Wed, 08 Feb 2023 08:59:47 -0600
Export Account::error
I can't think of a good reason why we shouldn't expose the error property on
Accounts. But I would like to be able to set the error from the UI when there
is an error in the settings for example.
Testing Done:
Built the docs, ran the tests, used the prune connection action in the demo protocol plugin and verified everything was still working.
Reviewed at https://reviews.imfreedom.org/r/2216/
|
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 "debug.h" |
|
41007
90d2dee9b3dc
Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents:
40951
diff
changeset
|
26 | #include "purpleenums.h" |
|
40696
cf58ec89b1e4
Rename message.[ch] to purplemessage.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
40541
diff
changeset
|
27 | #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
|
28 | #include "purpleprivate.h" |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
29 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
30 | struct _PurpleMessage { |
|
39537
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
31 | GObject parent; |
|
70abf152c2d9
Use G_DECLARE_FINAL_TYPE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39436
diff
changeset
|
32 | |
|
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
|
33 | gchar *id; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
34 | 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
|
35 | gchar *author_name_color; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
36 | gchar *author_alias; |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
37 | gchar *recipient; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
38 | |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
39 | gchar *contents; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
40 | PurpleMessageContentType content_type; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
41 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
42 | GDateTime *timestamp; |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
43 | PurpleMessageFlags flags; |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
44 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
45 | GHashTable *attachments; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
46 | }; |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
47 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
48 | enum { |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
49 | PROP_0, |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
50 | PROP_ID, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
51 | PROP_AUTHOR, |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
52 | 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
|
53 | PROP_AUTHOR_NAME_COLOR, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
54 | PROP_RECIPIENT, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
55 | PROP_CONTENTS, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
56 | PROP_CONTENT_TYPE, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
57 | PROP_TIMESTAMP, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
58 | PROP_FLAGS, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
59 | N_PROPERTIES |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
60 | }; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
61 | static GParamSpec *properties[N_PROPERTIES]; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
62 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
63 | G_DEFINE_TYPE(PurpleMessage, purple_message, G_TYPE_OBJECT) |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
64 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
65 | /****************************************************************************** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
66 | * Helpers |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
67 | *****************************************************************************/ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
68 | 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
|
69 | 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
|
70 | 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
|
71 | message->id = g_strdup(id); |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
72 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
73 | 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
|
74 | } |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
75 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
76 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
77 | purple_message_set_author(PurpleMessage *message, const gchar *author) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
78 | g_free(message->author); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
79 | message->author = g_strdup(author); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
80 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
81 | 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
|
82 | } |
|
39434
2dea6f348ebb
Use G_DEFINE_TYPE_WITH_PRIVATE for PurpleMessage.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
83 | |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
84 | /****************************************************************************** |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
85 | * GObject Implementation |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
86 | *****************************************************************************/ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
87 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
88 | 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
|
89 | GParamSpec *pspec) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
90 | { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
91 | PurpleMessage *message = PURPLE_MESSAGE(object); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
92 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
93 | switch(param_id) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
94 | 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
|
95 | 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
|
96 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
97 | case PROP_AUTHOR: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
98 | g_value_set_string(value, purple_message_get_author(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
99 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
100 | case PROP_AUTHOR_ALIAS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | break; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
107 | case PROP_RECIPIENT: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
108 | g_value_set_string(value, purple_message_get_recipient(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
109 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
110 | case PROP_CONTENTS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
111 | g_value_set_string(value, purple_message_get_contents(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
112 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
113 | case PROP_CONTENT_TYPE: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
114 | 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
|
115 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
116 | case PROP_TIMESTAMP: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
117 | g_value_set_boxed(value, purple_message_get_timestamp(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
118 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
119 | case PROP_FLAGS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
120 | g_value_set_flags(value, purple_message_get_flags(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
121 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
122 | default: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
123 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
124 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
125 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
126 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
127 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
128 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
129 | purple_message_set_property(GObject *object, guint param_id, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
130 | const GValue *value, GParamSpec *pspec) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
131 | { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
132 | PurpleMessage *message = PURPLE_MESSAGE(object); |
|
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 | switch(param_id) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
135 | 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
|
136 | 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
|
137 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
138 | case PROP_AUTHOR: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
139 | purple_message_set_author(message, g_value_get_string(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
140 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
141 | case PROP_AUTHOR_ALIAS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
142 | 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
|
143 | 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
|
144 | 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
|
145 | 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
|
146 | 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
|
147 | break; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
148 | case PROP_RECIPIENT: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
149 | purple_message_set_recipient(message, g_value_get_string(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
150 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
151 | case PROP_CONTENTS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
152 | purple_message_set_contents(message, g_value_get_string(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
153 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
154 | case PROP_CONTENT_TYPE: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
155 | 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
|
156 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
157 | case PROP_TIMESTAMP: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
158 | purple_message_set_timestamp(message, g_value_get_boxed(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
159 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
160 | case PROP_FLAGS: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
161 | purple_message_set_flags(message, g_value_get_flags(value)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
162 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
163 | default: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
164 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
165 | break; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
166 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
167 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
168 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
169 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
170 | purple_message_finalize(GObject *obj) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
171 | PurpleMessage *message = PURPLE_MESSAGE(obj); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
172 | |
|
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
|
173 | g_free(message->id); |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
174 | g_free(message->author); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
175 | g_free(message->author_alias); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
176 | g_free(message->recipient); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
177 | g_free(message->contents); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
178 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
179 | if(message->timestamp != NULL) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
180 | g_date_time_unref(message->timestamp); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
181 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
182 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
183 | g_hash_table_destroy(message->attachments); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
184 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
185 | G_OBJECT_CLASS(purple_message_parent_class)->finalize(obj); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
186 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
187 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
188 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
189 | purple_message_init(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
190 | 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
|
191 | NULL, g_object_unref); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
192 | } |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
193 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
194 | static void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
195 | purple_message_class_init(PurpleMessageClass *klass) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
196 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
197 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
198 | obj_class->get_property = purple_message_get_property; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
199 | obj_class->set_property = purple_message_set_property; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
200 | obj_class->finalize = purple_message_finalize; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
201 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
202 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
203 | * PurpleMessage::id: |
|
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 | * 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
|
206 | * |
|
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
|
207 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
208 | */ |
|
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
|
209 | properties[PROP_ID] = g_param_spec_string( |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
210 | "id", "ID", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
211 | "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
|
212 | 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
|
213 | 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
|
214 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
215 | /** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
216 | * PurpleMessage::author: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
217 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
218 | * 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
|
219 | * |
|
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
|
220 | * Since: 3.0.0 |
|
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 | properties[PROP_AUTHOR] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
223 | "author", "Author", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
224 | "The username of the person, who sent the message.", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
225 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
226 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
227 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
228 | /** |
|
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
|
229 | * 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
|
230 | * |
|
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
|
231 | * 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
|
232 | * |
|
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
|
233 | * 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
|
234 | */ |
|
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
|
235 | 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
|
236 | "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
|
237 | "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
|
238 | 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
|
239 | 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
|
240 | |
|
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 | /** |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
242 | * PurpleMessage::author-alias: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
243 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
244 | * 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
|
245 | * |
|
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 | * Since: 3.0.0 |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
247 | */ |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
248 | properties[PROP_AUTHOR_ALIAS] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
249 | "author-alias", "Author's alias", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
250 | "The alias of the sender", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
251 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
252 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
253 | |
|
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 | * PurpleMessage::recipient: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
256 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
257 | * 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
|
258 | * |
|
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
|
259 | * Since: 3.0.0 |
|
40541
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 | properties[PROP_RECIPIENT] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
262 | "recipient", "Recipient", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
263 | "The username of the recipient.", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
264 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
265 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
266 | |
|
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 | * PurpleMessage::content: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
269 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
270 | * 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
|
271 | * |
|
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
|
272 | * Since: 3.0.0 |
|
40541
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 | properties[PROP_CONTENTS] = g_param_spec_string( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
275 | "contents", "Contents", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
276 | "The message text", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
277 | NULL, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
278 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
279 | |
|
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 | * PurpleMessage::content-type: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
282 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
283 | * 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
|
284 | * |
|
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
|
285 | * Since: 3.0.0 |
|
40541
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 | properties[PROP_CONTENT_TYPE] = g_param_spec_enum( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
288 | "content-type", "content-type", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
289 | "The content-type of the message.", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
290 | PURPLE_TYPE_MESSAGE_CONTENT_TYPE, PURPLE_MESSAGE_CONTENT_TYPE_PLAIN, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
291 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
292 | |
|
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 | * PurpleMessage::timestamp: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
295 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
296 | * 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
|
297 | * |
|
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
|
298 | * Since: 3.0.0 |
|
40541
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 | properties[PROP_TIMESTAMP] = g_param_spec_boxed( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
301 | "timestamp", "timestamp", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
302 | "The timestamp of the message", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
303 | G_TYPE_DATE_TIME, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
304 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
305 | |
|
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 | * PurpleMessage::flags: |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
308 | * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
309 | * 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
|
310 | * |
|
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
|
311 | * Since: 3.0.0 |
|
40541
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 | properties[PROP_FLAGS] = g_param_spec_flags( |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
314 | "flags", "Flags", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
315 | "Bitwise set of #PurpleMessageFlags flags", |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
316 | PURPLE_TYPE_MESSAGE_FLAGS, 0, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
317 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
318 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
319 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
320 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
321 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
322 | /****************************************************************************** |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
323 | * Public API |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
324 | *****************************************************************************/ |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
325 | PurpleMessage * |
|
42048
8d4a5f33faa8
Add a PurpleAccount parameter to the PurpleMessage constructors
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
326 | purple_message_new_outgoing(G_GNUC_UNUSED PurpleAccount *account, |
|
8d4a5f33faa8
Add a PurpleAccount parameter to the PurpleMessage constructors
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
327 | const gchar *author, const gchar *recipient, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
328 | const gchar *contents, PurpleMessageFlags flags) |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
329 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
330 | PurpleMessage *message = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
331 | GDateTime *dt = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
332 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
333 | 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
|
334 | 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
|
335 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
336 | flags |= PURPLE_MESSAGE_SEND; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
337 | 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
|
338 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
339 | /* who may be NULL for outgoing MUC messages */ |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
340 | message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
341 | "author", author, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
342 | "recipient", recipient, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
343 | "contents", contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
344 | "timestamp", dt, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
345 | "flags", flags, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
346 | NULL)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
347 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
348 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
349 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
350 | return message; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
351 | } |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
352 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
353 | PurpleMessage * |
|
42048
8d4a5f33faa8
Add a PurpleAccount parameter to the PurpleMessage constructors
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
354 | purple_message_new_incoming(G_GNUC_UNUSED PurpleAccount *account, |
|
8d4a5f33faa8
Add a PurpleAccount parameter to the PurpleMessage constructors
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
355 | const gchar *who, const gchar *contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
356 | PurpleMessageFlags flags, guint64 timestamp) |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
357 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
358 | PurpleMessage *message = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
359 | GDateTime *dt = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
360 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
361 | 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
|
362 | 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
|
363 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
364 | flags |= PURPLE_MESSAGE_RECV; |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
365 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
366 | if(timestamp == 0) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
367 | dt = g_date_time_new_now_local(); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
368 | } else { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
369 | dt = g_date_time_new_from_unix_local((gint64)timestamp); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
370 | } |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
371 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
372 | 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
|
373 | "author", who, |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
374 | "author-alias", who, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
375 | "contents", contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
376 | "timestamp", dt, |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
377 | "flags", flags, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
378 | NULL)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
379 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
380 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
381 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
382 | return message; |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
383 | } |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
384 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
385 | PurpleMessage * |
|
42048
8d4a5f33faa8
Add a PurpleAccount parameter to the PurpleMessage constructors
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
386 | purple_message_new_system(G_GNUC_UNUSED PurpleAccount *account, |
|
8d4a5f33faa8
Add a PurpleAccount parameter to the PurpleMessage constructors
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
387 | const gchar *contents, PurpleMessageFlags flags) |
|
8d4a5f33faa8
Add a PurpleAccount parameter to the PurpleMessage constructors
Gary Kramlich <grim@reaperworld.com>
parents:
41685
diff
changeset
|
388 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
389 | PurpleMessage *message = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
390 | GDateTime *dt = NULL; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
391 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
392 | 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
|
393 | 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
|
394 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
395 | flags |= PURPLE_MESSAGE_SYSTEM; |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
396 | 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
|
397 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
398 | 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
|
399 | "contents", contents, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
400 | "timestamp", dt, |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
401 | "flags", flags, |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
402 | NULL)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
403 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
404 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
405 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
406 | return message; |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
407 | } |
|
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
408 | |
|
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
|
409 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
410 | purple_message_get_id(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
411 | 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
|
412 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
413 | return message->id; |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
414 | } |
|
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 | const gchar * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
417 | purple_message_get_author(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
418 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
419 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
420 | return message->author; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
421 | } |
|
36075
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
422 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
423 | 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
|
424 | 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
|
425 | 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
|
426 | { |
|
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 | 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
|
428 | |
|
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 | 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
|
430 | 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
|
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_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
|
433 | 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
|
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 | |
|
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 | 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
|
437 | 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
|
438 | 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
|
439 | |
|
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 | 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
|
441 | } |
|
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 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
444 | purple_message_set_recipient(PurpleMessage *message, const gchar *recipient) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
445 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
446 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
447 | g_free(message->recipient); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
448 | message->recipient = g_strdup(recipient); |
|
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_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
|
451 | } |
|
dfb5988e053b
PurpleMessage: implement IDs and storage-by-id
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36074
diff
changeset
|
452 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
453 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
454 | purple_message_get_recipient(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
455 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
456 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
457 | return message->recipient; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
458 | } |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
459 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
460 | void |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
461 | purple_message_set_author_alias(PurpleMessage *message, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
462 | const gchar *author_alias) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
463 | { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
464 | 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
|
465 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
466 | g_free(message->author_alias); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
467 | message->author_alias = g_strdup(author_alias); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
468 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
469 | 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
|
470 | } |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
471 | |
|
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36094
diff
changeset
|
472 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
473 | purple_message_get_author_alias(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
474 | 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
|
475 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
476 | if (message->author_alias == NULL) |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
477 | return purple_message_get_author(message); |
|
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 | return message->author_alias; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
480 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
481 | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
482 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
483 | purple_message_set_contents(PurpleMessage *message, const gchar *contents) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
484 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
485 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
486 | g_free(message->contents); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
487 | message->contents = g_strdup(contents); |
|
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_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
|
490 | } |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
491 | |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
492 | const gchar * |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
493 | purple_message_get_contents(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
494 | 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
|
495 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
496 | return message->contents; |
|
36094
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
497 | } |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
498 | |
|
dc5d15df3a88
PurpleMessage: add author's alias
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36092
diff
changeset
|
499 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
500 | purple_message_set_content_type(PurpleMessage *message, |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
501 | PurpleMessageContentType content_type) |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
502 | { |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
503 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
504 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
505 | message->content_type = content_type; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
506 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
507 | 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
|
508 | } |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36077
diff
changeset
|
509 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
510 | PurpleMessageContentType |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
511 | purple_message_get_content_type(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
512 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
513 | PURPLE_MESSAGE_CONTENT_TYPE_PLAIN); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
514 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
515 | return message->content_type; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
516 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
517 | |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
518 | gboolean |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
519 | purple_message_is_empty(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
520 | 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
|
521 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
522 | |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
523 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
524 | purple_message_set_timestamp(PurpleMessage *message, GDateTime *timestamp) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
525 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
526 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
527 | g_clear_pointer(&message->timestamp, g_date_time_unref); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
528 | if(timestamp != NULL) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
529 | message->timestamp = g_date_time_ref(timestamp); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
530 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
531 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
532 | 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
|
533 | } |
|
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
534 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
535 | GDateTime * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
536 | purple_message_get_timestamp(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
537 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
538 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
539 | if(message->timestamp == NULL) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
540 | GDateTime *dt = g_date_time_new_now_local(); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
541 | purple_message_set_timestamp(message, dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
542 | g_date_time_unref(dt); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
543 | } |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
544 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
545 | return message->timestamp; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
546 | } |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
547 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
548 | gchar * |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
549 | purple_message_format_timestamp(PurpleMessage *message, const gchar *format) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
550 | GDateTime *dt = NULL; |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
551 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
552 | g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
553 | g_return_val_if_fail(format != NULL, NULL); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
554 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
555 | dt = purple_message_get_timestamp(message); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
556 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
557 | return g_date_time_format(dt, format); |
|
36085
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
558 | } |
|
f4d353818589
Add time property to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36079
diff
changeset
|
559 | |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36086
diff
changeset
|
560 | void |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
561 | purple_message_set_flags(PurpleMessage *message, PurpleMessageFlags flags) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
562 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
563 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
564 | message->flags = flags; |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
565 | |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
566 | 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
|
567 | } |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36086
diff
changeset
|
568 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
569 | PurpleMessageFlags |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
570 | purple_message_get_flags(PurpleMessage *message) { |
|
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
571 | 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
|
572 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
573 | return message->flags; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
574 | } |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36075
diff
changeset
|
575 | |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
576 | gboolean |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
577 | purple_message_add_attachment(PurpleMessage *message, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
578 | PurpleAttachment *attachment) |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
579 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
580 | 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
|
581 | 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
|
582 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
583 | return g_hash_table_insert(message->attachments, |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
584 | purple_attachment_get_hash_key(attachment), |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
585 | g_object_ref(G_OBJECT(attachment))); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
586 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
587 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
588 | gboolean |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
589 | purple_message_remove_attachment(PurpleMessage *message, guint64 id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
590 | 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
|
591 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
592 | return g_hash_table_remove(message->attachments, &id); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
593 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
594 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
595 | PurpleAttachment * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
596 | purple_message_get_attachment(PurpleMessage *message, guint64 id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
597 | PurpleAttachment *attachment = NULL; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
598 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
599 | 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
|
600 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
601 | attachment = g_hash_table_lookup(message->attachments, &id); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
602 | if(PURPLE_IS_ATTACHMENT(attachment)) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
603 | return PURPLE_ATTACHMENT(g_object_ref(G_OBJECT(attachment))); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
604 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
605 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
606 | return NULL; |
|
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 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
610 | purple_message_foreach_attachment(PurpleMessage *message, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
611 | PurpleAttachmentForeachFunc func, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
612 | gpointer data) |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
613 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
614 | GHashTableIter iter; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
615 | gpointer value; |
|
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 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
618 | g_return_if_fail(func != NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
619 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
620 | g_hash_table_iter_init(&iter, message->attachments); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
621 | while(g_hash_table_iter_next(&iter, NULL, &value)) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
622 | func(PURPLE_ATTACHMENT(value), data); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
623 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
624 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
625 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
626 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
627 | purple_message_clear_attachments(PurpleMessage *message) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
628 | g_return_if_fail(PURPLE_IS_MESSAGE(message)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
40441
diff
changeset
|
629 | |
|
40541
9ceb8d25d4d9
PurpleMessage cleanups from hell
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
630 | g_hash_table_remove_all(message->attachments); |
|
36074
4f7b1fea3cd3
Initial implementation for PurpleMessage class
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
631 | } |