Commit 9b86619a 9b86619a749852aaf60b25102bde47680580cb32 by Sergey Poznyakoff

Added UID support.

1 parent ed4dc456
...@@ -71,6 +71,7 @@ struct _maildir_message ...@@ -71,6 +71,7 @@ struct _maildir_message
71 struct _amd_message amd_message; 71 struct _amd_message amd_message;
72 int newflag; 72 int newflag;
73 char *file_name; 73 char *file_name;
74 unsigned long uid;
74 }; 75 };
75 76
76 77
...@@ -311,6 +312,22 @@ maildir_msg_free (struct _amd_message *amsg) ...@@ -311,6 +312,22 @@ maildir_msg_free (struct _amd_message *amsg)
311 free (mp->file_name); 312 free (mp->file_name);
312 } 313 }
313 314
315 static int
316 maildir_message_uid (message_t msg, size_t *puid)
317 {
318 struct _maildir_message *mp = message_get_owner (msg);
319 if (puid)
320 *puid = mp->uid;
321 return 0;
322 }
323
324 static size_t
325 maildir_next_uid (struct _amd_data *amd)
326 {
327 struct _maildir_message *msg = (struct _maildir_message *) amd->msg_tail;
328 return (msg ? msg->uid : 0) + 1;
329 }
330
314 /* According to http://www.qmail.org/qmail-manual-html/man5/maildir.html 331 /* According to http://www.qmail.org/qmail-manual-html/man5/maildir.html
315 a file in tmp may be safely removed if it has not been accessed in 36 332 a file in tmp may be safely removed if it has not been accessed in 36
316 hours */ 333 hours */
...@@ -371,6 +388,7 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm) ...@@ -371,6 +388,7 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm)
371 { 388 {
372 if (stat (name, &st) < 0 && errno == ENOENT) 389 if (stat (name, &st) < 0 && errno == ENOENT)
373 { 390 {
391 msg->uid = amd->next_uid (amd);
374 msg->file_name = name; 392 msg->file_name = name;
375 return 0; 393 return 0;
376 } 394 }
...@@ -520,9 +538,12 @@ maildir_scan_dir (struct _amd_data *amd, DIR *dir) ...@@ -520,9 +538,12 @@ maildir_scan_dir (struct _amd_data *amd, DIR *dir)
520 msg->amd_message.attr_flags = 0; 538 msg->amd_message.attr_flags = 0;
521 msg->amd_message.deleted = msg->amd_message.attr_flags & MU_ATTRIBUTE_DELETED; 539 msg->amd_message.deleted = msg->amd_message.attr_flags & MU_ATTRIBUTE_DELETED;
522 if (insert) 540 if (insert)
541 {
542 msg->uid = amd->next_uid (amd);
523 _amd_message_insert (amd, (struct _amd_message*) msg); 543 _amd_message_insert (amd, (struct _amd_message*) msg);
524 } 544 }
525 } 545 }
546 }
526 return 0; 547 return 0;
527 } 548 }
528 549
...@@ -620,8 +641,8 @@ _mailbox_maildir_init (mailbox_t mailbox) ...@@ -620,8 +641,8 @@ _mailbox_maildir_init (mailbox_t mailbox)
620 amd->msg_file_name = maildir_message_name; 641 amd->msg_file_name = maildir_message_name;
621 amd->scan0 = maildir_scan0; 642 amd->scan0 = maildir_scan0;
622 amd->msg_cmp = maildir_message_cmp; 643 amd->msg_cmp = maildir_message_cmp;
623 amd->message_uid = NULL; /* FIXME */ 644 amd->message_uid = maildir_message_uid;
624 amd->next_uid = NULL; /* FIXME */ 645 amd->next_uid = maildir_next_uid;
625 646
626 /* Set our properties. */ 647 /* Set our properties. */
627 { 648 {
......