Mon, 12 Dec 2022 23:38:47 -0600
Create PurpleAvatar to represent avatars
Testing Done:
Ran the unit tests and manually verified the docs.
Reviewed at https://reviews.imfreedom.org/r/2092/
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * purple |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * source distribution. |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public |
|
40539
2941deda6d8d
Use an https link to gnu.org in the license file headers
Gary Kramlich <grim@reaperworld.com>
parents:
40526
diff
changeset
|
19 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | */ |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | #include "libpurple/purpleattachment.h" |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | #include <glib/gi18n-lib.h> |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | struct _PurpleAttachment { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | GObject parent; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | guint64 id; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | gchar *content_type; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | gchar *local_uri; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | gchar *remote_uri; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | guint64 size; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | }; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | G_DEFINE_TYPE(PurpleAttachment, purple_attachment, G_TYPE_OBJECT); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | enum { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | PROP_0 = 0, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | PROP_ID, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | PROP_CONTENT_TYPE, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PROP_LOCAL_URI, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | PROP_REMOTE_URI, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | PROP_SIZE, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | N_PROPERTIES, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | }; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | static GParamSpec *properties[N_PROPERTIES]; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | /****************************************************************************** |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | * Private Setters |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | *****************************************************************************/ |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | static void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | purple_attachment_set_content_type(PurpleAttachment *attachment, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | const gchar *content_type) |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | if(attachment->content_type == content_type) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | return; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | g_clear_pointer(&attachment->content_type, g_free); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | attachment->content_type = g_strdup(content_type); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | g_object_notify_by_pspec(G_OBJECT(attachment), |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | properties[PROP_CONTENT_TYPE]); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | /****************************************************************************** |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | * GObject Implementation |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | *****************************************************************************/ |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | static void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | purple_attachment_get_property(GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | PurpleAttachment *attachment = PURPLE_ATTACHMENT(obj); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | switch(prop_id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | case PROP_ID: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | g_value_set_uint64(value, purple_attachment_get_id(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | case PROP_CONTENT_TYPE: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | g_value_set_string(value, purple_attachment_get_content_type(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | case PROP_LOCAL_URI: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | g_value_set_string(value, purple_attachment_get_local_uri(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | case PROP_REMOTE_URI: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | g_value_set_string(value, purple_attachment_get_remote_uri(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | case PROP_SIZE: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | g_value_set_uint64(value, purple_attachment_get_size(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | default: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | static void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | purple_attachment_set_property(GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | PurpleAttachment *attachment = PURPLE_ATTACHMENT(obj); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | switch(prop_id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | case PROP_ID: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | purple_attachment_set_id(attachment, g_value_get_uint64(value)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | case PROP_CONTENT_TYPE: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | purple_attachment_set_content_type(attachment, g_value_get_string(value)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | case PROP_LOCAL_URI: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | purple_attachment_set_local_uri(attachment, g_value_get_string(value)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | case PROP_REMOTE_URI: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | purple_attachment_set_remote_uri(attachment, g_value_get_string(value)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | case PROP_SIZE: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | purple_attachment_set_size(attachment, g_value_get_uint64(value)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | default: |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | break; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | static void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | purple_attachment_finalize(GObject *obj) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | PurpleAttachment *attachment = PURPLE_ATTACHMENT(obj); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | g_clear_pointer(&attachment->content_type, g_free); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | g_clear_pointer(&attachment->local_uri, g_free); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | g_clear_pointer(&attachment->remote_uri, g_free); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | G_OBJECT_CLASS(purple_attachment_parent_class)->finalize(obj); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | static void |
|
41960
c8a4853205e3
Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40539
diff
changeset
|
137 | purple_attachment_init(G_GNUC_UNUSED PurpleAttachment *attachment) { |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | static void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | purple_attachment_class_init(PurpleAttachmentClass *klass) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | obj_class->get_property = purple_attachment_get_property; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | obj_class->set_property = purple_attachment_set_property; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | obj_class->finalize = purple_attachment_finalize; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | /* add our properties */ |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | properties[PROP_ID] = g_param_spec_uint64( |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | "id", "id", "The identifier of the attachment", |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | 0, G_MAXUINT64, 0, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | ); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | properties[PROP_CONTENT_TYPE] = g_param_spec_string( |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | "content-type", "content-type", "The content type of the attachment", |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | "application/octet-stream", |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | ); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | properties[PROP_LOCAL_URI] = g_param_spec_string( |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | "local-uri", "local-uri", "The local URI of the attachment", |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | NULL, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | ); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | properties[PROP_REMOTE_URI] = g_param_spec_string( |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | "remote-uri", "remote-uri", "The remote URI of the attachment", |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | NULL, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | ); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | properties[PROP_SIZE] = g_param_spec_uint64( |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | "size", "size", "The file size of the attachment in bytes", |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | 0, G_MAXUINT64, 0, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | ); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | /****************************************************************************** |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | * Public API |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | *****************************************************************************/ |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | PurpleAttachment * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | purple_attachment_new(guint64 id, const gchar *content_type) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | g_return_val_if_fail(content_type != NULL, NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | return PURPLE_ATTACHMENT(g_object_new( |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | PURPLE_TYPE_ATTACHMENT, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | "id", id, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | "content-type", content_type, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | NULL |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | )); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | guint64 |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | purple_attachment_get_id(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), 0); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | return attachment->id; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | guint64 * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | purple_attachment_get_hash_key(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | return &attachment->id; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | purple_attachment_set_id(PurpleAttachment *attachment, guint64 id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | if(attachment->id == id) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | return; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | attachment->id = id; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | g_object_notify_by_pspec(G_OBJECT(attachment), properties[PROP_ID]); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | const gchar * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | purple_attachment_get_content_type(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | return attachment->content_type; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | const gchar * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | purple_attachment_get_local_uri(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | return attachment->local_uri; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | purple_attachment_set_local_uri(PurpleAttachment *attachment, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | const gchar *local_uri) |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | if(attachment->local_uri == local_uri) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | return; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | g_free(attachment->local_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | if(local_uri != NULL) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | gchar *scheme = g_uri_parse_scheme(local_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | if(scheme == NULL) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | attachment->local_uri = g_filename_to_uri(local_uri, NULL, NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | } else { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | g_free(scheme); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | attachment->local_uri = g_strdup(local_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | } else { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | attachment->local_uri = NULL; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | g_object_notify_by_pspec(G_OBJECT(attachment), properties[PROP_LOCAL_URI]); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | const gchar * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | purple_attachment_get_remote_uri(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | return attachment->remote_uri; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | purple_attachment_set_remote_uri(PurpleAttachment *attachment, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | const gchar *remote_uri) |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | if(attachment->remote_uri == remote_uri) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | return; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | g_free(attachment->remote_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | attachment->remote_uri = g_strdup(remote_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | g_object_notify_by_pspec(G_OBJECT(attachment), properties[PROP_REMOTE_URI]); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | guint64 |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | purple_attachment_get_size(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), 0); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | return attachment->size; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | purple_attachment_set_size(PurpleAttachment *attachment, guint64 size) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | attachment->size = size; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | g_object_notify_by_pspec(G_OBJECT(attachment), properties[PROP_SIZE]); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | gchar * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | purple_attachment_get_filename(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | if(attachment->remote_uri != NULL && attachment->remote_uri[0] != '\0') { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | return g_path_get_basename(attachment->remote_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | if(attachment->local_uri != NULL && attachment->local_uri[0] != '\0') { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | return g_path_get_basename(attachment->local_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | return g_strdup("unknown"); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | } |