6
6
#include "mail-types.h"
7
7
#include "settings.h"
8
8
#include "mailbox.h"
9
- #include "client.h"
9
+ #include "imap- client.h"
10
10
#include "checkpoint.h"
11
11
12
12
#include <stdlib.h>
@@ -32,7 +32,7 @@ struct checkpoint_context {
32
32
};
33
33
34
34
static void
35
- keyword_map_update (struct checkpoint_context * ctx , struct client * client )
35
+ keyword_map_update (struct checkpoint_context * ctx , struct imap_client * client )
36
36
{
37
37
const struct mailbox_keyword * kw_my ;
38
38
const char * const * kw_all , * name ;
@@ -53,7 +53,7 @@ keyword_map_update(struct checkpoint_context *ctx, struct client *client)
53
53
if (!ctx -> first ) {
54
54
i_error ("Checkpoint: client %u: "
55
55
"Missing keyword %s" ,
56
- client -> idx , name );
56
+ client -> client . idx , name );
57
57
}
58
58
array_append (& ctx -> all_keywords , & name , 1 );
59
59
kw_all = array_get (& ctx -> all_keywords , & all_count );
@@ -99,8 +99,9 @@ checkpoint_keywords_to_str(struct checkpoint_context *ctx,
99
99
}
100
100
return str_c (str );
101
101
}
102
+
102
103
static void
103
- checkpoint_update (struct checkpoint_context * ctx , struct client * client )
104
+ checkpoint_update (struct checkpoint_context * ctx , struct imap_client * client )
104
105
{
105
106
struct mailbox_view * view = client -> view ;
106
107
const struct message_metadata_dynamic * msgs ;
@@ -116,22 +117,22 @@ checkpoint_update(struct checkpoint_context *ctx, struct client *client)
116
117
ctx -> errors = TRUE;
117
118
i_error ("Checkpoint: client %u: "
118
119
"Mailbox has only %u of %u messages" ,
119
- client -> global_id , count , ctx -> count );
120
+ client -> client . global_id , count , ctx -> count );
120
121
}
121
122
122
123
if (!view -> storage -> checkpoint -> thread_sent ) {
123
124
/* no THREAD checking */
124
125
} else if (client -> view -> last_thread_reply == NULL ) {
125
126
ctx -> errors = TRUE;
126
127
i_error ("Checkpoint: client %u: Missing THREAD reply" ,
127
- client -> global_id );
128
+ client -> client . global_id );
128
129
} else if (ctx -> thread_reply == NULL )
129
130
ctx -> thread_reply = client -> view -> last_thread_reply ;
130
131
else if (strcmp (client -> view -> last_thread_reply ,
131
132
ctx -> thread_reply ) != 0 ) {
132
133
ctx -> errors = TRUE;
133
134
i_error ("Checkpoint: client %u: THREAD reply differs: %s != %s" ,
134
- client -> global_id , client -> view -> last_thread_reply ,
135
+ client -> client . global_id , client -> view -> last_thread_reply ,
135
136
ctx -> thread_reply );
136
137
}
137
138
@@ -150,7 +151,7 @@ checkpoint_update(struct checkpoint_context *ctx, struct client *client)
150
151
ctx -> errors = TRUE;
151
152
i_error ("Checkpoint: client %u: "
152
153
"Message seq=%u UID %u != %u" ,
153
- client -> global_id , i + 1 ,
154
+ client -> client . global_id , i + 1 ,
154
155
uids [i ], ctx -> uids [i ]);
155
156
break ;
156
157
}
@@ -164,7 +165,7 @@ checkpoint_update(struct checkpoint_context *ctx, struct client *client)
164
165
i_error ("Checkpoint: client %u: "
165
166
"Message seq=%u UID=%u "
166
167
"modseqs differ: %s vs %s" ,
167
- client -> global_id , i + 1 , uids [i ],
168
+ client -> client . global_id , i + 1 , uids [i ],
168
169
dec2str (msgs [i ].modseq ),
169
170
dec2str (ctx -> messages [i ].modseq ));
170
171
}
@@ -195,7 +196,7 @@ checkpoint_update(struct checkpoint_context *ctx, struct client *client)
195
196
i_error ("Checkpoint: client %u: "
196
197
"Message seq=%u UID=%u "
197
198
"has \\Recent flag in multiple sessions" ,
198
- client -> global_id , i + 1 , uids [i ]);
199
+ client -> client . global_id , i + 1 , uids [i ]);
199
200
view -> storage -> dont_track_recent = TRUE;
200
201
}
201
202
}
@@ -206,7 +207,7 @@ checkpoint_update(struct checkpoint_context *ctx, struct client *client)
206
207
ctx -> errors = TRUE;
207
208
i_error ("Checkpoint: client %u: Message seq=%u UID=%u "
208
209
"flags differ: (%s) vs (%s)" ,
209
- client -> global_id , i + 1 , uids [i ],
210
+ client -> client . global_id , i + 1 , uids [i ],
210
211
mail_flags_to_str (this_flags ),
211
212
mail_flags_to_str (other_flags ));
212
213
}
@@ -215,7 +216,7 @@ checkpoint_update(struct checkpoint_context *ctx, struct client *client)
215
216
ctx -> errors = TRUE;
216
217
i_error ("Checkpoint: client %u: Message seq=%u UID=%u "
217
218
"keywords differ: (%s) vs (%s)" ,
218
- client -> global_id , i + 1 , uids [i ],
219
+ client -> client . global_id , i + 1 , uids [i ],
219
220
checkpoint_keywords_to_str (ctx , keywords_remapped ),
220
221
checkpoint_keywords_to_str (ctx , ctx -> messages [i ].keyword_bitmask ));
221
222
}
@@ -253,13 +254,15 @@ static void checkpoint_send_state_cmd(struct mailbox_storage *storage,
253
254
254
255
c = array_get (& clients , & count );
255
256
for (i = 0 ; i < count ; i ++ ) {
256
- if (c [i ] == NULL || c [i ]-> checkpointing != storage )
257
+ struct imap_client * client = imap_client (c [i ]);
258
+
259
+ if (client == NULL || client -> checkpointing != storage )
257
260
continue ;
258
261
259
262
/* send the checkpoint command */
260
- c [ i ] -> plan [0 ] = state ;
261
- c [ i ] -> plan_size = 1 ;
262
- (void )client_plan_send_next_cmd ( c [ i ] );
263
+ client -> plan [0 ] = state ;
264
+ client -> plan_size = 1 ;
265
+ (void )imap_client_plan_send_next_cmd ( client );
263
266
storage -> checkpoint -> clients_left ++ ;
264
267
}
265
268
}
@@ -304,17 +307,18 @@ void checkpoint_neg(struct mailbox_storage *storage)
304
307
/* get maximum number of messages in mailbox */
305
308
recent_total = 0 ;
306
309
for (i = 0 ; i < count ; i ++ ) {
307
- if (c [i ] == NULL || c [i ]-> checkpointing != storage )
310
+ struct imap_client * client = imap_client (c [i ]);
311
+ if (client == NULL || client -> checkpointing != storage )
308
312
continue ;
309
313
310
- i_assert (array_count (& c [ i ] -> commands ) == 0 );
311
- if (c [ i ] -> view -> select_uidnext != 0 ) {
314
+ i_assert (array_count (& client -> commands ) == 0 );
315
+ if (client -> view -> select_uidnext != 0 ) {
312
316
min_uidnext = I_MIN (min_uidnext ,
313
- c [ i ] -> view -> select_uidnext );
317
+ client -> view -> select_uidnext );
314
318
}
315
- recent_total += c [ i ] -> view -> recent_count ;
319
+ recent_total += client -> view -> recent_count ;
316
320
max_msgs_count = I_MAX (max_msgs_count ,
317
- array_count (& c [ i ] -> view -> uidmap ));
321
+ array_count (& client -> view -> uidmap ));
318
322
}
319
323
320
324
/* make sure everyone has the same idea of what the mailbox
@@ -330,11 +334,12 @@ void checkpoint_neg(struct mailbox_storage *storage)
330
334
i_array_init (& ctx .all_keywords , 32 );
331
335
i_array_init (& ctx .cur_keywords_map , 32 );
332
336
for (i = 0 ; i < count ; i ++ ) {
333
- if (c [i ] == NULL || c [i ]-> checkpointing != storage )
337
+ struct imap_client * client = imap_client (c [i ]);
338
+ if (client == NULL || client -> checkpointing != storage )
334
339
continue ;
335
340
336
341
check_count ++ ;
337
- checkpoint_update (& ctx , c [ i ] );
342
+ checkpoint_update (& ctx , client );
338
343
ctx .first = FALSE;
339
344
}
340
345
for (i = 0 ; i < ctx .count ; i ++ )
@@ -372,15 +377,16 @@ void checkpoint_neg(struct mailbox_storage *storage)
372
377
373
378
/* checkpointing is done - continue normal commands */
374
379
for (i = 0 ; i < count ; i ++ ) {
375
- if (c [i ] == NULL )
380
+ struct imap_client * client = imap_client (c [i ]);
381
+ if (client == NULL )
376
382
continue ;
377
- if (c [ i ] -> checkpointing == storage )
378
- c [ i ] -> checkpointing = NULL ;
383
+ if (client -> checkpointing == storage )
384
+ client -> checkpointing = NULL ;
379
385
380
- if (array_count (& c [ i ] -> commands ) == 0 &&
381
- c [ i ] -> state != STATE_BANNER ) {
382
- (void )client_send_more_commands (c [ i ] );
383
- i_assert (array_count (& c [ i ] -> commands ) > 0 );
386
+ if (array_count (& client -> commands ) == 0 &&
387
+ client -> client . state != STATE_BANNER ) {
388
+ (void )client_send_more_commands (& client -> client );
389
+ i_assert (array_count (& client -> commands ) > 0 );
384
390
}
385
391
}
386
392
@@ -402,12 +408,14 @@ void clients_checkpoint(struct mailbox_storage *storage)
402
408
403
409
c = array_get (& clients , & count );
404
410
for (i = 0 ; i < count ; i ++ ) {
405
- if (c [i ] == NULL || c [i ]-> login_state != LSTATE_SELECTED )
411
+ struct imap_client * client = imap_client (c [i ]);
412
+ if (client == NULL ||
413
+ client -> client .login_state != LSTATE_SELECTED )
406
414
continue ;
407
415
408
- if (c [ i ] -> storage == storage ) {
409
- c [ i ] -> checkpointing = storage ;
410
- if (array_count (& c [ i ] -> commands ) > 0 )
416
+ if (client -> storage == storage ) {
417
+ client -> checkpointing = storage ;
418
+ if (array_count (& client -> commands ) > 0 )
411
419
storage -> checkpoint -> clients_left ++ ;
412
420
}
413
421
}
0 commit comments