Mon, 12 May 2025 20:25:16 -0500
Handle formatting in server messages
Testing Done:
Used the default motd on my local ergo server to verify that formatting was working.
Reviewed at https://reviews.imfreedom.org/r/3991/
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This library is free software; you can redistribute it and/or |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * modify it under the terms of the GNU Lesser General Public |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * License as published by the Free Software Foundation; either |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * version 2 of the License, or (at your option) any later version. |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This library is distributed in the hope that it will be useful, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * Lesser General Public License for more details. |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU Lesser General Public |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib.h> |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include <purple.h> |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | /****************************************************************************** |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | * Callbacks |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | *****************************************************************************/ |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | static void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | test_purple_attachment_notify_counter_cb(GObject *self, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | G_GNUC_UNUSED GParamSpec *pspec, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | gpointer data) |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | guint *counter = data; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | g_assert_true(PURPLE_IS_ATTACHMENT(self)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | *counter = *counter + 1; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | /****************************************************************************** |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | * Tests |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | *****************************************************************************/ |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | static void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | test_purple_attachment_new(void) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | PurpleAttachment *attachment = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
45 | attachment = purple_attachment_new("1337", "text/plain"); |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | g_assert_true(PURPLE_IS_ATTACHMENT(attachment)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | g_assert_finalize_object(attachment); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | static void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | test_purple_attachment_properties(void) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | PurpleAttachment *attachment = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | char *content_type = NULL; |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
56 | char *id = NULL; |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | char *local_uri = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | char *remote_uri = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | gboolean _inline = FALSE; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | guint64 in_size = 0x1337; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | guint64 out_size = 0; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | attachment = g_object_new( |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | PURPLE_TYPE_ATTACHMENT, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | "content-type", "text/plain", |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
66 | "id", "1337", |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | "inline", TRUE, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | "local-uri", "local-uri", |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | "remote-uri", "remote-uri", |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | "size", in_size, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | NULL); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | g_object_get( |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | attachment, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | "content-type", &content_type, |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
76 | "id", &id, |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | "inline", &_inline, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | "local-uri", &local_uri, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | "remote-uri", &remote_uri, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | "size", &out_size, |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | NULL); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | g_assert_cmpstr(content_type, ==, "text/plain"); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | g_clear_pointer(&content_type, g_free); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
86 | g_assert_cmpstr(id, ==, "1337"); |
|
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
87 | g_clear_pointer(&id, g_free); |
|
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
88 | |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | g_assert_true(_inline); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | g_assert_cmpstr(local_uri, ==, "local-uri"); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | g_clear_pointer(&local_uri, g_free); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | g_assert_cmpstr(remote_uri, ==, "remote-uri"); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | g_clear_pointer(&remote_uri, g_free); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | g_assert_cmpuint(out_size, ==, in_size); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | g_assert_finalize_object(attachment); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | static void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | test_purple_attachment_notify(void) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | PurpleAttachment *attachment = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | guint counter = 0; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | attachment = g_object_new(PURPLE_TYPE_ATTACHMENT, NULL); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | g_signal_connect(attachment, "notify", |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | G_CALLBACK(test_purple_attachment_notify_counter_cb), |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | &counter); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | counter = 0; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | purple_attachment_set_content_type(attachment, "text/plain"); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | g_assert_cmpuint(counter, ==, 1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | counter = 0; |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
117 | purple_attachment_set_id(attachment, "1337"); |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | g_assert_cmpuint(counter, ==, 1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | counter = 0; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | purple_attachment_set_inline(attachment, TRUE); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | g_assert_cmpuint(counter, ==, 1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | counter = 0; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | purple_attachment_set_local_uri(attachment, "/dev/null"); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | g_assert_cmpuint(counter, ==, 1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | counter = 0; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | purple_attachment_set_remote_uri(attachment, "/dev/null"); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | g_assert_cmpuint(counter, ==, 1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | counter = 0; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | purple_attachment_set_size(attachment, 42lu); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | g_assert_cmpuint(counter, ==, 1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | g_assert_finalize_object(attachment); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | static void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | test_purple_attachment_equal_self(void) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | PurpleAttachment *attachment = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
143 | attachment = purple_attachment_new("1337", "text/plain"); |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | g_assert_true(purple_attachment_equal(attachment, attachment)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | g_assert_finalize_object(attachment); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | static void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | test_purple_attachment_equal_true(void) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | PurpleAttachment *attachment1 = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | PurpleAttachment *attachment2 = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
155 | attachment1 = purple_attachment_new("1337", "text/plain"); |
|
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
156 | attachment2 = purple_attachment_new("1337", "text/html"); |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | g_assert_true(purple_attachment_equal(attachment1, attachment2)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | g_assert_finalize_object(attachment1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | g_assert_finalize_object(attachment2); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | static void |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | test_purple_attachment_equal_false(void) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | PurpleAttachment *attachment1 = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | PurpleAttachment *attachment2 = NULL; |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | |
|
43147
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
169 | attachment1 = purple_attachment_new("1337", "text/plain"); |
|
835d74e5d22d
Make Purple.Attachment:id a string
Gary Kramlich <grim@reaperworld.com>
parents:
43144
diff
changeset
|
170 | attachment2 = purple_attachment_new("7331", "text/html"); |
|
43144
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | g_assert_false(purple_attachment_equal(attachment1, attachment2)); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | g_assert_finalize_object(attachment1); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | g_assert_finalize_object(attachment2); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | } |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | /****************************************************************************** |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | * Main |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | *****************************************************************************/ |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | int |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | main(int argc, char *argv[]) { |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | g_test_init(&argc, &argv, NULL); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | g_test_set_nonfatal_assertions(); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | g_test_add_func("/attachment/new", test_purple_attachment_new); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | g_test_add_func("/attachment/properties", |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | test_purple_attachment_properties); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | g_test_add_func("/attachment/notify", test_purple_attachment_notify); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | g_test_add_func("/attachment/equal/self", |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | test_purple_attachment_equal_self); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | g_test_add_func("/attachment/equal/true", |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | test_purple_attachment_equal_true); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | g_test_add_func("/attachment/equal/false", |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | test_purple_attachment_equal_false); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | return g_test_run(); |
|
627ee13c5dee
Add a Purple.Attachment:inline property and other cleanups
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | } |