Wed, 25 May 2022 23:52:45 -0500
Remove prpl-gtalk from XMPP console
It no longer exists, and complicates the code a bit.
|
40696
cf58ec89b1e4
Rename message.[ch] to purplemessage.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
1 | /* |
|
cf58ec89b1e4
Rename message.[ch] to purplemessage.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
cf58ec89b1e4
Rename message.[ch] to purplemessage.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
4 | * |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
7 | * source distribution. |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
8 | * |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
13 | * |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
18 | * |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
40696
cf58ec89b1e4
Rename message.[ch] to purplemessage.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
21 | */ |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
22 | |
|
40441
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
24 | |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
25 | #include "internal.h" |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
26 | |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
27 | #include "debug.h" |
|
41007
90d2dee9b3dc
Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents:
40951
diff
changeset
|
28 | #include "purpleenums.h" |
|
40696
cf58ec89b1e4
Rename message.[ch] to purplemessage.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
29 | #include "purplemessage.h" |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40195
diff
changeset
|
30 | #include "purpleprivate.h" |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
31 | |
|
39537
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
32 | /** |
|
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
33 | * PurpleMessage: |
|
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
34 | * |
|
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
35 | * A message data container. |
|
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
36 | */ |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
37 | struct _PurpleMessage { |
|
39537
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
38 | GObject parent; |
|
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
39 | |
|
41019
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
40 | gchar *id; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
41 | gchar *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:
40696
diff
changeset
|
42 | gchar *author_name_color; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
43 | gchar *author_alias; |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
44 | gchar *recipient; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
45 | |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
46 | gchar *contents; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
47 | PurpleMessageContentType content_type; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
48 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
49 | GDateTime *timestamp; |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
50 | PurpleMessageFlags flags; |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
51 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
52 | GHashTable *attachments; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
53 | }; |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
54 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
55 | enum { |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
56 | PROP_0, |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
57 | PROP_ID, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
58 | PROP_AUTHOR, |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
59 | PROP_AUTHOR_ALIAS, |
|
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:
40696
diff
changeset
|
60 | PROP_AUTHOR_NAME_COLOR, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
61 | PROP_RECIPIENT, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
62 | PROP_CONTENTS, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
63 | PROP_CONTENT_TYPE, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
64 | PROP_TIMESTAMP, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
65 | PROP_FLAGS, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
66 | N_PROPERTIES |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
67 | }; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
68 | static GParamSpec *properties[N_PROPERTIES]; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
69 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
70 | G_DEFINE_TYPE(PurpleMessage, purple_message, G_TYPE_OBJECT) |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
71 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
72 | /****************************************************************************** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
73 | * Helpers |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
74 | *****************************************************************************/ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
75 | static void |
|
41019
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
76 | purple_message_set_id(PurpleMessage *message, const gchar *id) { |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
77 | g_free(message->id); |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
78 | message->id = g_strdup(id); |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
79 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
80 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_ID]); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
81 | } |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
82 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
83 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
84 | purple_message_set_author(PurpleMessage *message, const gchar *author) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
85 | g_free(message->author); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
86 | message->author = g_strdup(author); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
87 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
88 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR]); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
89 | } |
|
39434
2dea6f348ebb
Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
90 | |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
91 | /****************************************************************************** |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
92 | * GObject Implementation |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
93 | *****************************************************************************/ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
94 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
95 | purple_message_get_property(GObject *object, guint param_id, GValue *value, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
96 | GParamSpec *pspec) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
97 | { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
98 | PurpleMessage *message = PURPLE_MESSAGE(object); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
99 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
100 | switch(param_id) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
101 | 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:
41007
diff
changeset
|
102 | g_value_set_string(value, purple_message_get_id(message)); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
103 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
104 | case PROP_AUTHOR: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
105 | g_value_set_string(value, purple_message_get_author(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
106 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
107 | case PROP_AUTHOR_ALIAS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
108 | g_value_set_string(value, purple_message_get_author_alias(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
109 | break; |
|
41019
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
110 | case PROP_AUTHOR_NAME_COLOR: |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
111 | g_value_set_string(value, |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
112 | purple_message_get_author_name_color(message)); |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
113 | break; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
114 | case PROP_RECIPIENT: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
115 | g_value_set_string(value, purple_message_get_recipient(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
116 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
117 | case PROP_CONTENTS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
118 | g_value_set_string(value, purple_message_get_contents(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
119 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
120 | case PROP_CONTENT_TYPE: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
121 | g_value_set_enum(value, purple_message_get_content_type(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
122 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
123 | case PROP_TIMESTAMP: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
124 | g_value_set_boxed(value, purple_message_get_timestamp(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
125 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
126 | case PROP_FLAGS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
127 | g_value_set_flags(value, purple_message_get_flags(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
128 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
129 | default: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
130 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
131 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
132 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
133 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
134 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
135 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
136 | purple_message_set_property(GObject *object, guint param_id, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
137 | const GValue *value, GParamSpec *pspec) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
138 | { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
139 | PurpleMessage *message = PURPLE_MESSAGE(object); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
140 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
141 | switch(param_id) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
142 | 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:
41007
diff
changeset
|
143 | purple_message_set_id(message, g_value_get_string(value)); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
144 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
145 | case PROP_AUTHOR: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
146 | purple_message_set_author(message, g_value_get_string(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
147 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
148 | case PROP_AUTHOR_ALIAS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
149 | purple_message_set_author_alias(message, g_value_get_string(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
150 | break; |
|
41019
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
151 | case PROP_AUTHOR_NAME_COLOR: |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
152 | purple_message_set_author_name_color(message, |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
153 | g_value_get_string(value)); |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
154 | break; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
155 | case PROP_RECIPIENT: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
156 | purple_message_set_recipient(message, g_value_get_string(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
157 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
158 | case PROP_CONTENTS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
159 | purple_message_set_contents(message, g_value_get_string(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
160 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
161 | case PROP_CONTENT_TYPE: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
162 | purple_message_set_content_type(message, g_value_get_enum(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
163 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
164 | case PROP_TIMESTAMP: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
165 | purple_message_set_timestamp(message, g_value_get_boxed(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
166 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
167 | case PROP_FLAGS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
168 | purple_message_set_flags(message, g_value_get_flags(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
169 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
170 | default: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
171 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
172 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
173 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
174 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
175 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
176 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
177 | purple_message_finalize(GObject *obj) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
178 | PurpleMessage *message = PURPLE_MESSAGE(obj); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
179 | |
|
41019
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
180 | g_free(message->id); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
181 | g_free(message->author); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
182 | g_free(message->author_alias); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
183 | g_free(message->recipient); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
184 | g_free(message->contents); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
185 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
186 | if(message->timestamp != NULL) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
187 | g_date_time_unref(message->timestamp); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
188 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
189 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
190 | g_hash_table_destroy(message->attachments); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
191 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
192 | G_OBJECT_CLASS(purple_message_parent_class)->finalize(obj); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
193 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
194 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
195 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
196 | purple_message_init(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
197 | message->attachments = g_hash_table_new_full(g_int64_hash, g_int64_equal, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
198 | NULL, g_object_unref); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
199 | } |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
200 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
201 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
202 | purple_message_class_init(PurpleMessageClass *klass) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
203 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
204 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
205 | obj_class->get_property = purple_message_get_property; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
206 | obj_class->set_property = purple_message_set_property; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
207 | obj_class->finalize = purple_message_finalize; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
208 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
209 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
210 | * PurpleMessage::id: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
211 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
212 | * The account specific identifier of the message. |
|
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:
40696
diff
changeset
|
213 | * |
|
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:
40696
diff
changeset
|
214 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
215 | */ |
|
41019
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
216 | properties[PROP_ID] = g_param_spec_string( |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
217 | "id", "ID", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
218 | "The session-unique message 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:
41007
diff
changeset
|
219 | NULL, |
|
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
220 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
221 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
222 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
223 | * PurpleMessage::author: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
224 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
225 | * The author of the message. |
|
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:
40696
diff
changeset
|
226 | * |
|
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:
40696
diff
changeset
|
227 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
228 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
229 | properties[PROP_AUTHOR] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
230 | "author", "Author", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
231 | "The username of the person, who sent the message.", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
232 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
233 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
234 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
235 | /** |
|
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:
40696
diff
changeset
|
236 | * PurpleMessage::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:
40696
diff
changeset
|
237 | * |
|
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:
40696
diff
changeset
|
238 | * The hex color for the author's name. |
|
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:
40696
diff
changeset
|
239 | * |
|
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:
40696
diff
changeset
|
240 | * Since: 3.0.0 |
|
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:
40696
diff
changeset
|
241 | */ |
|
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:
40696
diff
changeset
|
242 | properties[PROP_AUTHOR_NAME_COLOR] = g_param_spec_string( |
|
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:
40696
diff
changeset
|
243 | "author-name-color", "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:
40696
diff
changeset
|
244 | "The hex color to display the author's name with", |
|
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:
40696
diff
changeset
|
245 | 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:
40696
diff
changeset
|
246 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
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:
40696
diff
changeset
|
247 | |
|
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:
40696
diff
changeset
|
248 | /** |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
249 | * PurpleMessage::author-alias: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
250 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
251 | * The alias of the 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:
40696
diff
changeset
|
252 | * |
|
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:
40696
diff
changeset
|
253 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
254 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
255 | properties[PROP_AUTHOR_ALIAS] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
256 | "author-alias", "Author's alias", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
257 | "The alias of the sender", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
258 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
259 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
260 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
261 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
262 | * PurpleMessage::recipient: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
263 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
264 | * The recipient of the message. |
|
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:
40696
diff
changeset
|
265 | * |
|
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:
40696
diff
changeset
|
266 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
267 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
268 | properties[PROP_RECIPIENT] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
269 | "recipient", "Recipient", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
270 | "The username of the recipient.", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
271 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
272 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
273 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
274 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
275 | * PurpleMessage::content: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
276 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
277 | * The contents of the message. |
|
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:
40696
diff
changeset
|
278 | * |
|
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:
40696
diff
changeset
|
279 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
280 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
281 | properties[PROP_CONTENTS] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
282 | "contents", "Contents", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
283 | "The message text", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
284 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
285 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
286 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
287 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
288 | * PurpleMessage::content-type: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
289 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
290 | * The content-type of the message. |
|
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:
40696
diff
changeset
|
291 | * |
|
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:
40696
diff
changeset
|
292 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
293 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
294 | properties[PROP_CONTENT_TYPE] = g_param_spec_enum( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
295 | "content-type", "content-type", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
296 | "The content-type of the message.", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
297 | PURPLE_TYPE_MESSAGE_CONTENT_TYPE, PURPLE_MESSAGE_CONTENT_TYPE_PLAIN, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
298 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
299 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
300 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
301 | * PurpleMessage::timestamp: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
302 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
303 | * The timestamp of the message. |
|
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:
40696
diff
changeset
|
304 | * |
|
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:
40696
diff
changeset
|
305 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
306 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
307 | properties[PROP_TIMESTAMP] = g_param_spec_boxed( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
308 | "timestamp", "timestamp", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
309 | "The timestamp of the message", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
310 | G_TYPE_DATE_TIME, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
311 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
312 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
313 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
314 | * PurpleMessage::flags: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
315 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
316 | * The #PurpleMessageFlags for the message. |
|
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:
40696
diff
changeset
|
317 | * |
|
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:
40696
diff
changeset
|
318 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
319 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
320 | properties[PROP_FLAGS] = g_param_spec_flags( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
321 | "flags", "Flags", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
322 | "Bitwise set of #PurpleMessageFlags flags", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
323 | PURPLE_TYPE_MESSAGE_FLAGS, 0, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
324 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
325 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
326 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
327 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
328 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
329 | /****************************************************************************** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
330 | * Public API |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
331 | *****************************************************************************/ |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
332 | PurpleMessage * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
333 | purple_message_new_outgoing(const gchar *author, const gchar *recipient, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
334 | const gchar *contents, PurpleMessageFlags flags) |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
335 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
336 | PurpleMessage *message = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
337 | GDateTime *dt = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
338 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
339 | g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV)); |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
340 | g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM)); |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
341 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
342 | flags |= PURPLE_MESSAGE_SEND; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
343 | dt = g_date_time_new_now_local(); |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
344 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
345 | /* who may be NULL for outgoing MUC messages */ |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
346 | message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
347 | "author", author, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
348 | "recipient", recipient, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
349 | "contents", contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
350 | "timestamp", dt, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
351 | "flags", flags, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
352 | NULL)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
353 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
354 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
355 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
356 | return message; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
357 | } |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
358 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
359 | PurpleMessage * |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
360 | purple_message_new_incoming(const gchar *who, const gchar *contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
361 | PurpleMessageFlags flags, guint64 timestamp) |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
362 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
363 | PurpleMessage *message = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
364 | GDateTime *dt = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
365 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
366 | g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND)); |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
367 | g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM)); |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
368 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
369 | flags |= PURPLE_MESSAGE_RECV; |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
370 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
371 | if(timestamp == 0) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
372 | dt = g_date_time_new_now_local(); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
373 | } else { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
374 | dt = g_date_time_new_from_unix_local((gint64)timestamp); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
375 | } |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
376 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
377 | message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
378 | "author", who, |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
379 | "author-alias", who, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
380 | "contents", contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
381 | "timestamp", dt, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
382 | "flags", flags, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
383 | NULL)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
384 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
385 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
386 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
387 | return message; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
388 | } |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
389 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
390 | PurpleMessage * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
391 | purple_message_new_system(const gchar *contents, PurpleMessageFlags flags) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
392 | PurpleMessage *message = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
393 | GDateTime *dt = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
394 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
395 | g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND)); |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
396 | g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV)); |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
397 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
398 | flags |= PURPLE_MESSAGE_SYSTEM; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
399 | dt = g_date_time_new_now_local(); |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
400 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
401 | message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
402 | "contents", contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
403 | "timestamp", dt, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
404 | "flags", flags, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
405 | NULL)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
406 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
407 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
408 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
409 | return message; |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
410 | } |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
411 | |
|
41019
f1bdc43bf086
Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents:
41007
diff
changeset
|
412 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
413 | purple_message_get_id(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
414 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0); |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
415 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
416 | return message->id; |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
417 | } |
|
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
418 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
419 | const gchar * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
420 | purple_message_get_author(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
421 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
422 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
423 | return message->author; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
424 | } |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
425 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
426 | 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:
40696
diff
changeset
|
427 | purple_message_set_author_name_color(PurpleMessage *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:
40696
diff
changeset
|
428 | const gchar *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:
40696
diff
changeset
|
429 | { |
|
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:
40696
diff
changeset
|
430 | g_return_if_fail(PURPLE_IS_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:
40696
diff
changeset
|
431 | |
|
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:
40696
diff
changeset
|
432 | g_free(message->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:
40696
diff
changeset
|
433 | message->author_name_color = g_strdup(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:
40696
diff
changeset
|
434 | |
|
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:
40696
diff
changeset
|
435 | g_object_notify_by_pspec(G_OBJECT(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:
40696
diff
changeset
|
436 | properties[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:
40696
diff
changeset
|
437 | } |
|
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:
40696
diff
changeset
|
438 | |
|
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:
40696
diff
changeset
|
439 | const gchar * |
|
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:
40696
diff
changeset
|
440 | purple_message_get_author_name_color(PurpleMessage *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:
40696
diff
changeset
|
441 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 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:
40696
diff
changeset
|
442 | |
|
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:
40696
diff
changeset
|
443 | return message->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:
40696
diff
changeset
|
444 | } |
|
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:
40696
diff
changeset
|
445 | |
|
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:
40696
diff
changeset
|
446 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
447 | purple_message_set_recipient(PurpleMessage *message, const gchar *recipient) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
448 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
449 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
450 | g_free(message->recipient); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
451 | message->recipient = g_strdup(recipient); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
452 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
453 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_RECIPIENT]); |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
454 | } |
|
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
455 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
456 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
457 | purple_message_get_recipient(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
458 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
459 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
460 | return message->recipient; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
461 | } |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
462 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
463 | void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
464 | purple_message_set_author_alias(PurpleMessage *message, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
465 | const gchar *author_alias) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
466 | { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
467 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
468 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
469 | g_free(message->author_alias); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
470 | message->author_alias = g_strdup(author_alias); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
471 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
472 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR_ALIAS]); |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
473 | } |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
474 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
475 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
476 | purple_message_get_author_alias(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
477 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
478 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
479 | if (message->author_alias == NULL) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
480 | return purple_message_get_author(message); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
481 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
482 | return message->author_alias; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
483 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
484 | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
485 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
486 | purple_message_set_contents(PurpleMessage *message, const gchar *contents) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
487 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
488 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
489 | g_free(message->contents); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
490 | message->contents = g_strdup(contents); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
491 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
492 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENTS]); |
|
36094
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
493 | } |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
494 | |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
495 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
496 | purple_message_get_contents(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
497 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
36094
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
498 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
499 | return message->contents; |
|
36094
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
500 | } |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
501 | |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
502 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
503 | purple_message_set_content_type(PurpleMessage *message, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
504 | PurpleMessageContentType content_type) |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
505 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
506 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
507 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
508 | message->content_type = content_type; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
509 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
510 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENT_TYPE]); |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
511 | } |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
512 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
513 | PurpleMessageContentType |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
514 | purple_message_get_content_type(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
515 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
516 | PURPLE_MESSAGE_CONTENT_TYPE_PLAIN); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
517 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
518 | return message->content_type; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
519 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
520 | |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
521 | gboolean |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
522 | purple_message_is_empty(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
523 | return (message->contents == NULL || message->contents[0] == '\0'); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
524 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
525 | |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
526 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
527 | purple_message_set_timestamp(PurpleMessage *message, GDateTime *timestamp) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
528 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
529 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
530 | g_clear_pointer(&message->timestamp, g_date_time_unref); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
531 | if(timestamp != NULL) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
532 | message->timestamp = g_date_time_ref(timestamp); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
533 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
534 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
535 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_TIMESTAMP]); |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
536 | } |
|
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
537 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
538 | GDateTime * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
539 | purple_message_get_timestamp(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
540 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
541 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
542 | if(message->timestamp == NULL) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
543 | GDateTime *dt = g_date_time_new_now_local(); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
544 | purple_message_set_timestamp(message, dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
545 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
546 | } |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
547 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
548 | return message->timestamp; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
549 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
550 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
551 | gchar * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
552 | purple_message_format_timestamp(PurpleMessage *message, const gchar *format) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
553 | GDateTime *dt = NULL; |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
554 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
555 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
556 | g_return_val_if_fail(format != NULL, NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
557 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
558 | dt = purple_message_get_timestamp(message); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
559 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
560 | return g_date_time_format(dt, format); |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
561 | } |
|
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
562 | |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36086
diff
changeset
|
563 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
564 | purple_message_set_flags(PurpleMessage *message, PurpleMessageFlags flags) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
565 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
566 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
567 | message->flags = flags; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
568 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
569 | g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_FLAGS]); |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36086
diff
changeset
|
570 | } |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36086
diff
changeset
|
571 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
572 | PurpleMessageFlags |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
573 | purple_message_get_flags(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
574 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
575 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
576 | return message->flags; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
577 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
578 | |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
579 | gboolean |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
580 | purple_message_add_attachment(PurpleMessage *message, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
581 | PurpleAttachment *attachment) |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
582 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
583 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), FALSE); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
584 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), FALSE); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
585 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
586 | return g_hash_table_insert(message->attachments, |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
587 | purple_attachment_get_hash_key(attachment), |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
588 | g_object_ref(G_OBJECT(attachment))); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
589 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
590 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
591 | gboolean |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
592 | purple_message_remove_attachment(PurpleMessage *message, guint64 id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
593 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), FALSE); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
594 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
595 | return g_hash_table_remove(message->attachments, &id); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
596 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
597 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
598 | PurpleAttachment * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
599 | purple_message_get_attachment(PurpleMessage *message, guint64 id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
600 | PurpleAttachment *attachment = NULL; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
601 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
602 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
603 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
604 | attachment = g_hash_table_lookup(message->attachments, &id); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
605 | if(PURPLE_IS_ATTACHMENT(attachment)) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
606 | return PURPLE_ATTACHMENT(g_object_ref(G_OBJECT(attachment))); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
607 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
608 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
609 | return NULL; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
610 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
611 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
612 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
613 | purple_message_foreach_attachment(PurpleMessage *message, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
614 | PurpleAttachmentForeachFunc func, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
615 | gpointer data) |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
616 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
617 | GHashTableIter iter; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
618 | gpointer value; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
619 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
620 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
621 | g_return_if_fail(func != NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
622 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
623 | g_hash_table_iter_init(&iter, message->attachments); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
624 | while(g_hash_table_iter_next(&iter, NULL, &value)) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
625 | func(PURPLE_ATTACHMENT(value), data); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
626 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
627 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
628 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
629 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
630 | purple_message_clear_attachments(PurpleMessage *message) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
631 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
632 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
633 | g_hash_table_remove_all(message->attachments); |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
634 | } |