Diffstat (limited to 'kmicromail/libetpan/generic/imapdriver_tools.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libetpan/generic/imapdriver_tools.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/kmicromail/libetpan/generic/imapdriver_tools.c b/kmicromail/libetpan/generic/imapdriver_tools.c index 3d737f3..de4008f 100644 --- a/kmicromail/libetpan/generic/imapdriver_tools.c +++ b/kmicromail/libetpan/generic/imapdriver_tools.c | |||
@@ -3086,58 +3086,57 @@ static int imap_flags_to_flags(struct mailimap_msg_att_dynamic * att_dyn, | |||
3086 | /* do nothing */ | 3086 | /* do nothing */ |
3087 | break; | 3087 | break; |
3088 | } | 3088 | } |
3089 | } | 3089 | } |
3090 | } | 3090 | } |
3091 | /* | 3091 | /* |
3092 | MAIL_FLAG_NEW was set for \Recent messages. | 3092 | MAIL_FLAG_NEW was set for \Recent messages. |
3093 | Correct this flag for \Seen messages by unsetting it. | 3093 | Correct this flag for \Seen messages by unsetting it. |
3094 | */ | 3094 | */ |
3095 | if ((flags->fl_flags & MAIL_FLAG_SEEN) && (flags->fl_flags & MAIL_FLAG_NEW)) { | 3095 | if ((flags->fl_flags & MAIL_FLAG_SEEN) && (flags->fl_flags & MAIL_FLAG_NEW)) { |
3096 | flags->fl_flags &= ~MAIL_FLAG_NEW; | 3096 | flags->fl_flags &= ~MAIL_FLAG_NEW; |
3097 | } | 3097 | } |
3098 | } | 3098 | } |
3099 | 3099 | ||
3100 | * result = flags; | 3100 | * result = flags; |
3101 | 3101 | ||
3102 | return MAIL_NO_ERROR; | 3102 | return MAIL_NO_ERROR; |
3103 | 3103 | ||
3104 | free: | 3104 | free: |
3105 | mail_flags_free(flags); | 3105 | mail_flags_free(flags); |
3106 | err: | 3106 | err: |
3107 | return MAIL_ERROR_MEMORY; | 3107 | return MAIL_ERROR_MEMORY; |
3108 | } | 3108 | } |
3109 | 3109 | ||
3110 | static int flags_to_imap_flags(struct mail_flags * flags, | 3110 | int imap_flags_to_imap_flags(struct mail_flags * flags, |
3111 | struct mailimap_store_att_flags ** result) | 3111 | struct mailimap_flag_list ** result) |
3112 | { | 3112 | { |
3113 | struct mailimap_flag * flag; | 3113 | struct mailimap_flag * flag; |
3114 | struct mailimap_flag_list * flag_list; | 3114 | struct mailimap_flag_list * flag_list; |
3115 | struct mailimap_store_att_flags * att_flags; | ||
3116 | int res; | 3115 | int res; |
3117 | clistiter * cur; | 3116 | clistiter * cur; |
3118 | int r; | 3117 | int r; |
3119 | 3118 | ||
3120 | flag_list = mailimap_flag_list_new_empty(); | 3119 | flag_list = mailimap_flag_list_new_empty(); |
3121 | if (flag_list == NULL) { | 3120 | if (flag_list == NULL) { |
3122 | res = MAIL_ERROR_MEMORY; | 3121 | res = MAIL_ERROR_MEMORY; |
3123 | goto err; | 3122 | goto err; |
3124 | } | 3123 | } |
3125 | 3124 | ||
3126 | if ((flags->fl_flags & MAIL_FLAG_DELETED) != 0) { | 3125 | if ((flags->fl_flags & MAIL_FLAG_DELETED) != 0) { |
3127 | flag = mailimap_flag_new_deleted(); | 3126 | flag = mailimap_flag_new_deleted(); |
3128 | if (flag == NULL) { | 3127 | if (flag == NULL) { |
3129 | res = MAIL_ERROR_MEMORY; | 3128 | res = MAIL_ERROR_MEMORY; |
3130 | goto free_flag_list; | 3129 | goto free_flag_list; |
3131 | } | 3130 | } |
3132 | r = mailimap_flag_list_add(flag_list, flag); | 3131 | r = mailimap_flag_list_add(flag_list, flag); |
3133 | if (r != MAILIMAP_NO_ERROR) { | 3132 | if (r != MAILIMAP_NO_ERROR) { |
3134 | mailimap_flag_free(flag); | 3133 | mailimap_flag_free(flag); |
3135 | res = MAIL_ERROR_MEMORY; | 3134 | res = MAIL_ERROR_MEMORY; |
3136 | goto free_flag_list; | 3135 | goto free_flag_list; |
3137 | } | 3136 | } |
3138 | } | 3137 | } |
3139 | 3138 | ||
3140 | if ((flags->fl_flags & MAIL_FLAG_FLAGGED) != 0) { | 3139 | if ((flags->fl_flags & MAIL_FLAG_FLAGGED) != 0) { |
3141 | flag = mailimap_flag_new_flagged(); | 3140 | flag = mailimap_flag_new_flagged(); |
3142 | if (flag == NULL) { | 3141 | if (flag == NULL) { |
3143 | res = MAIL_ERROR_MEMORY; | 3142 | res = MAIL_ERROR_MEMORY; |
@@ -3218,59 +3217,84 @@ static int flags_to_imap_flags(struct mail_flags * flags, | |||
3218 | res = MAIL_ERROR_MEMORY; | 3217 | res = MAIL_ERROR_MEMORY; |
3219 | goto free_flag_list; | 3218 | goto free_flag_list; |
3220 | } | 3219 | } |
3221 | } | 3220 | } |
3222 | else { | 3221 | else { |
3223 | flag_str = strdup(flag_str); | 3222 | flag_str = strdup(flag_str); |
3224 | if (flag_str == NULL) { | 3223 | if (flag_str == NULL) { |
3225 | res = MAIL_ERROR_MEMORY; | 3224 | res = MAIL_ERROR_MEMORY; |
3226 | goto free_flag_list; | 3225 | goto free_flag_list; |
3227 | } | 3226 | } |
3228 | flag = mailimap_flag_new_flag_keyword(flag_str); | 3227 | flag = mailimap_flag_new_flag_keyword(flag_str); |
3229 | if (flag == NULL) { | 3228 | if (flag == NULL) { |
3230 | free(flag_str); | 3229 | free(flag_str); |
3231 | res = MAIL_ERROR_MEMORY; | 3230 | res = MAIL_ERROR_MEMORY; |
3232 | goto free_flag_list; | 3231 | goto free_flag_list; |
3233 | } | 3232 | } |
3234 | r = mailimap_flag_list_add(flag_list, flag); | 3233 | r = mailimap_flag_list_add(flag_list, flag); |
3235 | if (r != MAILIMAP_NO_ERROR) { | 3234 | if (r != MAILIMAP_NO_ERROR) { |
3236 | mailimap_flag_free(flag); | 3235 | mailimap_flag_free(flag); |
3237 | res = MAIL_ERROR_MEMORY; | 3236 | res = MAIL_ERROR_MEMORY; |
3238 | goto free_flag_list; | 3237 | goto free_flag_list; |
3239 | } | 3238 | } |
3240 | } | 3239 | } |
3241 | } | 3240 | } |
3241 | |||
3242 | * result = flag_list; | ||
3243 | |||
3244 | return MAIL_NO_ERROR; | ||
3245 | |||
3246 | free_flag_list: | ||
3247 | mailimap_flag_list_free(flag_list); | ||
3248 | err: | ||
3249 | return res; | ||
3250 | } | ||
3242 | 3251 | ||
3252 | static int flags_to_imap_flags(struct mail_flags * flags, | ||
3253 | struct mailimap_store_att_flags ** result) | ||
3254 | { | ||
3255 | struct mailimap_flag_list * flag_list; | ||
3256 | struct mailimap_store_att_flags * att_flags; | ||
3257 | int res; | ||
3258 | int r; | ||
3259 | |||
3260 | r = imap_flags_to_imap_flags(flags, | ||
3261 | &flag_list); | ||
3262 | if (r != MAIL_NO_ERROR) { | ||
3263 | res = r; | ||
3264 | goto err; | ||
3265 | } | ||
3266 | |||
3243 | att_flags = mailimap_store_att_flags_new_set_flags_silent(flag_list); | 3267 | att_flags = mailimap_store_att_flags_new_set_flags_silent(flag_list); |
3244 | if (att_flags == NULL) { | 3268 | if (att_flags == NULL) { |
3245 | res = MAIL_ERROR_MEMORY; | 3269 | res = MAIL_ERROR_MEMORY; |
3246 | goto free_flag_list; | 3270 | goto free_flag_list; |
3247 | } | 3271 | } |
3248 | 3272 | ||
3249 | * result = att_flags; | 3273 | * result = att_flags; |
3250 | 3274 | ||
3251 | return MAIL_NO_ERROR; | 3275 | return MAIL_NO_ERROR; |
3252 | 3276 | ||
3253 | free_flag_list: | 3277 | free_flag_list: |
3254 | mailimap_flag_list_free(flag_list); | 3278 | mailimap_flag_list_free(flag_list); |
3255 | err: | 3279 | err: |
3256 | return res; | 3280 | return res; |
3257 | } | 3281 | } |
3258 | 3282 | ||
3259 | 3283 | ||
3260 | static int | 3284 | static int |
3261 | imap_fetch_result_to_flags(clist * fetch_result, uint32_t index, | 3285 | imap_fetch_result_to_flags(clist * fetch_result, uint32_t index, |
3262 | struct mail_flags ** result) | 3286 | struct mail_flags ** result) |
3263 | { | 3287 | { |
3264 | clistiter * cur; | 3288 | clistiter * cur; |
3265 | int r; | 3289 | int r; |
3266 | 3290 | ||
3267 | for(cur = clist_begin(fetch_result) ; cur != NULL ; | 3291 | for(cur = clist_begin(fetch_result) ; cur != NULL ; |
3268 | cur = clist_next(cur)) { | 3292 | cur = clist_next(cur)) { |
3269 | struct mailimap_msg_att * msg_att; | 3293 | struct mailimap_msg_att * msg_att; |
3270 | clistiter * item_cur; | 3294 | clistiter * item_cur; |
3271 | uint32_t uid; | 3295 | uint32_t uid; |
3272 | struct mailimap_msg_att_dynamic * att_dyn; | 3296 | struct mailimap_msg_att_dynamic * att_dyn; |
3273 | 3297 | ||
3274 | msg_att = clist_content(cur); | 3298 | msg_att = clist_content(cur); |
3275 | 3299 | ||
3276 | uid = 0; | 3300 | uid = 0; |