GCC Code Coverage Report


Directory: src/
File: src/message/msg-mail-folder.c
Date: 2024-07-13 00:54:47
Exec Total Coverage
Lines: 26 26 100.0%
Functions: 11 11 100.0%
Branches: 8 9 88.9%

Line Branch Exec Source
1 /* Copyright 2022-2024 Jan-Michael Brummer <jan-michael.brummer1@volkswagen.de>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include "message/msg-mail-folder.h"
18 #include "msg-error.h"
19 #include "msg-json-utils.h"
20
21 /**
22 * MsgMailFolder:
23 *
24 * Handling of mail folder specific functions.
25 */
26
27 struct _MsgMailFolder {
28 GObject parent_instance;
29
30 char *id;
31 char *parent_folder_id;
32 char *display_name;
33 int child_folder_count;
34 int unread_item_count;
35 int total_item_count;
36 gboolean is_hidden;
37 };
38
39
6/7
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 31 times.
74 G_DEFINE_TYPE (MsgMailFolder, msg_mail_folder, G_TYPE_OBJECT);
40
41 static void
42 16 msg_mail_folder_finalize (GObject *object)
43 {
44 16 MsgMailFolder *self = MSG_MAIL_FOLDER (object);
45
46
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1 times.
16 g_clear_pointer (&self->display_name, g_free);
47
48 16 G_OBJECT_CLASS (msg_mail_folder_parent_class)->finalize (object);
49 16 }
50
51 static void
52 16 msg_mail_folder_init (__attribute__ ((unused)) MsgMailFolder *self)
53 {
54 16 }
55
56 static void
57 2 msg_mail_folder_class_init (MsgMailFolderClass *class)
58 {
59 2 GObjectClass *object_class = G_OBJECT_CLASS (class);
60
61 2 object_class->finalize = msg_mail_folder_finalize;
62 2 }
63
64 /**
65 * msg_mail_folder_new:
66 *
67 * Creates a new `MsgMailFolder`.
68 *
69 * Returns: the newly created `MsgMailFolder`
70 */
71 MsgMailFolder *
72 16 msg_mail_folder_new (void)
73 {
74 16 return g_object_new (MSG_TYPE_MAIL_FOLDER, NULL);
75 }
76
77 /**
78 * msg_mail_folder_new_from_json:
79 * @json_object: The json object to parse
80 * @error: a #GError
81 *
82 * Creates a new `MsgMailFolder` from json response object.
83 *
84 * Returns: the newly created `MsgMailFolder`
85 */
86 MsgMailFolder *
87 15 msg_mail_folder_new_from_json (JsonObject *json_object,
88 __attribute__ ((unused)) GError **error)
89 {
90 MsgMailFolder *self;
91
92 15 self = msg_mail_folder_new ();
93
94 15 self->display_name = g_strdup (msg_json_object_get_string (json_object, "displayName"));
95
96 15 self->unread_item_count = json_object_get_int_member (json_object, "unreadItemCount");
97 15 self->total_item_count = json_object_get_int_member (json_object, "totalItemCount");
98
99 15 return self;
100 }
101
102 /**
103 * msg_mail_folder_get_display_name:
104 * @self: a mail folder
105 *
106 * Returns: (transfer none): display name of mail folder
107 */
108 const char *
109 7 msg_mail_folder_get_display_name (MsgMailFolder *self)
110 {
111 7 return self->display_name;
112 }
113
114 /**
115 * msg_mail_folder_get_unread_item_count:
116 * @self: a mail folder
117 *
118 * Returns: unread item number of mail folder
119 */
120 int
121 7 msg_mail_folder_get_unread_item_count (MsgMailFolder *self)
122 {
123 7 return self->unread_item_count;
124 }
125
126 /**
127 * msg_mail_folder_get_total_item_count:
128 * @self: a mail folder
129 *
130 * Returns: total item number of mail folder
131 */
132 int
133 7 msg_mail_folder_get_total_item_count (MsgMailFolder *self)
134 {
135 7 return self->total_item_count;
136 }
137