From 0a4f27eec0a2e5035d6bb853a62dd7631ea8cb2a Mon Sep 17 00:00:00 2001 From: teranisi Date: Sun, 21 Sep 2003 10:49:37 +0000 Subject: [PATCH] * wl-summary.el (wl-summary-detect-mark-position): Follow the API change in elmo-msgdb-make-message-entity. (wl-summary-buffer-set-folder): Don't call wl-summary-detect-mark-position here. (wl-summary-rescan): Call elmo-message-entity-number. (wl-summary-sync-update): Ditto. (wl-summary-goto-folder-subr): Call wl-summary-detect-mark-position. * wl-score.el (wl-score-header-index): Redefine 2th element. (wl-score-overview-entity-get-extra): Abolish. (wl-score-ov-entity-get): Rewrite. (wl-score-string-index<, wl-score-string-func<): Abolish. (wl-score-string<): New function. (wl-score-string-sort): Use it. * wl-refile.el (wl-refile-guess-by-history): Use elmo-message-entity-field. (wl-refile-guess-by-from): Ditto. (wl-refile-guess-by-msgid): Ditto. * modb.el (elmo-message-entity-db): New function. (elmo-msgdb-make-message-entity): New API. (elmo-msgdb-message-entity-number): Ditto. (elmo-msgdb-message-entity-set-number): Ditto. (elmo-msgdb-message-entity-field): Ditto. (elmo-msgdb-message-entity-set-field): Ditto. (elmo-msgdb-copy-message-entity): Ditto. (elmo-msgdb-create-message-entity-from-file): Ditto. (elmo-msgdb-create-message-entity-from-buffer): Ditto. (elmo-msgdb-match-condition-internal): Ditto. * modb-standard.el (modb-legacy): Require modb-legacy. (modb-standard-make-message-entity): New inline function. (elmo-msgdb-make-message-entity): Define. (elmo-msgdb-create-message-entity-from-file): Ditto. (elmo-msgdb-create-message-entity-from-buffer): Ditto. (elmo-msgdb-message-entity-field): Ditto. (elmo-msgdb-message-entity-set-field): Ditto. (elmo-msgdb-copy-message-entity): Ditto. (elmo-msgdb-match-condition-internal): Ditto. * modb-legacy.el: Don't require modb-entity. (elmo-msgdb-decoded-cache-hashtb): Moved from elmo-msgdb.el (elmo-msgdb-match-condition-primitive): Ditto. (elmo-msgdb-get-decoded-cache): Ditto. (elmo-msgdb-overview-entity-get-id): Ditto. (elmo-msgdb-overview-entity-get-number): Ditto. (elmo-msgdb-overview-entity-set-number): Ditto. (elmo-msgdb-overview-entity-get-references): Ditto. (elmo-msgdb-overview-entity-set-references): Ditto. (elmo-msgdb-overview-entity-get-from-no-decode): Ditto. (elmo-msgdb-overview-entity-get-from): Ditto. (elmo-msgdb-overview-entity-set-from): Ditto. (elmo-msgdb-overview-entity-get-subject): Ditto. (elmo-msgdb-overview-entity-get-subject-no-decode): Ditto. (elmo-msgdb-overview-entity-set-subject): Ditto. (elmo-msgdb-overview-entity-get-date): Ditto. (elmo-msgdb-overview-entity-set-date): Ditto. (elmo-msgdb-overview-entity-get-to): Ditto. (elmo-msgdb-overview-entity-get-cc): Ditto. (elmo-msgdb-overview-entity-get-size): Ditto. (elmo-msgdb-overview-entity-set-size): Ditto. (elmo-msgdb-overview-entity-get-extra): Ditto. (elmo-msgdb-overview-entity-set-extra): Ditto. (elmo-msgdb-overview-entity-get-extra-field): Ditto. (elmo-msgdb-overview-entity-set-extra-field): Ditto. (elmo-msgdb-number-load): Ditto. (elmo-msgdb-overview-load): Ditto. (elmo-msgdb-mark-load): Ditto. (elmo-msgdb-number-save): Ditto. (elmo-msgdb-mark-save): Ditto. (elmo-msgdb-overview-save): Ditto. (modb-legacy-make-message-entity): New inline function. (elmo-msgdb-insert-file-header): Ditto. (elmo-msgdb-make-message-entity): Define. (elmo-msgdb-create-message-entity-from-file): Ditto. (elmo-msgdb-create-message-entity-from-buffer): Ditto. (elmo-msgdb-message-entity-number): Ditto. (elmo-msgdb-message-entity-set-number): Ditto. (elmo-msgdb-message-entity-field): Ditto. (elmo-msgdb-message-entity-set-field): Ditto. (elmo-msgdb-copy-message-entity): Ditto. (elmo-msgdb-match-condition-internal): Ditto. * elmo.el (elmo-find-fetch-strategy): Use elmo-message-entity-field. (elmo-message-copy-entity): Rewrite. (elmo-message-entity-number): Ditto. (elmo-message-entity-set-number): Ditto. (elmo-message-entity-field): Use elmo-message-entity-db. (elmo-message-entity-set-field): Ditto. (elmo-message-field): Rewrite. * elmo-util.el (elmo-msgdb-get-last-message-id): Moved from elmo-msgdb.el (elmo-msgdb-get-message-id-from-buffer): Ditto. * elmo-shimbun.el (elmo-shimbun-folder-entity-hash): Use elmo-message-entity-field. (elmo-shimbun-folder-shimbun-header): Ditto. (elmo-shimbun-entity-to-header): Ditto. (elmo-folder-msgdb-create): Ditto. (elmo-shimbun-msgdb-create-entity): Ditto; Use elmo-msgdb-create-message-entity-from-buffer. (elmo-shimbun-update-overview): Use elmo-message-entity-set-field. (elmo-map-folder-list-message-locations): elmo-message-entity-field. * elmo-sendlog.el (elmo-folder-msgdb-create): Use elmo-msgdb-create-message-entity-from-file and elmo-message-entity-field. * elmo-pop3.el (elmo-pop3-sort-msgdb-by-original-number): Use elmo-message-entity-number. (elmo-pop3-msgdb-create-message): Use elmo-msgdb-create-message-entity-from-buffer, elmo-message-entity-set-field, elmo-message-entity-number and elmo-message-entity-set-number. * elmo-nntp.el (elmo-nntp-create-msgdb-from-overview-string): Follow the API change in elmo-msgdb-make-message-entity. (elmo-nntp-msgdb-create-message): Use elmo-msgdb-create-message-entity-from-buffer. * elmo-nmz.el (elmo-nmz-msgdb-create-entity): Use elmo-message-entity-field and elmo-msgdb-create-message-entity-from-file. * elmo-msgdb.el (toplevel): Don't require modb-entity. (elmo-msgdb-get-field): Abolish. (elmo-msgdb-get-number): Rewrite. (elmo-msgdb-sort-by-date): Use elmo-message-entity-field. (elmo-msgdb-flag-table): Ditto. (elmo-msgdb-get-last-message-id, elmo-msgdb-number-load, elmo-msgdb-overview-load, elmo-msgdb-mark-load, elmo-msgdb-number-save, elmo-msgdb-mark-save, elmo-msgdb-overview-save): Moved to modb-legacy. (elmo-msgdb-create-overview-from-buffer, elmo-msgdb-overview-get-parent-entity): Abolish. * elmo-mime.el (elmo-mime-display-as-is): Use elmo-message-entity-field. * elmo-map.el (elmo-folder-pack-numbers): Use elmo-message-entity-set-number. * elmo-maildir.el (elmo-folder-msgdb-create): elmo-msgdb-create-message-entity-from-file instead of elmo-msgdb-create-overview-entity-from-file. * elmo-localdir.el (elmo-localdir-msgdb-create-entity): Added argument msgdb. (elmo-folder-msgdb-create): Use elmo-message-entity-field. (elmo-folder-pack-numbers): Use elmo-message-entity-set-number. * elmo-imap4.el (elmo-imap4-fetch-callback-1-subr): Use elmo-messge-entity-field and elmo-message-entity-number. (elmo-imap4-fetch-callback-1): Call elmo-msgdb-create-message-entity-from-buffer instead of elmo-msgdb-create-overview-from-buffer. (elmo-folder-msgdb-create-plugged): Use elmo-messge-entity-field. (elmo-find-fetch-strategy): Likewise. * elmo-flag.el (elmo-folder-msgdb-create): Call elmo-localdir-msgdb-create-entity with argument msgdb. * elmo-dop.el (elmo-dop-msgdb): Use elmo-message-entity-number and elmo-message-entity-set-number. * elmo-cache.el (elmo-folder-msgdb-create): Use elmo-message-entity-field. (elmo-folder-msgdb-create): Call elmo-msgdb-create-message-entity-from-file instead of elmo-msgdb-create-overview-entity-from-file. * elmo-archive.el (elmo-archive-msgdb-create-entity-subr): Added argument msgdb; Call elmo-msgdb-create-message-from-buffer instead of elmo-msgdb-create-overview-from-buffer. (elmo-archive-msgdb-create-entity): Ditto. (elmo-archive-msgdb-create-as-numlist-subr1): Use elmo-message-entity-field. (elmo-archive-parse-mmdf): Ditto. * WL-ELS (ELMO-MODULES): Removed modb-entity. --- ChangeLog | 4 + WL-ELS | 2 +- elmo/ChangeLog | 163 +++++++++++++++++++ elmo/elmo-archive.el | 18 ++- elmo/elmo-cache.el | 5 +- elmo/elmo-dop.el | 6 +- elmo/elmo-flag.el | 2 +- elmo/elmo-imap4.el | 17 +- elmo/elmo-localdir.el | 12 +- elmo/elmo-maildir.el | 3 +- elmo/elmo-map.el | 2 +- elmo/elmo-mime.el | 2 +- elmo/elmo-msgdb.el | 177 ++------------------ elmo/elmo-nmz.el | 25 +-- elmo/elmo-nntp.el | 4 +- elmo/elmo-pop3.el | 17 +- elmo/elmo-sendlog.el | 7 +- elmo/elmo-shimbun.el | 78 ++++----- elmo/elmo-util.el | 25 +++ elmo/elmo.el | 33 ++-- elmo/modb-legacy.el | 426 ++++++++++++++++++++++++++++++++++++++++++++++++- elmo/modb-standard.el | 180 ++++++++++++++++++++- elmo/modb.el | 72 ++++++++- wl/ChangeLog | 20 +++ wl/wl-refile.el | 8 +- wl/wl-score.el | 66 +++----- wl/wl-summary.el | 13 +- wl/wl-thread.el | 4 +- 28 files changed, 1060 insertions(+), 331 deletions(-) diff --git a/ChangeLog b/ChangeLog index 607a504..8854643 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-09-21 Yuuichi Teranishi + + * WL-ELS (ELMO-MODULES): Removed modb-entity. + 2003-09-19 Hiroya Murata * WL-ELS (ELMO-MODULES): Added modb-standard. diff --git a/WL-ELS b/WL-ELS index 9b11151..ffd3715 100644 --- a/WL-ELS +++ b/WL-ELS @@ -22,7 +22,7 @@ elmo-archive elmo-pipe elmo-cache elmo-internal elmo-flag elmo-sendlog elmo-dop elmo-nmz elmo-split - modb modb-entity modb-legacy modb-standard + modb modb-legacy modb-standard )) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 58eff68..1fa706f 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,5 +1,168 @@ 2003-09-21 Yuuichi Teranishi + * modb.el (elmo-message-entity-db): New function. + (elmo-msgdb-make-message-entity): New API. + (elmo-msgdb-message-entity-number): Ditto. + (elmo-msgdb-message-entity-set-number): Ditto. + (elmo-msgdb-message-entity-field): Ditto. + (elmo-msgdb-message-entity-set-field): Ditto. + (elmo-msgdb-copy-message-entity): Ditto. + (elmo-msgdb-create-message-entity-from-file): Ditto. + (elmo-msgdb-create-message-entity-from-buffer): Ditto. + (elmo-msgdb-match-condition-internal): Ditto. + + * modb-standard.el (modb-legacy): Require modb-legacy. + (modb-standard-make-message-entity): New inline function. + (elmo-msgdb-make-message-entity): Define. + (elmo-msgdb-create-message-entity-from-file): Ditto. + (elmo-msgdb-create-message-entity-from-buffer): Ditto. + (elmo-msgdb-message-entity-field): Ditto. + (elmo-msgdb-message-entity-set-field): Ditto. + (elmo-msgdb-copy-message-entity): Ditto. + (elmo-msgdb-match-condition-internal): Ditto. + + * modb-legacy.el: Don't require modb-entity. + (elmo-msgdb-decoded-cache-hashtb): Moved from elmo-msgdb.el + (elmo-msgdb-match-condition-primitive): Ditto. + (elmo-msgdb-get-decoded-cache): Ditto. + (elmo-msgdb-overview-entity-get-id): Ditto. + (elmo-msgdb-overview-entity-get-number): Ditto. + (elmo-msgdb-overview-entity-set-number): Ditto. + (elmo-msgdb-overview-entity-get-references): Ditto. + (elmo-msgdb-overview-entity-set-references): Ditto. + (elmo-msgdb-overview-entity-get-from-no-decode): Ditto. + (elmo-msgdb-overview-entity-get-from): Ditto. + (elmo-msgdb-overview-entity-set-from): Ditto. + (elmo-msgdb-overview-entity-get-subject): Ditto. + (elmo-msgdb-overview-entity-get-subject-no-decode): Ditto. + (elmo-msgdb-overview-entity-set-subject): Ditto. + (elmo-msgdb-overview-entity-get-date): Ditto. + (elmo-msgdb-overview-entity-set-date): Ditto. + (elmo-msgdb-overview-entity-get-to): Ditto. + (elmo-msgdb-overview-entity-get-cc): Ditto. + (elmo-msgdb-overview-entity-get-size): Ditto. + (elmo-msgdb-overview-entity-set-size): Ditto. + (elmo-msgdb-overview-entity-get-extra): Ditto. + (elmo-msgdb-overview-entity-set-extra): Ditto. + (elmo-msgdb-overview-entity-get-extra-field): Ditto. + (elmo-msgdb-overview-entity-set-extra-field): Ditto. + (elmo-msgdb-number-load): Ditto. + (elmo-msgdb-overview-load): Ditto. + (elmo-msgdb-mark-load): Ditto. + (elmo-msgdb-number-save): Ditto. + (elmo-msgdb-mark-save): Ditto. + (elmo-msgdb-overview-save): Ditto. + (modb-legacy-make-message-entity): New inline function. + (elmo-msgdb-insert-file-header): Ditto. + (elmo-msgdb-make-message-entity): Define. + (elmo-msgdb-create-message-entity-from-file): Ditto. + (elmo-msgdb-create-message-entity-from-buffer): Ditto. + (elmo-msgdb-message-entity-number): Ditto. + (elmo-msgdb-message-entity-set-number): Ditto. + (elmo-msgdb-message-entity-field): Ditto. + (elmo-msgdb-message-entity-set-field): Ditto. + (elmo-msgdb-copy-message-entity): Ditto. + (elmo-msgdb-match-condition-internal): Ditto. + + * elmo.el (elmo-find-fetch-strategy): Use elmo-message-entity-field. + (elmo-message-copy-entity): Rewrite. + (elmo-message-entity-number): Ditto. + (elmo-message-entity-set-number): Ditto. + (elmo-message-entity-field): Use elmo-message-entity-db. + (elmo-message-entity-set-field): Ditto. + (elmo-message-field): Rewrite. + + * elmo-util.el (elmo-msgdb-get-last-message-id): Moved from + elmo-msgdb.el + (elmo-msgdb-get-message-id-from-buffer): Ditto. + + * elmo-shimbun.el (elmo-shimbun-folder-entity-hash): Use + elmo-message-entity-field. + (elmo-shimbun-folder-shimbun-header): Ditto. + (elmo-shimbun-entity-to-header): Ditto. + (elmo-folder-msgdb-create): Ditto. + (elmo-shimbun-msgdb-create-entity): Ditto; + Use elmo-msgdb-create-message-entity-from-buffer. + (elmo-shimbun-update-overview): Use elmo-message-entity-set-field. + (elmo-map-folder-list-message-locations): elmo-message-entity-field. + + * elmo-sendlog.el (elmo-folder-msgdb-create): Use + elmo-msgdb-create-message-entity-from-file and + elmo-message-entity-field. + + * elmo-pop3.el (elmo-pop3-sort-msgdb-by-original-number): Use + elmo-message-entity-number. + (elmo-pop3-msgdb-create-message): Use + elmo-msgdb-create-message-entity-from-buffer, + elmo-message-entity-set-field, elmo-message-entity-number and + elmo-message-entity-set-number. + + * elmo-nntp.el (elmo-nntp-create-msgdb-from-overview-string): Follow + the API change in elmo-msgdb-make-message-entity. + (elmo-nntp-msgdb-create-message): Use + elmo-msgdb-create-message-entity-from-buffer. + + * elmo-nmz.el (elmo-nmz-msgdb-create-entity): Use + elmo-message-entity-field and + elmo-msgdb-create-message-entity-from-file. + + * elmo-msgdb.el (toplevel): Don't require modb-entity. + (elmo-msgdb-get-field): Abolish. + (elmo-msgdb-get-number): Rewrite. + (elmo-msgdb-sort-by-date): Use elmo-message-entity-field. + (elmo-msgdb-flag-table): Ditto. + (elmo-msgdb-get-last-message-id, + elmo-msgdb-number-load, elmo-msgdb-overview-load, + elmo-msgdb-mark-load, elmo-msgdb-number-save, + elmo-msgdb-mark-save, elmo-msgdb-overview-save): Moved to modb-legacy. + (elmo-msgdb-create-overview-from-buffer, + elmo-msgdb-overview-get-parent-entity): Abolish. + + * elmo-mime.el (elmo-mime-display-as-is): Use + elmo-message-entity-field. + + * elmo-map.el (elmo-folder-pack-numbers): Use + elmo-message-entity-set-number. + + * elmo-maildir.el (elmo-folder-msgdb-create): + elmo-msgdb-create-message-entity-from-file instead of + elmo-msgdb-create-overview-entity-from-file. + + * elmo-localdir.el (elmo-localdir-msgdb-create-entity): Added argument + msgdb. + (elmo-folder-msgdb-create): Use elmo-message-entity-field. + (elmo-folder-pack-numbers): Use elmo-message-entity-set-number. + + * elmo-imap4.el (elmo-imap4-fetch-callback-1-subr): Use + elmo-messge-entity-field and elmo-message-entity-number. + (elmo-imap4-fetch-callback-1): Call + elmo-msgdb-create-message-entity-from-buffer instead of + elmo-msgdb-create-overview-from-buffer. + (elmo-folder-msgdb-create-plugged): Use elmo-messge-entity-field. + (elmo-find-fetch-strategy): Likewise. + + * elmo-flag.el (elmo-folder-msgdb-create): Call + elmo-localdir-msgdb-create-entity with argument msgdb. + + * elmo-dop.el (elmo-dop-msgdb): Use elmo-message-entity-number + and elmo-message-entity-set-number. + + * elmo-cache.el (elmo-folder-msgdb-create): Use + elmo-message-entity-field. + (elmo-folder-msgdb-create): Call + elmo-msgdb-create-message-entity-from-file instead of + elmo-msgdb-create-overview-entity-from-file. + + * elmo-archive.el (elmo-archive-msgdb-create-entity-subr): Added + argument msgdb; Call elmo-msgdb-create-message-from-buffer + instead of elmo-msgdb-create-overview-from-buffer. + (elmo-archive-msgdb-create-entity): Ditto. + (elmo-archive-msgdb-create-as-numlist-subr1): Use + elmo-message-entity-field. + (elmo-archive-parse-mmdf): Ditto. + + * modb-entity.el: Removed. + * elmo-version.el (elmo-version): Up to 2.11.16. 2003-09-20 Yuuichi Teranishi diff --git a/elmo/elmo-archive.el b/elmo/elmo-archive.el index e610f4d..da6ebc1 100644 --- a/elmo/elmo-archive.el +++ b/elmo/elmo-archive.el @@ -893,7 +893,7 @@ TYPE specifies the archiver's symbol." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; MessageDB functions (from elmo-localdir.el) -(defsubst elmo-archive-msgdb-create-entity-subr (number) +(defsubst elmo-archive-msgdb-create-entity-subr (msgdb number) (let (header-end) (elmo-set-buffer-multibyte default-enable-multibyte-characters) (goto-char (point-min)) @@ -901,17 +901,20 @@ TYPE specifies the archiver's symbol." (setq header-end (point)) (setq header-end (point-max))) (narrow-to-region (point-min) header-end) - (elmo-msgdb-create-overview-from-buffer number))) + (elmo-msgdb-create-message-entity-from-buffer msgdb number))) ;; verrrry slow!! -(defsubst elmo-archive-msgdb-create-entity (method archive number type &optional prefix) +(defsubst elmo-archive-msgdb-create-entity (msgdb + method + archive number type + &optional prefix) (let* ((msg (elmo-concat-path prefix (int-to-string number))) (arg-list (list archive msg))) (when (elmo-archive-article-exists-p archive msg type) ;; insert article. (as-binary-process (elmo-archive-call-method method arg-list t)) - (elmo-archive-msgdb-create-entity-subr number)))) + (elmo-archive-msgdb-create-entity-subr msgdb number)))) (luna-define-method elmo-folder-msgdb-create ((folder elmo-archive-folder) numbers flag-table) @@ -940,10 +943,11 @@ TYPE specifies the archiver's symbol." (erase-buffer) (setq entity (elmo-archive-msgdb-create-entity + new-msgdb method file (car numlist) type (elmo-archive-folder-archive-prefix-internal folder))) (when entity - (setq message-id (elmo-msgdb-overview-entity-get-id entity) + (setq message-id (elmo-message-entity-field entity 'message-id) flags (elmo-flag-table-get flag-table message-id)) (elmo-global-flags-set flags folder (car numlist) message-id) (elmo-msgdb-append-entity new-msgdb entity flags)) @@ -1027,8 +1031,8 @@ TYPE specifies the archiver's symbol." () ; nop (save-excursion (narrow-to-region sp ep) - (setq entity (elmo-archive-msgdb-create-entity-subr number) - message-id (elmo-msgdb-overview-entity-get-id entity) + (setq entity (elmo-archive-msgdb-create-entity-subr new-msgdb number) + message-id (elmo-message-entity-field entity 'message-id) flags (elmo-flag-table-get flag-table message-id)) (elmo-global-flags-set flags folder number message-id) (elmo-msgdb-append-entity new-msgdb entity flags) diff --git a/elmo/elmo-cache.el b/elmo/elmo-cache.el index 850382e..eb47003 100644 --- a/elmo/elmo-cache.el +++ b/elmo/elmo-cache.el @@ -95,10 +95,11 @@ (message "Creating msgdb...") (while numbers (setq entity - (elmo-msgdb-create-overview-entity-from-file + (elmo-msgdb-create-message-entity-from-file + new-msgdb (car numbers) (elmo-message-file-name folder (car numbers)))) (when entity - (setq message-id (elmo-msgdb-overview-entity-get-id entity) + (setq message-id (elmo-message-entity-field entity 'message-id) flags (elmo-flag-table-get flag-table message-id)) (elmo-global-flags-set flags folder (car numbers) message-id) (elmo-msgdb-append-entity new-msgdb entity flags)) diff --git a/elmo/elmo-dop.el b/elmo/elmo-dop.el index 0286fc0..24ae26a 100644 --- a/elmo/elmo-dop.el +++ b/elmo/elmo-dop.el @@ -348,14 +348,14 @@ FOLDER is the folder structure." (unless (elmo-folder-exists-p folder) (elmo-folder-create folder))) -;;; Util +;;; Util XXX Oh my god... (defun elmo-dop-msgdb (msgdb) (list (mapcar (function (lambda (x) - (elmo-msgdb-overview-entity-set-number + (elmo-message-entity-set-number x (* -1 - (elmo-msgdb-overview-entity-get-number x))))) + (elmo-message-entity-number x))))) (nth 0 msgdb)) (mapcar (function (lambda (x) (cons diff --git a/elmo/elmo-flag.el b/elmo/elmo-flag.el index a093091..662ba04 100644 --- a/elmo/elmo-flag.el +++ b/elmo/elmo-flag.el @@ -147,7 +147,7 @@ (message "Creating msgdb...") (while numbers (when (setq entity (elmo-localdir-msgdb-create-entity - dir (car numbers))) + new-msgdb dir (car numbers))) (elmo-msgdb-append-entity new-msgdb entity (list (elmo-flag-folder-flag-internal folder)))) diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index 207f1f2..097edad 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -778,7 +778,7 @@ If CHOP-LENGTH is not specified, message set is not chopped." "A msgdb entity callback function." (let ((use-flag (elmo-folder-use-flag-p (cdr app-data))) (flag-table (car app-data)) - (msg-id (elmo-msgdb-overview-entity-get-id entity)) + (msg-id (elmo-message-entity-field entity 'message-id)) saved-flags flag-list) ;; (when (elmo-string-member-ignore-case "\\Flagged" flags) ;; (elmo-msgdb-global-mark-set msg-id elmo-msgdb-important-mark)) @@ -801,7 +801,7 @@ If CHOP-LENGTH is not specified, message set is not chopped." (memq 'answered flag-list)) (memq 'unread flag-list)) (setq elmo-imap4-seen-messages - (cons (elmo-msgdb-overview-entity-get-number entity) + (cons (elmo-message-entity-number entity) elmo-imap4-seen-messages))) (elmo-msgdb-append-entity elmo-imap4-current-msgdb entity @@ -817,9 +817,10 @@ If CHOP-LENGTH is not specified, message set is not chopped." (goto-char (point-min)) (while (search-forward "\r\n" nil t) (replace-match "\n")) - (elmo-msgdb-create-overview-from-buffer + (elmo-msgdb-create-message-entity-from-buffer + (elmo-folder-msgdb-internal (cdr app-data)) (elmo-imap4-response-value element 'uid) - (elmo-imap4-response-value element 'rfc822size))) + :size (elmo-imap4-response-value element 'rfc822size))) (elmo-imap4-response-value element 'flags) app-data)) @@ -2304,7 +2305,7 @@ If optional argument REMOVE is non-nil, remove FLAG." (elmo-global-flags-set (elmo-msgdb-flags elmo-imap4-current-msgdb number) folder number - (elmo-msgdb-message-entity-field + (elmo-message-entity-field (elmo-msgdb-message-entity elmo-imap4-current-msgdb number) 'message-id))) @@ -2460,10 +2461,10 @@ If optional argument REMOVE is non-nil, remove FLAG." (luna-define-method elmo-find-fetch-strategy ((folder elmo-imap4-folder) entity &optional ignore-cache) - (let ((number (elmo-msgdb-overview-entity-get-number entity)) + (let ((number (elmo-message-entity-number entity)) cache-file size message-id) - (setq size (elmo-msgdb-overview-entity-get-size entity)) - (setq message-id (elmo-msgdb-overview-entity-get-id entity)) + (setq size (elmo-message-entity-field entity 'size)) + (setq message-id (elmo-message-entity-field entity 'message-id)) (setq cache-file (elmo-file-cache-get message-id)) (if (or ignore-cache (null (elmo-file-cache-status cache-file))) diff --git a/elmo/elmo-localdir.el b/elmo/elmo-localdir.el index 06d0d06..01993db 100644 --- a/elmo/elmo-localdir.el +++ b/elmo/elmo-localdir.el @@ -138,9 +138,9 @@ (incf cur-number)) temp-dir)) -(defun elmo-localdir-msgdb-create-entity (dir number) - (elmo-msgdb-create-overview-entity-from-file - number (expand-file-name (int-to-string number) dir))) +(defun elmo-localdir-msgdb-create-entity (msgdb dir number) + (elmo-msgdb-create-message-entity-from-file + msgdb number (expand-file-name (int-to-string number) dir))) (luna-define-method elmo-folder-msgdb-create ((folder elmo-localdir-folder) numbers @@ -156,9 +156,9 @@ (while numbers (setq entity (elmo-localdir-msgdb-create-entity - dir (car numbers))) + new-msgdb dir (car numbers))) (when entity - (setq message-id (elmo-msgdb-overview-entity-get-id entity) + (setq message-id (elmo-message-entity-field entity 'message-id) flags (elmo-flag-table-get flag-table message-id)) (elmo-global-flags-set flags folder (car numbers) message-id) (elmo-msgdb-append-entity new-msgdb entity flags)) @@ -345,7 +345,7 @@ ;; xxx nfs,hardlink (rename-file (int-to-string old-number) (int-to-string new-number) t)) - (elmo-msgdb-overview-entity-set-number entity new-number)) + (elmo-message-entity-set-number entity new-number)) (elmo-msgdb-append-entity new-msgdb entity (elmo-msgdb-flags msgdb old-number)) (setq new-number (1+ new-number)))) diff --git a/elmo/elmo-maildir.el b/elmo/elmo-maildir.el index 017ad3f..e366844 100644 --- a/elmo/elmo-maildir.el +++ b/elmo/elmo-maildir.el @@ -152,7 +152,8 @@ LOCATION." (dolist (number numbers) (setq location (elmo-map-message-location folder number)) (setq entity - (elmo-msgdb-create-overview-entity-from-file + (elmo-msgdb-create-message-entity-from-file + new-msgdb number (elmo-maildir-message-file-name folder location))) (when entity diff --git a/elmo/elmo-map.el b/elmo/elmo-map.el index ba00918..9322ca5 100644 --- a/elmo/elmo-map.el +++ b/elmo/elmo-map.el @@ -147,7 +147,7 @@ (elmo-folder-pack-numbers total "Packing...") (dolist (old-number numbers) (setq entity (elmo-msgdb-message-entity msgdb old-number)) - (elmo-msgdb-overview-entity-set-number entity number) + (elmo-message-entity-set-number entity number) (elmo-msgdb-append-entity new-msgdb entity (elmo-msgdb-flags msgdb old-number)) (setq location diff --git a/elmo/elmo-mime.el b/elmo/elmo-mime.el index f0a1b52..baa2eb0 100644 --- a/elmo/elmo-mime.el +++ b/elmo/elmo-mime.el @@ -259,7 +259,7 @@ Return non-nil if cache is used." cache-file strategy use-cache) (when entity (setq cache-file (elmo-file-cache-get - (elmo-msgdb-overview-entity-get-id entity))) + (elmo-message-entity-field entity 'message-id))) (setq use-cache (and (elmo-message-use-cache-p folder number) (eq (elmo-file-cache-status cache-file) 'entire)))) (setq strategy (elmo-make-fetch-strategy diff --git a/elmo/elmo-msgdb.el b/elmo/elmo-msgdb.el index d33506b..b68414e 100644 --- a/elmo/elmo-msgdb.el +++ b/elmo/elmo-msgdb.el @@ -38,14 +38,12 @@ (require 'std11) (require 'mime) (require 'modb) -(require 'modb-entity) ;;; MSGDB interface. ;; ;; MSGDB elmo-load-msgdb PATH ;; NUMBER elmo-msgdb-get-number MSGDB MESSAGE-ID -;; FIELD-VALUE elmo-msgdb-get-field MSGDB NUMBER FIELD ;; elmo-msgdb-sort-by-date MSGDB ;; elmo-flag-table-load @@ -116,30 +114,8 @@ (defsubst elmo-msgdb-get-number (msgdb message-id) "Get number of the message which corrensponds to MESSAGE-ID from MSGDB." - (elmo-msgdb-overview-entity-get-number - (elmo-msgdb-message-entity msgdb message-id))) - -(defsubst elmo-msgdb-get-field (msgdb number field) - "Get FIELD value of the message with NUMBER from MSGDB." - (case field - (message-id (elmo-msgdb-overview-entity-get-id - (elmo-msgdb-message-entity - msgdb number))) - (subject (elmo-msgdb-overview-entity-get-subject - (elmo-msgdb-message-entity - msgdb number))) - (size (elmo-msgdb-overview-entity-get-size - (elmo-msgdb-message-entity - msgdb number))) - (date (elmo-msgdb-overview-entity-get-date - (elmo-msgdb-message-entity - msgdb number))) - (to (elmo-msgdb-overview-entity-get-to - (elmo-msgdb-message-entity - msgdb number))) - (cc (elmo-msgdb-overview-entity-get-cc - (elmo-msgdb-message-entity - msgdb number))))) + (elmo-msgdb-message-entity-number + msgdb (elmo-msgdb-message-entity msgdb message-id))) (defun elmo-msgdb-sort-by-date (msgdb) (elmo-msgdb-sort-entities @@ -148,11 +124,17 @@ (condition-case nil (string< (timezone-make-date-sortable - (elmo-msgdb-overview-entity-get-date x)) + (elmo-msgdb-message-entity-field msgdb x 'date)) (timezone-make-date-sortable - (elmo-msgdb-overview-entity-get-date y))) + (elmo-msgdb-message-entity-field msgdb y 'date))) (error))))) + +(defsubst elmo-msgdb-get-parent-entity (entity msgdb) + (setq entity (elmo-msgdb-message-entity-field msgdb entity 'references)) + ;; entity is parent-id. + (and entity (elmo-msgdb-message-entity msgdb entity))) + ;;; (defsubst elmo-msgdb-append-element (list element) (if list @@ -240,7 +222,7 @@ (setq entity (elmo-msgdb-message-entity msgdb number)) (elmo-flag-table-set flag-table - (elmo-msgdb-overview-entity-get-id entity) + (elmo-msgdb-message-entity-field msgdb entity 'message-id) (elmo-msgdb-flags msgdb number))) flag-table)) @@ -286,55 +268,15 @@ header separator." (substring string (match-end 0)) string)) -(defsubst elmo-msgdb-get-last-message-id (string) - (if string - (save-match-data - (let (beg) - (elmo-set-work-buf - (insert string) - (goto-char (point-max)) - (when (search-backward "<" nil t) - (setq beg (point)) - (if (search-forward ">" nil t) - (elmo-replace-in-string - (buffer-substring beg (point)) "\n[ \t]*" "")))))))) - -(defun elmo-msgdb-number-load (dir) - (elmo-object-load - (expand-file-name elmo-msgdb-number-filename dir))) - -(defun elmo-msgdb-overview-load (dir) - (elmo-object-load - (expand-file-name elmo-msgdb-overview-filename dir))) - -(defun elmo-msgdb-mark-load (dir) - (elmo-object-load - (expand-file-name elmo-msgdb-mark-filename dir))) - (defsubst elmo-msgdb-seen-load (dir) (elmo-object-load (expand-file-name elmo-msgdb-seen-filename dir))) -(defun elmo-msgdb-number-save (dir obj) - (elmo-object-save - (expand-file-name elmo-msgdb-number-filename dir) - obj)) - -(defun elmo-msgdb-mark-save (dir obj) - (elmo-object-save - (expand-file-name elmo-msgdb-mark-filename dir) - obj)) - (defsubst elmo-msgdb-out-of-date-messages (msgdb) (dolist (number (elmo-msgdb-list-flagged msgdb 'new)) (elmo-msgdb-unset-flag msgdb number 'new))) -(defsubst elmo-msgdb-overview-save (dir overview) - (elmo-object-save - (expand-file-name elmo-msgdb-overview-filename dir) - overview)) - (defun elmo-msgdb-match-condition (msgdb condition number numbers) "Check whether the condition of the message is satisfied or not. MSGDB is the msgdb to search from. @@ -344,23 +286,13 @@ NUMBERS is the target message number list. Return CONDITION itself if no entity exists in msgdb." (let ((entity (elmo-msgdb-message-entity msgdb number))) (if entity - (elmo-msgdb-match-condition-internal condition + (elmo-msgdb-match-condition-internal msgdb + condition entity (elmo-msgdb-flags msgdb number) numbers) condition))) -;; entity -> parent-entity -(defsubst elmo-msgdb-overview-get-parent-entity (entity database) - (setq entity (elmo-msgdb-overview-entity-get-references entity)) - ;; entity is parent-id. - (and entity (assoc entity database))) - -(defsubst elmo-msgdb-get-parent-entity (entity msgdb) - (setq entity (elmo-msgdb-overview-entity-get-references entity)) - ;; entity is parent-id. - (and entity (elmo-msgdb-message-entity msgdb entity))) - ;; ;; deleted message handling ;; @@ -465,89 +397,6 @@ Return CONDITION itself if no entity exists in msgdb." (nth 1 (eword-extract-address-components (or (elmo-field-body "from") "nobody"))) ">")))) -(defsubst elmo-msgdb-create-overview-from-buffer (number &optional size time) - "Create overview entity from current buffer. -Header region is supposed to be narrowed." - (save-excursion - (let ((extras elmo-msgdb-extra-fields) - (default-mime-charset default-mime-charset) - message-id references from subject to cc date - extra field-body charset) - (elmo-set-buffer-multibyte default-enable-multibyte-characters) - (setq message-id (elmo-msgdb-get-message-id-from-buffer)) - (and (setq charset (cdr (assoc "charset" (mime-read-Content-Type)))) - (setq charset (intern-soft charset)) - (setq default-mime-charset charset)) - (setq references - (or (elmo-msgdb-get-last-message-id - (elmo-field-body "in-reply-to")) - (elmo-msgdb-get-last-message-id - (elmo-field-body "references")))) - (setq from (elmo-replace-in-string - (elmo-mime-string (or (elmo-field-body "from") - elmo-no-from)) - "\t" " ") - subject (elmo-replace-in-string - (elmo-mime-string (or (elmo-field-body "subject") - elmo-no-subject)) - "\t" " ")) - (setq date (or (elmo-field-body "date") time)) - (setq to (mapconcat 'identity (elmo-multiple-field-body "to") ",")) - (setq cc (mapconcat 'identity (elmo-multiple-field-body "cc") ",")) - (or size - (if (setq size (elmo-field-body "content-length")) - (setq size (string-to-int size)) - (setq size 0)));; No mean... - (while extras - (if (setq field-body (elmo-field-body (car extras))) - (setq extra (cons (cons (downcase (car extras)) - field-body) extra))) - (setq extras (cdr extras))) - (cons message-id (vector number references - from subject date to cc - size extra)) - ))) - -(defsubst elmo-msgdb-insert-file-header (file) - "Insert the header of the article." - (let ((beg 0) - insert-file-contents-pre-hook ; To avoid autoconv-xmas... - insert-file-contents-post-hook - format-alist) - (when (file-exists-p file) - ;; Read until header separator is found. - (while (and (eq elmo-msgdb-file-header-chop-length - (nth 1 - (insert-file-contents-as-binary - file nil beg - (incf beg elmo-msgdb-file-header-chop-length)))) - (prog1 (not (search-forward "\n\n" nil t)) - (goto-char (point-max)))))))) - -(defsubst elmo-msgdb-create-overview-entity-from-file (number file) - (let (insert-file-contents-pre-hook ; To avoid autoconv-xmas... - insert-file-contents-post-hook header-end - (attrib (file-attributes file)) - ret-val size mtime) - (with-temp-buffer - (if (not (file-exists-p file)) - () - (setq size (nth 7 attrib)) - (setq mtime (timezone-make-date-arpa-standard - (current-time-string (nth 5 attrib)) (current-time-zone))) - ;; insert header from file. - (catch 'done - (condition-case nil - (elmo-msgdb-insert-file-header file) - (error (throw 'done nil))) - (goto-char (point-min)) - (setq header-end - (if (re-search-forward "\\(^--.*$\\)\\|\\(\n\n\\)" nil t) - (point) - (point-max))) - (narrow-to-region (point-min) header-end) - (elmo-msgdb-create-overview-from-buffer number size mtime)))))) - (defsubst elmo-folder-get-info (folder &optional hashtb) (elmo-get-hash-val folder (or hashtb elmo-folder-info-hashtb))) diff --git a/elmo/elmo-nmz.el b/elmo/elmo-nmz.el index 9c80224..79f7ff6 100644 --- a/elmo/elmo-nmz.el +++ b/elmo/elmo-nmz.el @@ -98,22 +98,23 @@ If the value is a list, all elements are used as index paths for namazu." (elmo-folder-name-internal folder)) (expand-file-name "nmz" elmo-msgdb-directory))) -(defun elmo-nmz-msgdb-create-entity (folder number) +(defun elmo-nmz-msgdb-create-entity (msgdb folder number) "Create msgdb entity for the message in the FOLDER with NUMBER." (let ((location (expand-file-name (elmo-map-message-location folder number))) entity uid) - (setq entity (elmo-msgdb-create-overview-entity-from-file number location)) - (unless (or (> (length (elmo-msgdb-overview-entity-get-to entity)) 0) - (> (length (elmo-msgdb-overview-entity-get-cc entity)) 0) - (not (string= (elmo-msgdb-overview-entity-get-subject entity) + (setq entity (elmo-msgdb-create-message-entity-from-file + msgdb number location)) + (unless (or (> (length (elmo-message-entity-field entity 'to)) 0) + (> (length (elmo-message-entity-field entity 'cc)) 0) + (not (string= (elmo-message-entity-field entity 'subject) elmo-no-subject))) - (elmo-msgdb-overview-entity-set-subject entity location) + (elmo-message-entity-set-field entity 'subject location) (setq uid (nth 2 (file-attributes location))) - (elmo-msgdb-overview-entity-set-from entity - (concat - (user-full-name uid) - " <"(user-login-name uid) "@" - (system-name) ">"))) + (elmo-message-entity-set-field entity 'from + (concat + (user-full-name uid) + " <"(user-login-name uid) "@" + (system-name) ">"))) entity)) (luna-define-method elmo-folder-msgdb-create ((folder elmo-nmz-folder) @@ -126,7 +127,7 @@ If the value is a list, all elements are used as index paths for namazu." (while numlist (setq entity (elmo-nmz-msgdb-create-entity - folder (car numlist))) + new-msgdb folder (car numlist))) (when entity (elmo-msgdb-append-entity new-msgdb entity '(new))) (when (> num elmo-display-progress-threshold) diff --git a/elmo/elmo-nntp.el b/elmo/elmo-nntp.el index 9494d76..10ec333 100644 --- a/elmo/elmo-nntp.el +++ b/elmo/elmo-nntp.el @@ -769,6 +769,7 @@ Don't cache if nil.") (setq extra (cons (cons ext field) extra)))) (setq extras (cdr extras))) (setq entity (elmo-msgdb-make-message-entity + new-msgdb :message-id (aref ov-entity 4) :number num :references (elmo-msgdb-get-last-message-id @@ -1417,7 +1418,8 @@ Returns a list of cons cells like (NUMBER . VALUE)" (save-restriction (narrow-to-region beg (point)) (setq entity - (elmo-msgdb-create-overview-from-buffer num)) + (elmo-msgdb-create-message-entity-from-buffer + new-msgdb num)) (when entity (setq message-id (elmo-message-entity-field entity 'message-id)) diff --git a/elmo/elmo-pop3.el b/elmo/elmo-pop3.el index bf00c65..19db3b0 100644 --- a/elmo/elmo-pop3.el +++ b/elmo/elmo-pop3.el @@ -710,10 +710,10 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists." msgdb (lambda (ent1 ent2 loc-alist) (< (elmo-pop3-uidl-to-number - (cdr (assq (elmo-msgdb-overview-entity-get-number ent1) + (cdr (assq (elmo-message-entity-number ent1) loc-alist))) (elmo-pop3-uidl-to-number - (cdr (assq (elmo-msgdb-overview-entity-get-number ent2) + (cdr (assq (elmo-message-entity-number ent2) loc-alist))))) location-alist)) msgdb)) @@ -778,23 +778,24 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists." (save-restriction (narrow-to-region beg (point)) (setq entity - (elmo-msgdb-create-overview-from-buffer - (car numlist))) + (elmo-msgdb-create-message-entity-from-buffer + new-msgdb (car numlist))) (setq numlist (cdr numlist)) (when entity (with-current-buffer (process-buffer process) - (elmo-msgdb-overview-entity-set-size + (elmo-message-entity-set-field entity + 'size (string-to-number (elmo-pop3-number-to-size - (elmo-msgdb-overview-entity-get-number entity)))) + (elmo-message-entity-number entity)))) (if (setq number (car (rassoc (elmo-pop3-number-to-uidl - (elmo-msgdb-overview-entity-get-number entity)) + (elmo-message-entity-number entity)) loc-alist))) - (elmo-msgdb-overview-entity-set-number entity number))) + (elmo-message-entity-set-number entity number))) (setq message-id (elmo-message-entity-field entity 'message-id) flags (elmo-flag-table-get flag-table message-id)) (elmo-global-flags-set flags folder number message-id) diff --git a/elmo/elmo-sendlog.el b/elmo/elmo-sendlog.el index 7a5c811..18d6d5d 100644 --- a/elmo/elmo-sendlog.el +++ b/elmo/elmo-sendlog.el @@ -89,15 +89,16 @@ (message "Creating msgdb...") (while numbers (setq entity - (elmo-msgdb-create-overview-entity-from-file - (car numbers) (elmo-message-file-name folder (car numbers)))) + (elmo-msgdb-create-message-entity-from-filea + new-msgdb (car numbers) + (elmo-message-file-name folder (car numbers)))) (if (null entity) (elmo-folder-set-killed-list-internal folder (nconc (elmo-folder-killed-list-internal folder) (list (car numbers)))) - (setq message-id (elmo-msgdb-overview-entity-get-id entity) + (setq message-id (elmo-message-entity-field entity 'message-id) flags (elmo-flag-table-get flag-table message-id)) (elmo-global-flags-set flags folder (car numbers) message-id) (elmo-msgdb-append-entity new-msgdb entity flags)) diff --git a/elmo/elmo-shimbun.el b/elmo/elmo-shimbun.el index f15b37e..fed6258 100644 --- a/elmo/elmo-shimbun.el +++ b/elmo/elmo-shimbun.el @@ -110,10 +110,9 @@ update overview when message is fetched." (when overviews (setq hash (elmo-make-hash (length overviews))) (dolist (entity overviews) - (elmo-set-hash-val (elmo-msgdb-overview-entity-get-id entity) + (elmo-set-hash-val (elmo-message-entity-field entity 'message-id) entity hash) - (when (setq id (elmo-msgdb-overview-entity-get-extra-field - entity "x-original-id")) + (when (setq id (elmo-message-entity-field entity 'x-original-id)) (elmo-set-hash-val id entity hash))) (elmo-shimbun-folder-set-entity-hash-internal folder hash))))) @@ -131,7 +130,8 @@ update overview when message is fetched." (elmo-shimbun-folder-set-header-hash-internal folder (setq hash (elmo-make-hash)))) - (elmo-set-hash-val (elmo-msgdb-overview-entity-get-id entity) + (elmo-set-hash-val (elmo-message-entity-field entity + 'message-id) header hash) header))))) @@ -158,29 +158,25 @@ update overview when message is fetched." (defun elmo-shimbun-entity-to-header (entity) (let (message-id shimbun-id) - (if (setq message-id (elmo-msgdb-overview-entity-get-extra-field - entity "x-original-id")) - (setq shimbun-id (elmo-msgdb-overview-entity-get-id entity)) - (setq message-id (elmo-msgdb-overview-entity-get-id entity) + (if (setq message-id (elmo-message-entity-field + entity 'x-original-id)) + (setq shimbun-id (elmo-message-entity-field entity 'message-id)) + (setq message-id (elmo-message-entity-field entity 'message-id) shimbun-id nil)) (elmo-set-work-buf (set-buffer-multibyte t) (shimbun-make-header - (elmo-msgdb-overview-entity-get-number entity) + (elmo-message-entity-number entity) (shimbun-mime-encode-string - (decode-mime-charset-string - (elmo-msgdb-overview-entity-get-subject-no-decode entity) - elmo-mime-charset)) + (elmo-message-entity-field entity 'subject 'decode)) (shimbun-mime-encode-string - (decode-mime-charset-string - (elmo-msgdb-overview-entity-get-from-no-decode entity) - elmo-mime-charset)) - (elmo-msgdb-overview-entity-get-date entity) + (elmo-message-entity-field entity 'from 'decode)) + (elmo-message-entity-field entity 'date) message-id - (elmo-msgdb-overview-entity-get-references entity) + (elmo-message-entity-field entity 'references) 0 0 - (elmo-msgdb-overview-entity-get-extra-field entity "xref") + (elmo-message-entity-field entity 'xref) (and shimbun-id (list (cons "x-shimbun-id" shimbun-id))))))) @@ -341,12 +337,12 @@ update overview when message is fetched." (shimbun-header-insert (elmo-shimbun-folder-shimbun-internal folder) header) - (setq ov (elmo-msgdb-create-overview-from-buffer number)) - (elmo-msgdb-overview-entity-set-extra + (setq ov (elmo-msgdb-create-message-entity-from-buffer + (elmo-folder-msgdb-internal folder) number)) + (elmo-message-entity-set-field ov - (nconc - (elmo-msgdb-overview-entity-get-extra ov) - (list (cons "xref" (shimbun-header-xref header))))))))) + 'xref (shimbun-header-xref header))) + ov))) (luna-define-method elmo-folder-msgdb-create ((folder elmo-shimbun-folder) numlist flag-table) @@ -360,7 +356,7 @@ update overview when message is fetched." (elmo-shimbun-msgdb-create-entity folder (car numlist))) (when entity - (setq msgid (elmo-msgdb-overview-entity-get-id entity) + (setq msgid (elmo-message-entity-field entity 'message-id) flags (elmo-flag-table-get flag-table msgid)) (elmo-global-flags-set flags folder (car numlist) msgid) (elmo-msgdb-append-entity new-msgdb entity flags)) @@ -383,8 +379,8 @@ update overview when message is fetched." (message-id (shimbun-header-id header)) references) (unless (string= shimbun-id message-id) - (elmo-msgdb-overview-entity-set-extra-field - entity "x-original-id" message-id) + (elmo-message-entity-set-field + entity 'x-original-id message-id) (elmo-shimbun-header-set-extra-field header "x-shimbun-id" shimbun-id) (elmo-set-hash-val message-id @@ -393,25 +389,30 @@ update overview when message is fetched." (elmo-set-hash-val shimbun-id entity (elmo-shimbun-folder-entity-hash folder))) - (elmo-msgdb-overview-entity-set-from + (elmo-message-entity-set-field entity + 'from (elmo-mime-string (shimbun-header-from header))) - (elmo-msgdb-overview-entity-set-subject + (elmo-message-entity-set-field entity + 'subject (elmo-mime-string (shimbun-header-subject header))) - (elmo-msgdb-overview-entity-set-date - entity (shimbun-header-date header)) + (elmo-message-entity-set-field + entity + 'date + (shimbun-header-date header)) (when (setq references (or (elmo-msgdb-get-last-message-id (elmo-field-body "in-reply-to")) (elmo-msgdb-get-last-message-id (elmo-field-body "references")))) - (elmo-msgdb-overview-entity-set-references + (elmo-message-entity-set-field entity - (or (elmo-msgdb-overview-entity-get-id - (elmo-get-hash-val - references - (elmo-shimbun-folder-entity-hash folder))) + 'references + (or (elmo-message-entity-field entity 'message-id) + (elmo-get-hash-val + references + (elmo-shimbun-folder-entity-hash folder)) references))))) (luna-define-method elmo-map-message-fetch ((folder elmo-shimbun-folder) @@ -459,16 +460,15 @@ update overview when message is fetched." (delq nil (mapcar (lambda (ov) - (when (and (elmo-msgdb-overview-entity-get-extra-field - ov "xref") + (when (and (elmo-message-entity-field ov 'xref) (if expire-days (< (elmo-shimbun-lapse-seconds (elmo-shimbun-parse-time-string - (elmo-msgdb-overview-entity-get-date ov))) + (elmo-message-entity-field ov 'date))) (* expire-days 86400 ; seconds per day )) t)) - (elmo-msgdb-overview-entity-get-id ov))) + (elmo-message-entity-field ov 'message-id))) (elmo-folder-list-message-entities folder))) (mapcar (lambda (header) diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el index 56ac49f..bee64ac 100644 --- a/elmo/elmo-util.el +++ b/elmo/elmo-util.el @@ -1972,6 +1972,31 @@ If ALIST is nil, `elmo-obsolete-variable-alist' is used." (elmo-resque-obsolete-variable (cdr pair) (car pair)))) +(defsubst elmo-msgdb-get-last-message-id (string) + (if string + (save-match-data + (let (beg) + (elmo-set-work-buf + (insert string) + (goto-char (point-max)) + (when (search-backward "<" nil t) + (setq beg (point)) + (if (search-forward ">" nil t) + (elmo-replace-in-string + (buffer-substring beg (point)) "\n[ \t]*" "")))))))) + +(defun elmo-msgdb-get-message-id-from-buffer () + (let ((msgid (elmo-field-body "message-id"))) + (if msgid + (if (string-match "<\\(.+\\)>$" msgid) + msgid + (concat "<" msgid ">")) ; Invaild message-id. + ;; no message-id, so put dummy msgid. + (concat "<" (timezone-make-date-sortable + (elmo-field-body "date")) + (nth 1 (eword-extract-address-components + (or (elmo-field-body "from") "nobody"))) ">")))) + ;;; Queue. (defvar elmo-dop-queue-filename "queue" "*Disconnected operation queue is saved in this file.") diff --git a/elmo/elmo.el b/elmo/elmo.el index ef56069..a06abb0 100644 --- a/elmo/elmo.el +++ b/elmo/elmo.el @@ -498,9 +498,9 @@ Return newly created temporary directory name which contains temporary files.") (luna-define-method elmo-find-fetch-strategy ((folder elmo-folder) entity &optional ignore-cache) (let (cache-file size message-id number) - (setq size (elmo-msgdb-overview-entity-get-size entity)) - (setq message-id (elmo-msgdb-overview-entity-get-id entity)) - (setq number (elmo-msgdb-overview-entity-get-number entity)) + (setq size (elmo-message-entity-field entity 'size)) + (setq message-id (elmo-message-entity-field entity 'message-id)) + (setq number (elmo-message-entity-number entity)) (setq cache-file (elmo-file-cache-get message-id)) (setq ignore-cache (or ignore-cache (null (elmo-message-use-cache-p folder number)))) @@ -1121,11 +1121,8 @@ If CACHED is t, message is set as cached.") (elmo-msgdb-unset-flag (elmo-folder-msgdb folder) number 'cached))) (defun elmo-message-copy-entity (entity) - ;; - (elmo-msgdb-copy-overview-entity entity)) - -(defun elmo-message-entity-set-number (entity number) - (elmo-msgdb-overview-entity-set-number entity number)) + (elmo-msgdb-copy-message-entity (elmo-message-entity-db entity) + entity)) (luna-define-generic elmo-message-entity (folder key) "Return the message-entity structure which matches to the KEY. @@ -1162,21 +1159,31 @@ ENTITY is the message-entity to get the parent.") ,@form)) (defmacro elmo-message-entity-number (entity) - `(elmo-msgdb-overview-entity-get-number ,entity)) + `(elmo-msgdb-message-entity-number (elmo-message-entity-db ,entity) + ,entity)) + +(defmacro elmo-message-entity-set-number (entity number) + `(elmo-msgdb-message-entity-set-number (elmo-message-entity-db ,entity) + ,entity + ,number)) (defun elmo-message-entity-field (entity field &optional decode) "Get message entity field value. ENTITY is the message entity structure obtained by `elmo-message-entity'. FIELD is the symbol of the field name. if optional DECODE is non-nil, returned value is decoded." - (elmo-msgdb-message-entity-field entity field decode)) + (elmo-msgdb-message-entity-field + (elmo-message-entity-db entity) + entity field decode)) (defun elmo-message-entity-set-field (entity field value) "Set message entity field value. ENTITY is the message entity structure. FIELD is the symbol of the field name. VALUE is the field value (raw)." - (elmo-msgdb-message-entity-set-field entity field value)) + (elmo-msgdb-message-entity-set-field + (elmo-message-entity-db entity) + entity field value)) (luna-define-generic elmo-folder-count-flags (folder) "Count flagged message number in the msgdb of the FOLDER. @@ -1272,7 +1279,9 @@ FIELD is a symbol of the field.") (luna-define-method elmo-message-field ((folder elmo-folder) number field) (when (zerop (elmo-folder-length folder)) (error "Cannot treat this folder correctly.")) - (elmo-msgdb-get-field (elmo-folder-msgdb folder) number field)) + (elmo-msgdb-message-entity-field (elmo-folder-msgdb folder) + (elmo-message-entity folder number) + field)) (luna-define-method elmo-message-use-cache-p ((folder elmo-folder) number) nil) ; default is not use cache. diff --git a/elmo/modb-legacy.el b/elmo/modb-legacy.el index 2287fe8..d0c8990 100644 --- a/elmo/modb-legacy.el +++ b/elmo/modb-legacy.el @@ -34,7 +34,6 @@ (require 'elmo-util) (require 'modb) -(require 'modb-entity) ;;; legacy implement ;; @@ -102,6 +101,146 @@ (defsubst elmo-msgdb-set-path (msgdb path) (modb-generic-set-location-internal msgdb path)) +;;; +;; Internal use only (obsolete interface) +;; +;; +;; mime decode cache +;; +(defvar elmo-msgdb-decoded-cache-hashtb nil) +(make-variable-buffer-local 'elmo-msgdb-decoded-cache-hashtb) + +(defsubst elmo-msgdb-get-decoded-cache (string) + (if elmo-use-decoded-cache + (let ((hashtb (or elmo-msgdb-decoded-cache-hashtb + (setq elmo-msgdb-decoded-cache-hashtb + (elmo-make-hash 2048)))) + decoded) + (or (elmo-get-hash-val string hashtb) + (progn + (elmo-set-hash-val + string + (setq decoded + (decode-mime-charset-string string elmo-mime-charset)) + hashtb) + decoded))) + (decode-mime-charset-string string elmo-mime-charset))) + +(defsubst elmo-msgdb-overview-entity-get-id (entity) + (and entity (car entity))) + +(defsubst elmo-msgdb-overview-entity-get-number (entity) + (and entity (aref (cdr entity) 0))) + +(defsubst elmo-msgdb-overview-entity-set-number (entity number) + (and entity (aset (cdr entity) 0 number)) + entity) + +(defsubst elmo-msgdb-overview-entity-get-references (entity) + (and entity (aref (cdr entity) 1))) + +(defsubst elmo-msgdb-overview-entity-set-references (entity references) + (and entity (aset (cdr entity) 1 references)) + entity) + +(defsubst elmo-msgdb-overview-entity-get-from-no-decode (entity) + (and entity (aref (cdr entity) 2))) + +(defsubst elmo-msgdb-overview-entity-get-from (entity) + (and entity + (aref (cdr entity) 2) + (elmo-msgdb-get-decoded-cache (aref (cdr entity) 2)))) + +(defsubst elmo-msgdb-overview-entity-set-from (entity from) + (and entity (aset (cdr entity) 2 from)) + entity) + +(defsubst elmo-msgdb-overview-entity-get-subject (entity) + (and entity + (aref (cdr entity) 3) + (elmo-msgdb-get-decoded-cache (aref (cdr entity) 3)))) + +(defsubst elmo-msgdb-overview-entity-get-subject-no-decode (entity) + (and entity (aref (cdr entity) 3))) + +(defsubst elmo-msgdb-overview-entity-set-subject (entity subject) + (and entity (aset (cdr entity) 3 subject)) + entity) + +(defsubst elmo-msgdb-overview-entity-get-date (entity) + (and entity (aref (cdr entity) 4))) + +(defsubst elmo-msgdb-overview-entity-set-date (entity date) + (and entity (aset (cdr entity) 4 date)) + entity) + +(defsubst elmo-msgdb-overview-entity-get-to (entity) + (and entity (aref (cdr entity) 5))) + +(defsubst elmo-msgdb-overview-entity-get-cc (entity) + (and entity (aref (cdr entity) 6))) + +(defsubst elmo-msgdb-overview-entity-get-size (entity) + (and entity (aref (cdr entity) 7))) + +(defsubst elmo-msgdb-overview-entity-set-size (entity size) + (and entity (aset (cdr entity) 7 size)) + entity) + +(defsubst elmo-msgdb-overview-entity-get-extra (entity) + (and entity (aref (cdr entity) 8))) + +(defsubst elmo-msgdb-overview-entity-set-extra (entity extra) + (and entity (aset (cdr entity) 8 extra)) + entity) + +(defsubst elmo-msgdb-overview-entity-get-extra-field (entity field-name) + (let ((field-name (downcase field-name)) + (extra (and entity (aref (cdr entity) 8)))) + (and extra + (cdr (assoc field-name extra))))) + +(defsubst elmo-msgdb-overview-entity-set-extra-field (entity field-name value) + (let ((field-name (downcase field-name)) + (extras (and entity (aref (cdr entity) 8))) + extra) + (if (setq extra (assoc field-name extras)) + (setcdr extra value) + (elmo-msgdb-overview-entity-set-extra + entity + (cons (cons field-name value) extras))))) + +;;; load & save +(defun elmo-msgdb-number-load (dir) + (elmo-object-load + (expand-file-name elmo-msgdb-number-filename dir))) + +(defun elmo-msgdb-overview-load (dir) + (elmo-object-load + (expand-file-name elmo-msgdb-overview-filename dir))) + +(defun elmo-msgdb-mark-load (dir) + (elmo-object-load + (expand-file-name elmo-msgdb-mark-filename dir))) + +(defun elmo-msgdb-number-save (dir obj) + (elmo-object-save + (expand-file-name elmo-msgdb-number-filename dir) + obj)) + +(defun elmo-msgdb-mark-save (dir obj) + (elmo-object-save + (expand-file-name elmo-msgdb-mark-filename dir) + obj)) + +(defsubst elmo-msgdb-overview-save (dir overview) + (elmo-object-save + (expand-file-name elmo-msgdb-overview-filename dir) + overview)) + +;;; + + (defvar modb-legacy-unread-marks-internal nil) (defsubst modb-legacy-unread-marks () "Return an unread mark list" @@ -465,11 +604,294 @@ Return a list of message numbers which have duplicated message-ids." msgdb)) (luna-define-method elmo-msgdb-message-entity ((msgdb modb-legacy) key) - (elmo-get-hash-val + (elmo-get-hash-val (cond ((stringp key) key) ((numberp key) (format "#%d" key))) (elmo-msgdb-get-entity-hashtb msgdb))) +;;; Message entity handling. +(defsubst modb-legacy-make-message-entity (args) + "Make an message entity." + (cons (plist-get args :message-id) + (vector (plist-get args :number) + (plist-get args :references) + (plist-get args :from) + (plist-get args :subject) + (plist-get args :date) + (plist-get args :to) + (plist-get args :cc) + (plist-get args :size) + (plist-get args :extra)))) + +(luna-define-method elmo-msgdb-make-message-entity ((msgdb modb-legacy) + args) + (modb-legacy-make-message-entity args)) + +(defsubst elmo-msgdb-insert-file-header (file) + "Insert the header of the article." + (let ((beg 0) + insert-file-contents-pre-hook ; To avoid autoconv-xmas... + insert-file-contents-post-hook + format-alist) + (when (file-exists-p file) + ;; Read until header separator is found. + (while (and (eq elmo-msgdb-file-header-chop-length + (nth 1 + (insert-file-contents-as-binary + file nil beg + (incf beg elmo-msgdb-file-header-chop-length)))) + (prog1 (not (search-forward "\n\n" nil t)) + (goto-char (point-max)))))))) + +(luna-define-method elmo-msgdb-create-message-entity-from-file + ((msgdb modb-legacy) number file) + (let (insert-file-contents-pre-hook ; To avoid autoconv-xmas... + insert-file-contents-post-hook header-end + (attrib (file-attributes file)) + ret-val size mtime) + (with-temp-buffer + (if (not (file-exists-p file)) + () + (setq size (nth 7 attrib)) + (setq mtime (timezone-make-date-arpa-standard + (current-time-string (nth 5 attrib)) (current-time-zone))) + ;; insert header from file. + (catch 'done + (condition-case nil + (elmo-msgdb-insert-file-header file) + (error (throw 'done nil))) + (goto-char (point-min)) + (setq header-end + (if (re-search-forward "\\(^--.*$\\)\\|\\(\n\n\\)" nil t) + (point) + (point-max))) + (narrow-to-region (point-min) header-end) + (elmo-msgdb-create-message-entity-from-buffer + msgdb number :size size :date mtime)))))) + +(luna-define-method elmo-msgdb-create-message-entity-from-buffer + ((msgdb modb-legacy) number args) + (let ((extras elmo-msgdb-extra-fields) + (default-mime-charset default-mime-charset) + entity message-id references from subject to cc date + extra field-body charset size) + (save-excursion + (setq entity (modb-legacy-make-message-entity args)) + (elmo-set-buffer-multibyte default-enable-multibyte-characters) + (setq message-id (elmo-msgdb-get-message-id-from-buffer)) + (and (setq charset (cdr (assoc "charset" (mime-read-Content-Type)))) + (setq charset (intern-soft charset)) + (setq default-mime-charset charset)) + (setq references + (or (elmo-msgdb-get-last-message-id + (elmo-field-body "in-reply-to")) + (elmo-msgdb-get-last-message-id + (elmo-field-body "references"))) + from (elmo-replace-in-string + (elmo-mime-string (or (elmo-field-body "from") + elmo-no-from)) + "\t" " ") + subject (elmo-replace-in-string + (elmo-mime-string (or (elmo-field-body "subject") + elmo-no-subject)) + "\t" " ") + date (elmo-field-body "date") + to (mapconcat 'identity (elmo-multiple-field-body "to") ",") + cc (mapconcat 'identity (elmo-multiple-field-body "cc") ",")) + (unless (elmo-msgdb-message-entity-field msgdb entity 'size) + (if (setq size (elmo-field-body "content-length")) + (setq size (string-to-int size)) + (setq size 0))) + (while extras + (if (setq field-body (elmo-field-body (car extras))) + (setq extra (cons (cons (downcase (car extras)) + field-body) extra))) + (setq extras (cdr extras))) + (dolist (field '(message-id number references from subject date to cc + size extra)) + (when (symbol-value field) + (elmo-msgdb-message-entity-set-field + msgdb entity field (symbol-value field)))) + entity))) + +;;; Message entity interface +;; +(luna-define-method elmo-msgdb-message-entity-number ((msgdb modb-legacy) + entity) + (and entity (aref (cdr entity) 0))) + +(luna-define-method elmo-msgdb-message-entity-set-number ((msgdb modb-legacy) + entity + number) + (and entity (aset (cdr entity) 0 number)) + entity) + +(luna-define-method elmo-msgdb-message-entity-field ((msgdb modb-legacy) + entity field + &optional decode) + (and entity + (let ((field-value + (case field + (to (aref (cdr entity) 5)) + (cc (aref (cdr entity) 6)) + (date (aref (cdr entity) 4)) + (subject (aref (cdr entity) 3)) + (from (aref (cdr entity) 2)) + (message-id (car entity)) + (references (aref (cdr entity) 1)) + (size (aref (cdr entity) 7)) + (t (cdr (assoc (symbol-name field) (aref (cdr entity) 8))))))) + (if (and decode (memq field '(from subject))) + (elmo-msgdb-get-decoded-cache field-value) + field-value)))) + +(luna-define-method elmo-msgdb-message-entity-set-field ((msgdb modb-legacy) + entity field value) + (and entity + (case field + (number (aset (cdr entity) 0 value)) + (to (aset (cdr entity) 5 value)) + (cc (aset (cdr entity) 6 value)) + (date (aset (cdr entity) 4 value)) + (subject (aset (cdr entity) 3 value)) + (from (aset (cdr entity) 2 value)) + (message-id (setcar entity value)) + (references (aset (cdr entity) 1 value)) + (size (aset (cdr entity) 7 value)) + (t + (let ((extras (and entity (aref (cdr entity) 8))) + extra) + (if (setq extra (assoc field extras)) + (setcdr extra value) + (aset (cdr entity) 8 (cons (cons (symbol-name field) + value) extras)))))))) + +(luna-define-method elmo-msgdb-copy-message-entity ((msgdb modb-legacy) + entity) + (cons (car entity) + (copy-sequence (cdr entity)))) + +(luna-define-method elmo-msgdb-match-condition-internal ((msgdb modb-legacy) + condition + entity flags numbers) + (cond + ((vectorp condition) + (elmo-msgdb-match-condition-primitive condition entity flags numbers)) + ((eq (car condition) 'and) + (let ((lhs (elmo-msgdb-match-condition-internal msgdb + (nth 1 condition) + entity flags numbers))) + (cond + ((elmo-filter-condition-p lhs) + (let ((rhs (elmo-msgdb-match-condition-internal + msgdb (nth 2 condition) entity flags numbers))) + (cond ((elmo-filter-condition-p rhs) + (list 'and lhs rhs)) + (rhs + lhs)))) + (lhs + (elmo-msgdb-match-condition-internal msgdb (nth 2 condition) + entity flags numbers))))) + ((eq (car condition) 'or) + (let ((lhs (elmo-msgdb-match-condition-internal msgdb (nth 1 condition) + entity flags numbers))) + (cond + ((elmo-filter-condition-p lhs) + (let ((rhs (elmo-msgdb-match-condition-internal msgdb + (nth 2 condition) + entity flags numbers))) + (cond ((elmo-filter-condition-p rhs) + (list 'or lhs rhs)) + (rhs + t) + (t + lhs)))) + (lhs + t) + (t + (elmo-msgdb-match-condition-internal msgdb + (nth 2 condition) + entity flags numbers))))))) + +;; +(defun elmo-msgdb-match-condition-primitive (condition entity flags numbers) + (catch 'unresolved + (let ((key (elmo-filter-key condition)) + (case-fold-search t) + result) + (cond + ((string= key "last") + (setq result (<= (length (memq + (elmo-msgdb-overview-entity-get-number + entity) + numbers)) + (string-to-int (elmo-filter-value condition))))) + ((string= key "first") + (setq result (< (- + (length numbers) + (length (memq + (elmo-msgdb-overview-entity-get-number + entity) + numbers))) + (string-to-int (elmo-filter-value condition))))) + ((string= key "flag") + (setq result + (cond + ((string= (elmo-filter-value condition) "any") + (or (memq 'important flags) + (memq 'answered flags) + (memq 'unread flags))) + ((string= (elmo-filter-value condition) "digest") + (or (memq 'important flags) + (memq 'unread flags))) + ((string= (elmo-filter-value condition) "unread") + (memq 'unread flags)) + ((string= (elmo-filter-value condition) "important") + (memq 'important flags)) + ((string= (elmo-filter-value condition) "answered") + (memq 'answered flags))))) + ((string= key "from") + (setq result (string-match + (elmo-filter-value condition) + (elmo-msgdb-overview-entity-get-from entity)))) + ((string= key "subject") + (setq result (string-match + (elmo-filter-value condition) + (elmo-msgdb-overview-entity-get-subject entity)))) + ((string= key "to") + (setq result (string-match + (elmo-filter-value condition) + (elmo-msgdb-overview-entity-get-to entity)))) + ((string= key "cc") + (setq result (string-match + (elmo-filter-value condition) + (elmo-msgdb-overview-entity-get-cc entity)))) + ((or (string= key "since") + (string= key "before")) + (let ((field-date (elmo-date-make-sortable-string + (timezone-fix-time + (elmo-msgdb-overview-entity-get-date entity) + (current-time-zone) nil))) + (specified-date + (elmo-date-make-sortable-string + (elmo-date-get-datevec + (elmo-filter-value condition))))) + (setq result (if (string= key "since") + (or (string= specified-date field-date) + (string< specified-date field-date)) + (string< field-date specified-date))))) + ((member key elmo-msgdb-extra-fields) + (let ((extval (elmo-msgdb-overview-entity-get-extra-field entity key))) + (when (stringp extval) + (setq result (string-match + (elmo-filter-value condition) + extval))))) + (t + (throw 'unresolved condition))) + (if (eq (elmo-filter-type condition) 'unmatch) + (not result) + result)))) + (require 'product) (product-provide (provide 'modb-legacy) (require 'elmo-version)) diff --git a/elmo/modb-standard.el b/elmo/modb-standard.el index 9083717..f5b6a2a 100644 --- a/elmo/modb-standard.el +++ b/elmo/modb-standard.el @@ -33,7 +33,8 @@ (require 'elmo-util) (require 'modb) -(require 'modb-entity) +;; Currently, entity structure is same as legacy. +(require 'modb-legacy) (defcustom modb-standard-divide-number 500 @@ -428,6 +429,183 @@ (modb-standard-entity-map-internal msgdb))) ret))) +;;; Message entity handling. +(defsubst modb-standard-make-message-entity (args) + "Make an message entity." + (cons (plist-get args :message-id) + (vector (plist-get args :number) + (plist-get args :references) + (plist-get args :from) + (plist-get args :subject) + (plist-get args :date) + (plist-get args :to) + (plist-get args :cc) + (plist-get args :size) + (plist-get args :extra)))) + +(luna-define-method elmo-msgdb-make-message-entity ((msgdb modb-standard) + args) + (modb-standard-make-message-entity args)) + +(luna-define-method elmo-msgdb-create-message-entity-from-file + ((msgdb modb-standard) number file) + (let (insert-file-contents-pre-hook ; To avoid autoconv-xmas... + insert-file-contents-post-hook header-end + (attrib (file-attributes file)) + ret-val size mtime) + (with-temp-buffer + (if (not (file-exists-p file)) + () + (setq size (nth 7 attrib)) + (setq mtime (timezone-make-date-arpa-standard + (current-time-string (nth 5 attrib)) (current-time-zone))) + ;; insert header from file. + (catch 'done + (condition-case nil + (elmo-msgdb-insert-file-header file) + (error (throw 'done nil))) + (goto-char (point-min)) + (setq header-end + (if (re-search-forward "\\(^--.*$\\)\\|\\(\n\n\\)" nil t) + (point) + (point-max))) + (narrow-to-region (point-min) header-end) + (elmo-msgdb-create-message-entity-from-buffer + msgdb number :size size :date mtime)))))) + +(luna-define-method elmo-msgdb-create-message-entity-from-buffer + ((msgdb modb-standard) number args) + (let ((extras elmo-msgdb-extra-fields) + (default-mime-charset default-mime-charset) + entity message-id references from subject to cc date + extra field-body charset size) + (save-excursion + (setq entity (modb-standard-make-message-entity args)) + (elmo-set-buffer-multibyte default-enable-multibyte-characters) + (setq message-id (elmo-msgdb-get-message-id-from-buffer)) + (and (setq charset (cdr (assoc "charset" (mime-read-Content-Type)))) + (setq charset (intern-soft charset)) + (setq default-mime-charset charset)) + (setq references + (or (elmo-msgdb-get-last-message-id + (elmo-field-body "in-reply-to")) + (elmo-msgdb-get-last-message-id + (elmo-field-body "references"))) + from (elmo-replace-in-string + (elmo-mime-string (or (elmo-field-body "from") + elmo-no-from)) + "\t" " ") + subject (elmo-replace-in-string + (elmo-mime-string (or (elmo-field-body "subject") + elmo-no-subject)) + "\t" " ") + date (elmo-field-body "date") + to (mapconcat 'identity (elmo-multiple-field-body "to") ",") + cc (mapconcat 'identity (elmo-multiple-field-body "cc") ",")) + (unless (elmo-msgdb-message-entity-field msgdb entity 'size) + (if (setq size (elmo-field-body "content-length")) + (setq size (string-to-int size)) + (setq size 0))) + (while extras + (if (setq field-body (elmo-field-body (car extras))) + (setq extra (cons (cons (downcase (car extras)) + field-body) extra))) + (setq extras (cdr extras))) + (dolist (field '(number message-id references from subject date to cc + size extra)) + (when (symbol-value field) + (elmo-msgdb-message-entity-set-field + msgdb entity field (symbol-value field)))) + entity))) + +;;; Message entity interface +;; +(luna-define-method elmo-msgdb-message-entity-field ((msgdb modb-standard) + entity field + &optional decode) + (and entity + (let ((field-value + (case field + (to (aref (cdr entity) 5)) + (cc (aref (cdr entity) 6)) + (date (aref (cdr entity) 4)) + (subject (aref (cdr entity) 3)) + (from (aref (cdr entity) 2)) + (message-id (car entity)) + (references (aref (cdr entity) 1)) + (size (aref (cdr entity) 7)) + (t (cdr (assoc (symbol-name field) (aref (cdr entity) 8))))))) + (if (and decode (memq field '(from subject))) + (elmo-msgdb-get-decoded-cache field-value) + field-value)))) + +(luna-define-method elmo-msgdb-message-entity-set-field ((msgdb modb-standard) + entity field value) + (and entity + (case field + (number (aset (cdr entity) 0 value)) + (to (aset (cdr entity) 5 value)) + (cc (aset (cdr entity) 6 value)) + (date (aset (cdr entity) 4 value)) + (subject (aset (cdr entity) 3 value)) + (from (aset (cdr entity) 2 value)) + (message-id (setcar entity value)) + (references (aset (cdr entity) 1 value)) + (size (aset (cdr entity) 7 value)) + (t + (let ((extras (and entity (aref (cdr entity) 8))) + extra) + (if (setq extra (assoc field extras)) + (setcdr extra value) + (aset (cdr entity) 8 (cons (cons (symbol-name field) + value) extras)))))))) + +(luna-define-method elmo-msgdb-copy-message-entity ((msgdb modb-standard) + entity) + (cons (car entity) + (copy-sequence (cdr entity)))) + +(luna-define-method elmo-msgdb-match-condition-internal ((msgdb modb-standard) + condition + entity flags numbers) + (cond + ((vectorp condition) + (elmo-msgdb-match-condition-primitive condition entity flags numbers)) + ((eq (car condition) 'and) + (let ((lhs (elmo-msgdb-match-condition-internal msgdb + (nth 1 condition) + entity flags numbers))) + (cond + ((elmo-filter-condition-p lhs) + (let ((rhs (elmo-msgdb-match-condition-internal + msgdb (nth 2 condition) entity flags numbers))) + (cond ((elmo-filter-condition-p rhs) + (list 'and lhs rhs)) + (rhs + lhs)))) + (lhs + (elmo-msgdb-match-condition-internal msgdb (nth 2 condition) + entity flags numbers))))) + ((eq (car condition) 'or) + (let ((lhs (elmo-msgdb-match-condition-internal msgdb (nth 1 condition) + entity flags numbers))) + (cond + ((elmo-filter-condition-p lhs) + (let ((rhs (elmo-msgdb-match-condition-internal msgdb + (nth 2 condition) + entity flags numbers))) + (cond ((elmo-filter-condition-p rhs) + (list 'or lhs rhs)) + (rhs + t) + (t + lhs)))) + (lhs + t) + (t + (elmo-msgdb-match-condition-internal msgdb + (nth 2 condition) + entity flags numbers))))))) (require 'product) (product-provide (provide 'modb-standard) (require 'elmo-version)) diff --git a/elmo/modb.el b/elmo/modb.el index 7dd2782..48c5013 100644 --- a/elmo/modb.el +++ b/elmo/modb.el @@ -111,7 +111,8 @@ Return non-nil if message-id of entity is duplicated.") (luna-define-generic elmo-msgdb-delete-messages (msgdb numbers) "Delete messages which are contained NUMBERS from MSGDB.") -(luna-define-generic elmo-msgdb-sort-entities (msgdb predicate &optional app-data) +(luna-define-generic elmo-msgdb-sort-entities (msgdb predicate + &optional app-data) "Sort entities of MSGDB, comparing with PREDICATE. PREDICATE is called with two entities and APP-DATA. Should return non-nil if the first entity is \"less\" than the second.") @@ -122,6 +123,75 @@ KEY is a number or a string. A number is for message number in the MSGDB. A string is for message-id of the message.") +;; Message entity handling. +(defvar modb-cache-internal nil) +(defun elmo-message-entity-db (entity) + "Get modb instance which corresponds to the ENTITY." + (if (or (null (car entity)) + (stringp (car entity))) + ;; Transitional implementation for modb-legacy. + (or modb-cache-internal + (progn + (require 'modb-legacy) + (setq modb-cache-internal (luna-make-entity 'modb-legacy)))) + ;; XXX Next generation entity structure...not decided yet. + (car entity))) + +(luna-define-generic elmo-msgdb-make-message-entity (msgdb + &rest args) + "Make a message entity for MSGDB.") + +(luna-define-generic elmo-msgdb-message-entity-number (msgdb entity) + "Number of the ENTITY.") + +(luna-define-generic elmo-msgdb-message-entity-set-number (msgdb entity number) + "Set number of the ENTITY.") + +(luna-define-generic elmo-msgdb-message-entity-field (msgdb + entity field + &optional decode) + "Retrieve field value of the message entity. +MSGDB is the msgdb structure. +ENTITY is the message entity structure. +FIELD is a symbol of the field. +If optional DECODE is no-nil, the field value is decoded.") + +(luna-define-generic elmo-msgdb-message-entity-set-field (msgdb + entity field value) + "Set the field value of the message entity. +MSGDB is the msgdb structure. +ENTITY is the message entity structure. +FIELD is a symbol of the field. +VALUE is the field value to set.") + +(luna-define-generic elmo-msgdb-copy-message-entity (msgdb entity) + "Copy message entity. +MSGDB is the msgdb structure. +ENTITY is the message entity structure.") + +(luna-define-generic elmo-msgdb-create-message-entity-from-file (msgdb number + file) + "Create message entity from file. +MSGDB is the msgdb structure. +NUMBER is the number of the newly created message entity. +FILE is the message file.") + +(luna-define-generic elmo-msgdb-create-message-entity-from-buffer (msgdb + number + &rest args) + "Create message entity from current buffer. +NUMBER is the number of the newly created message entity. +Rest of the ARGS is a plist of message entity field for initial value. +Header region is supposed to be narrowed.") + +;; Transitional interface. +(luna-define-generic elmo-msgdb-match-condition-internal (msgdb + condition + entity + flags + numbers) + "Return non-nil when the entity matches the condition.") + ;;; generic implement ;; (luna-define-method elmo-msgdb-load ((msgdb modb-generic)) diff --git a/wl/ChangeLog b/wl/ChangeLog index 953f9fc..b6a0dae 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,5 +1,25 @@ 2003-09-21 Yuuichi Teranishi + * wl-summary.el (wl-summary-detect-mark-position): Follow the API + change in elmo-msgdb-make-message-entity. + (wl-summary-buffer-set-folder): Don't call + wl-summary-detect-mark-position here. + (wl-summary-rescan): Call elmo-message-entity-number. + (wl-summary-sync-update): Ditto. + (wl-summary-goto-folder-subr): Call wl-summary-detect-mark-position. + + * wl-score.el (wl-score-header-index): Redefine 2th element. + (wl-score-overview-entity-get-extra): Abolish. + (wl-score-ov-entity-get): Rewrite. + (wl-score-string-index<, wl-score-string-func<): Abolish. + (wl-score-string<): New function. + (wl-score-string-sort): Use it. + + * wl-refile.el (wl-refile-guess-by-history): Use + elmo-message-entity-field. + (wl-refile-guess-by-from): Ditto. + (wl-refile-guess-by-msgid): Ditto. + * Version number is increased to 2.11.16. 2003-09-21 Yoichi NAKAYAMA diff --git a/wl/wl-refile.el b/wl/wl-refile.el index feb8282..607e410 100644 --- a/wl/wl-refile.el +++ b/wl/wl-refile.el @@ -216,8 +216,8 @@ If RULE does not match ENTITY, returns nil." (downcase (wl-address-header-extract-address entity)))) (wl-parse-addresses (concat - (elmo-msgdb-overview-entity-get-to entity) "," - (elmo-msgdb-overview-entity-get-cc entity))))) + (elmo-message-entity-field entity 'to) "," + (elmo-message-entity-field entity 'cc))))) ret-val) (setq tocc-list (elmo-list-delete (or wl-user-mail-address-list @@ -238,14 +238,14 @@ If RULE does not match ENTITY, returns nil." (defun wl-refile-guess-by-from (entity) (let ((from (downcase (wl-address-header-extract-address - (elmo-msgdb-overview-entity-get-from entity))))) + (elmo-message-entity-field entity 'from))))) ;; search from alist (or (cdr (assoc from wl-refile-alist)) (format "%s/%s" wl-refile-default-from-folder (wl-refile-get-account-part-from-address from))))) (defun wl-refile-guess-by-msgid (entity) - (cdr (assoc (elmo-msgdb-overview-entity-get-references entity) + (cdr (assoc (elmo-message-entity-field entity 'references) wl-refile-msgid-alist))) (defun wl-refile-guess-by-subject (entity) diff --git a/wl/wl-score.el b/wl/wl-score.el index 2527b8c..45edbef 100644 --- a/wl/wl-score.el +++ b/wl/wl-score.el @@ -69,20 +69,20 @@ (defconst wl-score-header-index ;; Name to function alist. - '(("number" wl-score-integer elmo-msgdb-overview-entity-get-number) ;;0 - ("subject" wl-score-string 3 charset) - ("from" wl-score-string 2 charset) - ("date" wl-score-date elmo-msgdb-overview-entity-get-date) ;;4 - ("message-id" wl-score-string elmo-msgdb-overview-entity-get-id) - ("references" wl-score-string 1) - ("to" wl-score-string 5) - ("cc" wl-score-string 6) - ("chars" wl-score-integer elmo-msgdb-overview-entity-get-size) ;;7 - ("lines" wl-score-integer wl-score-overview-entity-get-lines) - ("xref" wl-score-string wl-score-overview-entity-get-xref) - ("extra" wl-score-extra wl-score-overview-entity-get-extra mime) - ("followup" wl-score-followup 2 charset) - ("thread" wl-score-thread 1))) + '(("number" wl-score-integer number) + ("subject" wl-score-string subject charset) + ("from" wl-score-string from charset) + ("date" wl-score-date date) + ("message-id" wl-score-string message-id) + ("references" wl-score-string references) + ("to" wl-score-string to) + ("cc" wl-score-string cc) + ("chars" wl-score-integer size) + ("lines" wl-score-integer lines) + ("xref" wl-score-string xref) + ("extra" wl-score-extra extra mime) + ("followup" wl-score-followup from charset) + ("thread" wl-score-thread references))) (defvar wl-score-auto-make-followup-entry nil) (defvar wl-score-debug nil) @@ -172,45 +172,19 @@ Remove Re, Was, Fwd etc." (or (elmo-message-entity-field entity 'xref) "")) -(defun wl-score-overview-entity-get-extra (entity header &optional decode) - (let ((extra (elmo-msgdb-overview-entity-get-extra-field entity header))) - (if (and extra decode) - (eword-decode-string - (decode-mime-charset-string extra elmo-mime-charset)) - (or extra "")))) - (defun wl-string> (s1 s2) (not (or (string< s1 s2) (string= s1 s2)))) -(defmacro wl-score-ov-entity-get-by-index (entity index) - (` (aref (cdr (, entity)) (, index)))) - (defsubst wl-score-ov-entity-get (entity index &optional extra decode) - (let ((str (cond ((integerp index) - (wl-score-ov-entity-get-by-index entity index)) - (extra - (funcall index entity extra decode)) - (t - (funcall index entity))))) - (if (and decode (not extra)) - (decode-mime-charset-string str elmo-mime-charset) - str))) - -(defun wl-score-string-index< (a1 a2) - (string-lessp (wl-score-ov-entity-get-by-index (car a1) wl-score-index) - (wl-score-ov-entity-get-by-index (car a2) wl-score-index))) - -(defun wl-score-string-func< (a1 a2) - (string-lessp (funcall wl-score-index (car a1)) - (funcall wl-score-index (car a2)))) + (elmo-message-entity-field entity index decode)) + +(defun wl-score-string< (a1 a2) + (string-lessp (wl-score-ov-entity-get (car a1) wl-score-index) + (wl-score-ov-entity-get (car a2) wl-score-index))) (defun wl-score-string-sort (messages index) - (let ((func (cond ((integerp index) - 'wl-score-string-index<) - (t - 'wl-score-string-func<)))) - (sort messages func))) + (sort messages 'wl-score-string<)) (defsubst wl-score-get (symbol &optional alist) "Get SYMBOL's definition in ALIST." diff --git a/wl/wl-summary.el b/wl/wl-summary.el index c2bc638..66b1daf 100644 --- a/wl/wl-summary.el +++ b/wl/wl-summary.el @@ -667,6 +667,7 @@ you." (dummy-temp (char-to-string 200)) (wl-summary-new-mark (char-to-string 201)) ; bind only for the check. (wl-summary-flag-priority-list '(new)) ; ditto. + (msgdb (elmo-folder-msgdb-internal wl-summary-buffer-elmo-folder)) wl-summary-highlight temp persistent) (with-temp-buffer @@ -675,6 +676,7 @@ you." (insert (wl-summary-create-line (elmo-msgdb-make-message-entity + msgdb :number 10000 :from "foo" :subject "bar" @@ -727,7 +729,6 @@ you." wl-summary-buffer-mode-line-formatter wl-summary-mode-line-format wl-summary-mode-line-format-spec-alist) - (wl-summary-detect-mark-position) (setq wl-summary-buffer-persistent (wl-folder-persistent-p (elmo-folder-name-internal folder))) (elmo-folder-set-persistent-internal folder wl-summary-buffer-persistent) @@ -939,7 +940,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (while wl-summary-delayed-update (message "Parent (%d) of message %d is no entity" (caar wl-summary-delayed-update) - (elmo-msgdb-overview-entity-get-number + (elmo-message-entity-number (cdar wl-summary-delayed-update))) (wl-summary-insert-message (cdar wl-summary-delayed-update) @@ -1790,7 +1791,7 @@ If ARG is non-nil, checking is omitted." (if elmo-use-database (elmo-database-msgid-put (car entity) (elmo-folder-name-internal folder) - (elmo-msgdb-overview-entity-get-number entity))) + (elmo-message-entity-number entity))) (when (> num elmo-display-progress-threshold) (setq i (+ i 1)) (if (or (zerop (% i 5)) (= i num)) @@ -1804,7 +1805,7 @@ If ARG is non-nil, checking is omitted." (while wl-summary-delayed-update (message "Parent (%d) of message %d is no entity" (caar wl-summary-delayed-update) - (elmo-msgdb-overview-entity-get-number + (elmo-message-entity-number (cdar wl-summary-delayed-update))) (when (setq update-thread (wl-summary-insert-message @@ -2227,12 +2228,14 @@ If ARG, without confirm." (elmo-folder-name-internal folder)) wl-summary-default-view))) (wl-thread-resume-entity folder) - (wl-summary-open-folder folder)) + (wl-summary-open-folder folder) + (wl-summary-detect-mark-position)) (setq wl-summary-buffer-view (wl-summary-load-file-object (expand-file-name wl-summary-view-file (elmo-folder-msgdb-path folder)))) (wl-summary-open-folder folder) + (wl-summary-detect-mark-position) (wl-summary-rescan)) (wl-summary-count-unread) (wl-summary-update-modeline))) diff --git a/wl/wl-thread.el b/wl/wl-thread.el index d844991..bfb2e5b 100644 --- a/wl/wl-thread.el +++ b/wl/wl-thread.el @@ -640,7 +640,7 @@ ENTITY is returned." ;; don't update buffer update-msgs)))) ; return value -(defun wl-thread-insert-message (overview-entity +(defun wl-thread-insert-message (message-entity msg parent-msg &optional update linked) "Insert MSG to the entity. When optional argument UPDATE is non-nil, @@ -674,7 +674,7 @@ Message is inserted to the summary buffer." ;; visible. (progn (wl-summary-update-thread - overview-entity + message-entity child-entity (elmo-message-entity wl-summary-buffer-elmo-folder parent-msg)) -- 1.7.10.4