Thu, 24 Apr 2025 21:42:59 -0500
Add Purple.Contact.is_own_account
This checks to see if a Purple.Contact shares the Purple.ContactInfo with the
account it is tied to.
Testing Done:
Ran the unit tests under valgrind and called in the turtles.
Reviewed at https://reviews.imfreedom.org/r/3985/
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify it |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the Free |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
11 | * Software Foundation; either version 2 of the License, or (at your option) |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
12 | * any later version. |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
17 | * more details. |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License along with |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
20 | * 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
|
21 | */ |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
23 | #include "purpleattachment.h" |
|
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
24 | #include "util.h" |
|
40526
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 | #include <glib/gi18n-lib.h> |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | struct _PurpleAttachment { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | GObject parent; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
31 | char *id; |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
32 | char *content_type; |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
33 | gboolean _inline; |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
35 | char *local_uri; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
36 | char *remote_uri; |
|
40526
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 | guint64 size; |
|
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 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | enum { |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
42 | PROP_0, |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | PROP_ID, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PROP_CONTENT_TYPE, |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
45 | PROP_INLINE, |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | PROP_LOCAL_URI, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | PROP_REMOTE_URI, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | PROP_SIZE, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | N_PROPERTIES, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | }; |
|
42584
687260353985
Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42576
diff
changeset
|
51 | static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | |
|
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 | * GObject Implementation |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | *****************************************************************************/ |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
56 | G_DEFINE_FINAL_TYPE(PurpleAttachment, purple_attachment, G_TYPE_OBJECT); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
57 | |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | static void |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
59 | purple_attachment_get_property(GObject *obj, guint prop_id, GValue *value, |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
60 | GParamSpec *pspec) |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
61 | { |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | PurpleAttachment *attachment = PURPLE_ATTACHMENT(obj); |
|
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 | switch(prop_id) { |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
65 | case PROP_ID: |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
66 | g_value_set_string(value, purple_attachment_get_id(attachment)); |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
67 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
68 | case PROP_CONTENT_TYPE: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
69 | g_value_set_string(value, |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
70 | purple_attachment_get_content_type(attachment)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
71 | break; |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
72 | case PROP_INLINE: |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
73 | g_value_set_boolean(value, purple_attachment_get_inline(attachment)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
74 | break; |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
75 | case PROP_LOCAL_URI: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
76 | g_value_set_string(value, purple_attachment_get_local_uri(attachment)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
77 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
78 | case PROP_REMOTE_URI: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
79 | g_value_set_string(value, |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
80 | purple_attachment_get_remote_uri(attachment)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
81 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
82 | case PROP_SIZE: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
83 | g_value_set_uint64(value, purple_attachment_get_size(attachment)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
84 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
85 | default: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
86 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
87 | break; |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | static void |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
92 | purple_attachment_set_property(GObject *obj, guint prop_id, |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
93 | const GValue *value, GParamSpec *pspec) |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
94 | { |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | PurpleAttachment *attachment = PURPLE_ATTACHMENT(obj); |
|
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 | switch(prop_id) { |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
98 | case PROP_ID: |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
99 | purple_attachment_set_id(attachment, g_value_get_string(value)); |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
100 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
101 | case PROP_CONTENT_TYPE: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
102 | purple_attachment_set_content_type(attachment, |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
103 | g_value_get_string(value)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
104 | break; |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
105 | case PROP_INLINE: |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
106 | purple_attachment_set_inline(attachment, g_value_get_boolean(value)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
107 | break; |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
108 | case PROP_LOCAL_URI: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
109 | purple_attachment_set_local_uri(attachment, g_value_get_string(value)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
110 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
111 | case PROP_REMOTE_URI: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
112 | purple_attachment_set_remote_uri(attachment, |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
113 | g_value_get_string(value)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
114 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
115 | case PROP_SIZE: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
116 | purple_attachment_set_size(attachment, g_value_get_uint64(value)); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
117 | break; |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
118 | default: |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
119 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, prop_id, pspec); |
|
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
120 | break; |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | } |
|
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 | static void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | purple_attachment_finalize(GObject *obj) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | PurpleAttachment *attachment = PURPLE_ATTACHMENT(obj); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
128 | g_clear_pointer(&attachment->id, g_free); |
|
40526
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 | |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
148 | /** |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
149 | * PurpleAttachment:id: |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
150 | * |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
151 | * The identifier of this attachment. |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
152 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
153 | * Since: 3.0 |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
154 | */ |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
155 | properties[PROP_ID] = g_param_spec_string( |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
156 | "id", NULL, NULL, |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
157 | NULL, |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
158 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
160 | /** |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
161 | * PurpleAttachment:content-type: |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
162 | * |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
163 | * The content type of this attachment. This should be a commonly used |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
164 | * mime type. |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
165 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
166 | * Since: 3.0 |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
167 | */ |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | properties[PROP_CONTENT_TYPE] = g_param_spec_string( |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
169 | "content-type", NULL, NULL, |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | "application/octet-stream", |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
171 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
172 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
173 | /** |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
174 | * PurpleAttachment:inline: |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
175 | * |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
176 | * Whether or not the attachment should be shown inline. |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
177 | * |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
178 | * This property is a hint that user interfaces may use to only show this |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
179 | * attachment inline with message content instead of as an external |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
180 | * attachment. |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
181 | * |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
182 | * Since: 3.0 |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
183 | */ |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
184 | properties[PROP_INLINE] = g_param_spec_boolean( |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
185 | "inline", NULL, NULL, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
186 | FALSE, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
187 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
189 | /** |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
190 | * PurpleAttachment:local-uri: |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
191 | * |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
192 | * The local URI of the attachment. That is where the file can be found on |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
193 | * disk. |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
194 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
195 | * Since: 3.0 |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
196 | */ |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | properties[PROP_LOCAL_URI] = g_param_spec_string( |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
198 | "local-uri", NULL, NULL, |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | NULL, |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
200 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
202 | /** |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
203 | * PurpleAttachment:remote-uri: |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
204 | * |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
205 | * The remote URI of the attachment. In most cases this is just a base |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
206 | * filename. |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
207 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
208 | * Since: 3.0 |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
209 | */ |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
210 | properties[PROP_REMOTE_URI] = g_param_spec_string( |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
211 | "remote-uri", NULL, NULL, |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
212 | NULL, |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
213 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
214 | |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
215 | /** |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
216 | * PurpleAttachment:size: |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
217 | * |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
218 | * The size of the attachment in bytes. |
|
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
219 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
220 | * Since: 3.0 |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
221 | */ |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | properties[PROP_SIZE] = g_param_spec_uint64( |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
223 | "size", NULL, NULL, |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | 0, G_MAXUINT64, 0, |
|
42406
15d400ce4285
Fix up some issues with the documentation on PurpleAttachment's properties
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
225 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
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 | |
|
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 | * Public API |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | *****************************************************************************/ |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | PurpleAttachment * |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
234 | purple_attachment_new(const char *id, const char *content_type) { |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | g_return_val_if_fail(content_type != NULL, NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42584
diff
changeset
|
237 | return g_object_new( |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | PURPLE_TYPE_ATTACHMENT, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | "id", id, |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | "content-type", content_type, |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42584
diff
changeset
|
241 | NULL); |
|
40526
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 | |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
244 | gboolean |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
245 | purple_attachment_equal(PurpleAttachment *attachment1, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
246 | PurpleAttachment *attachment2) |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
247 | { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
248 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment1), FALSE); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
249 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment2), FALSE); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
250 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
251 | return purple_strequal(attachment1->id, attachment2->id); |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
252 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
253 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
254 | const char * |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | purple_attachment_get_id(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), 0); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | return attachment->id; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | void |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
262 | purple_attachment_set_id(PurpleAttachment *attachment, const char *id) { |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
265 | if(g_set_str(&attachment->id, id)) { |
|
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
266 | g_object_notify_by_pspec(G_OBJECT(attachment), properties[PROP_ID]); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
270 | gboolean |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
271 | purple_attachment_get_inline(PurpleAttachment *attachment) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
272 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), FALSE); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
273 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
274 | return attachment->_inline; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
275 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
276 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
277 | void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
278 | purple_attachment_set_inline(PurpleAttachment *attachment, gboolean _inline) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
279 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
280 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
281 | if(attachment->_inline != _inline) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
282 | attachment->_inline = _inline; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
283 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
284 | g_object_notify_by_pspec(G_OBJECT(attachment), |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
285 | properties[PROP_INLINE]); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
286 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
287 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
288 | |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
289 | const char * |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | purple_attachment_get_content_type(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), NULL); |
|
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->content_type; |
|
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 | |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
296 | void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
297 | purple_attachment_set_content_type(PurpleAttachment *attachment, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
298 | const char *content_type) |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
299 | { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
300 | if(g_set_str(&attachment->content_type, content_type)) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
301 | g_object_notify_by_pspec(G_OBJECT(attachment), |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
302 | properties[PROP_CONTENT_TYPE]); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
303 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
304 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
305 | |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
306 | const char * |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | purple_attachment_get_local_uri(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | return attachment->local_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 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | purple_attachment_set_local_uri(PurpleAttachment *attachment, |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
315 | const char *local_uri) |
|
40526
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 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
319 | if(g_set_str(&attachment->local_uri, local_uri)) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
320 | g_object_notify_by_pspec(G_OBJECT(attachment), |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
42841
diff
changeset
|
321 | properties[PROP_LOCAL_URI]); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
325 | const char * |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | purple_attachment_get_remote_uri(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | return attachment->remote_uri; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | purple_attachment_set_remote_uri(PurpleAttachment *attachment, |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
334 | const char *remote_uri) |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | |
|
42767
8cf1d11b59c1
Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42613
diff
changeset
|
338 | if(g_set_str(&attachment->remote_uri, remote_uri)) { |
|
8cf1d11b59c1
Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42613
diff
changeset
|
339 | g_object_notify_by_pspec(G_OBJECT(attachment), |
|
8cf1d11b59c1
Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42613
diff
changeset
|
340 | properties[PROP_REMOTE_URI]); |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | guint64 |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | purple_attachment_get_size(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), 0); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | return attachment->size; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | void |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | purple_attachment_set_size(PurpleAttachment *attachment, guint64 size) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | g_return_if_fail(PURPLE_IS_ATTACHMENT(attachment)); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | attachment->size = size; |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | 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
|
358 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | |
|
42841
fbb5c5cb37f4
Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents:
42767
diff
changeset
|
360 | char * |
|
40526
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | purple_attachment_get_filename(PurpleAttachment *attachment) { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), NULL); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | if(attachment->remote_uri != NULL && attachment->remote_uri[0] != '\0') { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | return g_path_get_basename(attachment->remote_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | if(attachment->local_uri != NULL && attachment->local_uri[0] != '\0') { |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | return g_path_get_basename(attachment->local_uri); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | } |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | return g_strdup("unknown"); |
|
c8cc1a4c4a02
Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | } |