From 92d127ffaed6f7904764458cd81821f74f559be0 Mon Sep 17 00:00:00 2001 From: teranisi Date: Thu, 25 Sep 2003 14:29:48 +0000 Subject: [PATCH] * elmo-dop.el (elmo-dop-msgdb): Rewrite. * modb-legacy.el (elmo-msgdb-overview-entity-get-id-internal): New inline function. (elmo-msgdb-overview-entity-get-number-internal): Ditto. (elmo-msgdb-overview-entity-set-number, elmo-msgdb-overview-entity-get-references, elmo-msgdb-overview-entity-set-references, elmo-msgdb-overview-entity-get-from-no-decode, elmo-msgdb-overview-entity-get-from, elmo-msgdb-overview-entity-set-from, elmo-msgdb-overview-entity-get-subject, elmo-msgdb-overview-entity-get-subject-no-decode, elmo-msgdb-overview-entity-set-subject, elmo-msgdb-overview-entity-get-date, elmo-msgdb-overview-entity-set-date, elmo-msgdb-overview-entity-get-to, elmo-msgdb-overview-entity-get-cc, elmo-msgdb-overview-entity-get-size, elmo-msgdb-overview-entity-set-size, elmo-msgdb-overview-entity-get-extra, elmo-msgdb-overview-entity-set-extra, elmo-msgdb-overview-entity-get-extra-field, elmo-msgdb-overview-entity-set-extra-field): Moved to elmo-msgdb.el. (elmo-msgdb-make-index): Use `elmo-msgdb-overview-entity-get-number-internal'. (elmo-msgdb-clear-index): Ditto. (elmo-msgdb-append-entity): Ditto; Use `elmo-msgdb-overview-entity-get-id-internal'. * elmo-msgdb.el (elmo-msgdb-overview-entity-get-number, elmo-msgdb-overview-entity-set-number, elmo-msgdb-overview-entity-get-references, elmo-msgdb-overview-entity-set-references, elmo-msgdb-overview-entity-get-from-no-decode, elmo-msgdb-overview-entity-get-from, elmo-msgdb-overview-entity-set-from, elmo-msgdb-overview-entity-get-subject, elmo-msgdb-overview-entity-get-subject-no-decode, elmo-msgdb-overview-entity-set-subject, elmo-msgdb-overview-entity-get-date, elmo-msgdb-overview-entity-set-date, elmo-msgdb-overview-entity-get-to, elmo-msgdb-overview-entity-get-cc, elmo-msgdb-overview-entity-get-size, elmo-msgdb-overview-entity-set-size, elmo-msgdb-overview-entity-get-extra, elmo-msgdb-overview-entity-set-extra, elmo-msgdb-overview-entity-get-extra-field, elmo-msgdb-overview-entity-set-extra-field): Moved from modb-legacy.el and rewrote for backward compatibility. --- elmo/ChangeLog | 54 ++++++++++++++++++++++++++++ elmo/elmo-dop.el | 36 ++++++++++--------- elmo/elmo-msgdb.el | 66 ++++++++++++++++++++++++++++++++++ elmo/modb-legacy.el | 99 +++++++-------------------------------------------- 4 files changed, 151 insertions(+), 104 deletions(-) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index bd7dfcb..17bda82 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,57 @@ +2003-09-25 Yuuichi Teranishi + + * elmo-dop.el (elmo-dop-msgdb): Rewrite. + + * modb-legacy.el (elmo-msgdb-overview-entity-get-id-internal): New + inline function. + (elmo-msgdb-overview-entity-get-number-internal): Ditto. + (elmo-msgdb-overview-entity-set-number, + elmo-msgdb-overview-entity-get-references, + elmo-msgdb-overview-entity-set-references, + elmo-msgdb-overview-entity-get-from-no-decode, + elmo-msgdb-overview-entity-get-from, + elmo-msgdb-overview-entity-set-from, + elmo-msgdb-overview-entity-get-subject, + elmo-msgdb-overview-entity-get-subject-no-decode, + elmo-msgdb-overview-entity-set-subject, + elmo-msgdb-overview-entity-get-date, + elmo-msgdb-overview-entity-set-date, + elmo-msgdb-overview-entity-get-to, + elmo-msgdb-overview-entity-get-cc, + elmo-msgdb-overview-entity-get-size, + elmo-msgdb-overview-entity-set-size, + elmo-msgdb-overview-entity-get-extra, + elmo-msgdb-overview-entity-set-extra, + elmo-msgdb-overview-entity-get-extra-field, + elmo-msgdb-overview-entity-set-extra-field): Moved to elmo-msgdb.el. + (elmo-msgdb-make-index): Use + `elmo-msgdb-overview-entity-get-number-internal'. + (elmo-msgdb-clear-index): Ditto. + (elmo-msgdb-append-entity): Ditto; + Use `elmo-msgdb-overview-entity-get-id-internal'. + + * elmo-msgdb.el (elmo-msgdb-overview-entity-get-number, + elmo-msgdb-overview-entity-set-number, + elmo-msgdb-overview-entity-get-references, + elmo-msgdb-overview-entity-set-references, + elmo-msgdb-overview-entity-get-from-no-decode, + elmo-msgdb-overview-entity-get-from, + elmo-msgdb-overview-entity-set-from, + elmo-msgdb-overview-entity-get-subject, + elmo-msgdb-overview-entity-get-subject-no-decode, + elmo-msgdb-overview-entity-set-subject, + elmo-msgdb-overview-entity-get-date, + elmo-msgdb-overview-entity-set-date, + elmo-msgdb-overview-entity-get-to, + elmo-msgdb-overview-entity-get-cc, + elmo-msgdb-overview-entity-get-size, + elmo-msgdb-overview-entity-set-size, + elmo-msgdb-overview-entity-get-extra, + elmo-msgdb-overview-entity-set-extra, + elmo-msgdb-overview-entity-get-extra-field, + elmo-msgdb-overview-entity-set-extra-field): Moved from modb-legacy.el + and rewrote for backward compatibility. + 2003-09-24 Hiroya Murata * elmo.el (elmo-message-entity-number, diff --git a/elmo/elmo-dop.el b/elmo/elmo-dop.el index 24ae26a..9094a6d 100644 --- a/elmo/elmo-dop.el +++ b/elmo/elmo-dop.el @@ -348,24 +348,26 @@ FOLDER is the folder structure." (unless (elmo-folder-exists-p folder) (elmo-folder-create folder))) -;;; Util XXX Oh my god... +;;; Util (defun elmo-dop-msgdb (msgdb) - (list (mapcar (function - (lambda (x) - (elmo-message-entity-set-number - x - (* -1 - (elmo-message-entity-number x))))) - (nth 0 msgdb)) - (mapcar (function - (lambda (x) (cons - (* -1 (car x)) - (cdr x)))) - (nth 1 msgdb)) - (mapcar (function - (lambda (x) (cons - (* -1 (car x)) - (cdr x)))) (nth 2 msgdb)))) + (let ((new-db (elmo-make-msgdb)) + entity) + (dolist (dop-entity (mapcar + (lambda (number) + (setq entity (elmo-msgdb-message-entity + msgdb number)) + (elmo-message-entity-set-number + entity + (* -1 (elmo-message-entity-number entity))) + entity) + (elmo-msgdb-list-messages msgdb))) + (elmo-msgdb-append-entity new-db + dop-entity + (elmo-msgdb-flags + msgdb + (abs (elmo-message-entity-number + dop-entity))))) + new-db)) (require 'product) (product-provide (provide 'elmo-dop) (require 'elmo-version)) diff --git a/elmo/elmo-msgdb.el b/elmo/elmo-msgdb.el index 5738329..851ff8d 100644 --- a/elmo/elmo-msgdb.el +++ b/elmo/elmo-msgdb.el @@ -413,6 +413,72 @@ header separator." elmo-msgdb-location-filename dir) alist)) +;;; For backward compatibility. +(defsubst elmo-msgdb-overview-entity-get-number (entity) + (elmo-message-entity-number entity)) + +(defsubst elmo-msgdb-overview-entity-set-number (entity number) + (elmo-message-entity-set-number entity number)) + +(defsubst elmo-msgdb-overview-entity-get-references (entity) + (elmo-message-entity-field entity 'references)) + +(defsubst elmo-msgdb-overview-entity-set-references (entity references) + (elmo-message-entity-set-field entity 'references references)) + +(defsubst elmo-msgdb-overview-entity-get-from-no-decode (entity) + (elmo-message-entity-field entity 'from)) + +(defsubst elmo-msgdb-overview-entity-get-from (entity) + (elmo-message-entity-field entity 'from t)) + +(defsubst elmo-msgdb-overview-entity-set-from (entity from) + (elmo-message-entity-set-field entity 'from from)) + +(defsubst elmo-msgdb-overview-entity-get-subject (entity) + (elmo-message-entity-field entity 'subject t)) + +(defsubst elmo-msgdb-overview-entity-get-subject-no-decode (entity) + (elmo-message-entity-field entity 'subject)) + +(defsubst elmo-msgdb-overview-entity-set-subject (entity subject) + (elmo-message-entity-set-field entity 'subject subject)) + +(defsubst elmo-msgdb-overview-entity-get-date (entity) + (elmo-message-entity-field entity 'date)) + +(defsubst elmo-msgdb-overview-entity-set-date (entity date) + (elmo-message-entity-set-field entity 'date date)) + +(defsubst elmo-msgdb-overview-entity-get-to (entity) + (elmo-message-entity-field entity 'to)) + +(defsubst elmo-msgdb-overview-entity-get-cc (entity) + (elmo-message-entity-field entity 'cc)) + +(defsubst elmo-msgdb-overview-entity-get-size (entity) + (elmo-message-entity-field entity 'size)) + +(defsubst elmo-msgdb-overview-entity-set-size (entity size) + (elmo-message-entity-set-field entity 'size size)) + +(defsubst elmo-msgdb-overview-entity-get-extra (entity) + ;; Truely obsolete. + ) + +(defsubst elmo-msgdb-overview-entity-set-extra (entity extra) + ;; Truely obsolete. + ) + +(defsubst elmo-msgdb-overview-entity-get-extra-field (entity + field-name) + (elmo-message-entity-field entity (intern field-name))) + +(defsubst elmo-msgdb-overview-entity-set-extra-field (entity + field-name + value) + (elmo-message-entity-set-field entity (intern field-name) value)) + (require 'product) (product-provide (provide 'elmo-msgdb) (require 'elmo-version)) diff --git a/elmo/modb-legacy.el b/elmo/modb-legacy.el index a804025..5aa69a0 100644 --- a/elmo/modb-legacy.el +++ b/elmo/modb-legacy.el @@ -104,90 +104,12 @@ ;;; ;; Internal use only (obsolete interface) ;; -(defsubst elmo-msgdb-overview-entity-get-id (entity) +(defsubst elmo-msgdb-overview-entity-get-id-internal (entity) (and entity (car entity))) -(defsubst elmo-msgdb-overview-entity-get-number (entity) +(defsubst elmo-msgdb-overview-entity-get-number-internal (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 @@ -326,7 +248,7 @@ Return a list of message numbers which have duplicated message-ids." ;; key is message-id (if (elmo-get-hash-val (caar overview) ehash) ; duplicated. (setq duplicates (cons - (elmo-msgdb-overview-entity-get-number + (elmo-msgdb-overview-entity-get-number-internal (car overview)) duplicates))) (if (caar overview) @@ -334,7 +256,8 @@ Return a list of message numbers which have duplicated message-ids." ;; key is number (elmo-set-hash-val (format "#%d" - (elmo-msgdb-overview-entity-get-number (car overview))) + (elmo-msgdb-overview-entity-get-number-internal + (car overview))) (car overview) ehash) (setq overview (cdr overview))) (while mark-alist @@ -352,12 +275,14 @@ Return a list of message numbers which have duplicated message-ids." (mhash (elmo-msgdb-get-mark-hashtb msgdb)) number) (when (and entity ehash) - (and (setq number (elmo-msgdb-overview-entity-get-number entity)) + (and (setq number (elmo-msgdb-overview-entity-get-number-internal + entity)) (elmo-clear-hash-val (format "#%d" number) ehash)) (and (car entity) ;; message-id (elmo-clear-hash-val (car entity) ehash))) (when (and entity mhash) - (and (setq number (elmo-msgdb-overview-entity-get-number entity)) + (and (setq number (elmo-msgdb-overview-entity-get-number-internal + entity)) (elmo-clear-hash-val (format "#%d" number) mhash))))) ;;; Implement @@ -481,7 +406,7 @@ Return a list of message numbers which have duplicated message-ids." (elmo-msgdb-set-mark msgdb number new-mark)))))) (luna-define-method elmo-msgdb-list-messages ((msgdb modb-legacy)) - (mapcar 'elmo-msgdb-overview-entity-get-number + (mapcar 'elmo-msgdb-overview-entity-get-number-internal (elmo-msgdb-get-overview msgdb))) (luna-define-method elmo-msgdb-list-flagged ((msgdb modb-legacy) flag) @@ -556,8 +481,8 @@ Return a list of message numbers which have duplicated message-ids." (luna-define-method elmo-msgdb-append-entity ((msgdb modb-legacy) entity &optional flags) (when entity - (let ((number (elmo-msgdb-overview-entity-get-number entity)) - (message-id (elmo-msgdb-overview-entity-get-id entity)) + (let ((number (elmo-msgdb-overview-entity-get-number-internal entity)) + (message-id (elmo-msgdb-overview-entity-get-id-internal entity)) mark) (elmo-msgdb-set-overview msgdb -- 1.7.10.4