Skip to content

Commit 2746947

Browse files
committed
Restore support for old libcamel
1 parent 8cb5bb8 commit 2746947

File tree

6 files changed

+1219
-1
lines changed

6 files changed

+1219
-1
lines changed

meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ gobject_dep = dependency('gobject-2.0')
1515
granite_dep = dependency('granite', version: '>= 6.0.0')
1616
gee_dep = dependency('gee-0.8')
1717
handy_dep = dependency('libhandy-1', version: '>=1.1.90')
18-
camel_dep = dependency('camel-1.2', version: '>= 3.57.1')
18+
camel_dep = dependency('camel-1.2', version: '>= 3.57.1', required: false)
19+
if camel_dep.found()
20+
add_project_arguments('--define=HAS_CAMEL_3_57', language: 'vala')
21+
else
22+
camel_dep = dependency('camel-1.2', version: '>= 3.28')
23+
endif
1924
libedataserver_dep = dependency('libedataserver-1.2', version: '>= 3.28')
2025
libedataserverui_dep = dependency('libedataserverui-1.2', version: '>=3.45.1')
2126
webkit2_dep = dependency('webkit2gtk-4.1')

src/Backend/MoveOperation.vala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,16 @@ public class Mail.MoveOperation : Object {
189189
var vee_folder = (Camel.VeeFolder)src_folder;
190190

191191
store = null;
192+
#if !HAS_CAMEL_3_57
193+
unowned Camel.Folder? orig_folder = null;
194+
#endif
192195

193196
foreach (unowned Camel.MessageInfo message in moved_messages) {
197+
#if HAS_CAMEL_3_57
194198
Camel.Folder? orig_folder = vee_folder.dup_vee_uid_folder (message.uid);
199+
#else
200+
orig_folder = vee_folder.get_vee_uid_folder (message.uid);
201+
#endif
195202
if (orig_folder != null) {
196203
if (store != null && orig_folder.get_parent_store () != store) {
197204
// Don't know which archive folder to use when messages are from
@@ -213,11 +220,20 @@ public class Mail.MoveOperation : Object {
213220
}
214221

215222
private async void collect_thread_messages (Camel.FolderThreadNode thread) {
223+
#if HAS_CAMEL_3_57
216224
moved_messages.add ((Camel.MessageInfo?) thread.get_item ());
217225
unowned Camel.FolderThreadNode? child = (Camel.FolderThreadNode?) thread.get_child ();
226+
#else
227+
moved_messages.add (thread.message);
228+
unowned Camel.FolderThreadNode? child = (Camel.FolderThreadNode?) thread.child;
229+
#endif
218230
while (child != null) {
219231
yield collect_thread_messages (child);
232+
#if HAS_CAMEL_3_57
220233
child = (Camel.FolderThreadNode?) child.get_next ();
234+
#else
235+
child = (Camel.FolderThreadNode?) child.next;
236+
#endif
221237
}
222238
}
223239

src/ConversationList/ConversationItemModel.vala

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public class Mail.ConversationItemModel : GLib.Object {
4646

4747
unowned Camel.FolderThreadNode? current_node = node;
4848
while (current_node != null) {
49+
#if HAS_CAMEL_3_57
4950
weak Camel.MessageInfo? message = (Camel.MessageInfo?) current_node.get_item ();
51+
#else
52+
weak Camel.MessageInfo? message = current_node.message;
53+
#endif
5054
if (message != null) {
5155
var address = new Camel.InternetAddress ();
5256
if (address.decode (message.from) > 0) {
@@ -67,7 +71,11 @@ public class Mail.ConversationItemModel : GLib.Object {
6771
}
6872
}
6973

74+
#if HAS_CAMEL_3_57
7075
current_node = (Camel.FolderThreadNode?) current_node.get_child ();
76+
#else
77+
current_node = (Camel.FolderThreadNode?) current_node.child;
78+
#endif
7179
}
7280

7381
if (senders.length > 0) {
@@ -84,7 +92,11 @@ public class Mail.ConversationItemModel : GLib.Object {
8492

8593
unowned Camel.FolderThreadNode? current_node = node;
8694
while (current_node != null) {
95+
#if HAS_CAMEL_3_57
8796
weak Camel.MessageInfo? message = (Camel.MessageInfo?) current_node.get_item ();
97+
#else
98+
weak Camel.MessageInfo? message = current_node.message;
99+
#endif
88100
if (message != null) {
89101
var address = new Camel.InternetAddress ();
90102
if (address.decode (message.to) > 0) {
@@ -105,7 +117,11 @@ public class Mail.ConversationItemModel : GLib.Object {
105117
}
106118
}
107119

120+
#if HAS_CAMEL_3_57
108121
current_node = (Camel.FolderThreadNode?) current_node.get_child ();
122+
#else
123+
current_node = (Camel.FolderThreadNode?) current_node.child;
124+
#endif
109125
}
110126

111127
if (recipients.length > 0) {
@@ -118,7 +134,11 @@ public class Mail.ConversationItemModel : GLib.Object {
118134

119135
public string subject {
120136
get {
137+
#if HAS_CAMEL_3_57
121138
weak Camel.MessageInfo? message = (Camel.MessageInfo?) node.get_item ();
139+
#else
140+
weak Camel.MessageInfo? message = node.message;
141+
#endif
122142
if (message == null) {
123143
return _("Unknown");
124144
}
@@ -129,7 +149,11 @@ public class Mail.ConversationItemModel : GLib.Object {
129149

130150
public bool flagged {
131151
get {
152+
#if HAS_CAMEL_3_57
132153
weak Camel.MessageInfo? message = (Camel.MessageInfo?) node.get_item ();
154+
#else
155+
weak Camel.MessageInfo? message = node.message;
156+
#endif
133157
if (message == null) {
134158
return false;
135159
}
@@ -140,7 +164,11 @@ public class Mail.ConversationItemModel : GLib.Object {
140164

141165
public bool forwarded {
142166
get {
167+
#if HAS_CAMEL_3_57
143168
weak Camel.MessageInfo? message = (Camel.MessageInfo?) node.get_item ();
169+
#else
170+
weak Camel.MessageInfo? message = node.message;
171+
#endif
144172
if (message == null) {
145173
return false;
146174
}
@@ -151,7 +179,11 @@ public class Mail.ConversationItemModel : GLib.Object {
151179

152180
public bool replied {
153181
get {
182+
#if HAS_CAMEL_3_57
154183
weak Camel.MessageInfo? message = (Camel.MessageInfo?) node.get_item ();
184+
#else
185+
weak Camel.MessageInfo? message = node.message;
186+
#endif
155187
if (message == null) {
156188
return false;
157189
}
@@ -162,7 +194,11 @@ public class Mail.ConversationItemModel : GLib.Object {
162194

163195
public bool replied_all {
164196
get {
197+
#if HAS_CAMEL_3_57
165198
weak Camel.MessageInfo? message = (Camel.MessageInfo?) node.get_item ();
199+
#else
200+
weak Camel.MessageInfo? message = node.message;
201+
#endif
166202
if (message == null) {
167203
return false;
168204
}
@@ -179,7 +215,11 @@ public class Mail.ConversationItemModel : GLib.Object {
179215

180216
public bool deleted {
181217
get {
218+
#if HAS_CAMEL_3_57
182219
weak Camel.MessageInfo? message = (Camel.MessageInfo?) node.get_item ();
220+
#else
221+
weak Camel.MessageInfo? message = node.message;
222+
#endif
183223
if (message == null) {
184224
return false;
185225
}
@@ -204,7 +244,11 @@ public class Mail.ConversationItemModel : GLib.Object {
204244

205245
private static uint count_thread_messages (Camel.FolderThreadNode node) {
206246
uint i = 1;
247+
#if HAS_CAMEL_3_57
207248
for (unowned Camel.FolderThreadNode? child = node.get_child (); child != null; child = child.get_next ()) {
249+
#else
250+
for (unowned Camel.FolderThreadNode? child = node.child; child != null; child = child.next) {
251+
#endif
208252
i += count_thread_messages (child);
209253
}
210254

@@ -217,13 +261,21 @@ public class Mail.ConversationItemModel : GLib.Object {
217261
return time;
218262
}
219263

264+
#if HAS_CAMEL_3_57
220265
weak Camel.MessageInfo? message = (Camel.MessageInfo?) node.get_item ();
266+
#else
267+
weak Camel.MessageInfo? message = node.message;
268+
#endif
221269
if (message != null) {
222270
time = int64.max (time, message.date_received);
223271
time = int64.max (time, message.date_sent);
224272
}
225273

274+
#if HAS_CAMEL_3_57
226275
for (unowned Camel.FolderThreadNode? child = node.get_child (); child != null; child = child.get_next ()) {
276+
#else
277+
for (unowned Camel.FolderThreadNode? child = node.child; child != null; child = child.next) {
278+
#endif
227279
time = get_newest_timestamp (child, time);
228280
}
229281

@@ -235,10 +287,18 @@ public class Mail.ConversationItemModel : GLib.Object {
235287
return false;
236288
}
237289

290+
#if HAS_CAMEL_3_57
238291
var has_flag = !(flag in (int)((Camel.MessageInfo?) node.get_item ()).flags);
292+
#else
293+
var has_flag = !(flag in (int)node.message.flags);
294+
#endif
239295

240296
if (!has_flag) {
297+
#if HAS_CAMEL_3_57
241298
for (unowned Camel.FolderThreadNode? child = node.get_child (); child != null; child = child.get_next ()) {
299+
#else
300+
for (unowned Camel.FolderThreadNode? child = node.child; child != null; child = child.next) {
301+
#endif
242302
has_flag = has_thread_flag (child, flag);
243303
if (has_flag) {
244304
break;

0 commit comments

Comments
 (0)