From: teranisi Date: Sun, 12 Sep 2004 08:41:37 +0000 (+0000) Subject: * modb.el (elmo-msgdb-flag-available-p): New generic function. X-Git-Tag: wl-2_12-root~124 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65f449524687f7f37c579ae142aab0f067400a05;p=elisp%2Fwanderlust.git * modb.el (elmo-msgdb-flag-available-p): New generic function. (elmo-msgdb-message-number): Ditto. (elmo-msgdb-message-field): Ditto. * modb-standard.el (modb-standard-economize-entity-size): New user option. (modb-standard-loaded-message-id): New inline function. (modb-standard-load-entity): Use it. (modb-standard-save-entity-1): If `modb-standard-economize-entity-size', throw message-id string away. (elmo-msgdb-flag-available-p): Define. (elmo-msgdb-message-number): Ditto. (elmo-msgdb-message-field): Ditto. * modb-legacy.el (modb-legacy-flag-list): Fix typo (suppoted -> supported). (modb-legacy-supported-flag-p): Ditto. (elmo-msgdb-set-flag): Ditto. (elmo-msgdb-unset-flag): Ditto. (elmo-msgdb-flag-available-p): Define. * modb-entity.el (elmo-message-entity-handler): If CAR element of entity is `t', treat it as legacy entity. * elmo.el (elmo-message-flag-available-p): New generic function. (elmo-message-number): Ditto. (elmo-message-field): Use `elmo-msgdb-message-field'. * elmo-vars.el (elmo-preserved-flags): Added `forwarded'. * elmo-pipe.el (elmo-message-flag-available-p): Define. (elmo-message-number): Ditto. * elmo-multi.el (elmo-message-number): Define. (elmo-message-flag-available-p): Ditto. * elmo-filter.el (elmo-message-flag-available-p): Define. (elmo-message-number): Ditto. * elmo-flag.el (elmo-flag-folder): Added slot `max-number'. (elmo-folder-initialize): Load `max-number'. (elmo-folder-commit): Save it. (elmo-folder-list-global-flag-messages): Use `elmo-message-number'. (elmo-global-flag-set-internal): Set up max-number slot. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 297a630..35a87a0 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,5 +1,52 @@ 2004-09-12 Yuuichi Teranishi + * modb.el (elmo-msgdb-flag-available-p): New generic function. + (elmo-msgdb-message-number): Ditto. + (elmo-msgdb-message-field): Ditto. + + * modb-standard.el (modb-standard-economize-entity-size): New user + option. + (modb-standard-loaded-message-id): New inline function. + (modb-standard-load-entity): Use it. + (modb-standard-save-entity-1): If `modb-standard-economize-entity-size', + throw message-id string away. + (elmo-msgdb-flag-available-p): Define. + (elmo-msgdb-message-number): Ditto. + (elmo-msgdb-message-field): Ditto. + + * modb-legacy.el (modb-legacy-flag-list): Fix typo + (suppoted -> supported). + (modb-legacy-supported-flag-p): Ditto. + (elmo-msgdb-set-flag): Ditto. + (elmo-msgdb-unset-flag): Ditto. + (elmo-msgdb-flag-available-p): Define. + + * modb-entity.el (elmo-message-entity-handler): If CAR element of entity + is `t', treat it as legacy entity. + + * elmo.el (elmo-message-flag-available-p): New generic function. + (elmo-message-number): Ditto. + (elmo-message-field): Use `elmo-msgdb-message-field'. + + * elmo-vars.el (elmo-preserved-flags): Added `forwarded'. + + * elmo-pipe.el (elmo-message-flag-available-p): Define. + (elmo-message-number): Ditto. + + * elmo-multi.el (elmo-message-number): Define. + (elmo-message-flag-available-p): Ditto. + + * elmo-filter.el (elmo-message-flag-available-p): Define. + (elmo-message-number): Ditto. + + * elmo-flag.el (elmo-flag-folder): Added slot `max-number'. + (elmo-folder-initialize): Load `max-number'. + (elmo-folder-commit): Save it. + (elmo-folder-list-global-flag-messages): Use `elmo-message-number'. + (elmo-global-flag-set-internal): Set up max-number slot. + +2004-09-12 Yuuichi Teranishi + * elmo-version.el (elmo-version): Up to 2.11.31. 2004-09-09 Yuuichi Teranishi diff --git a/elmo/elmo-filter.el b/elmo/elmo-filter.el index 9a6c3ce..c9b33c6 100644 --- a/elmo/elmo-filter.el +++ b/elmo/elmo-filter.el @@ -307,6 +307,13 @@ (elmo-message-file-name (elmo-filter-folder-target-internal folder) number)) +(luna-define-method elmo-message-flag-available-p ((folder + elmo-filter-folder) number + flag) + (elmo-message-flag-available-p + (elmo-filter-folder-target-internal folder) + number flag)) + (luna-define-method elmo-message-flags ((folder elmo-filter-folder) number &optional msgid) (elmo-message-flags (elmo-filter-folder-target-internal folder) @@ -317,6 +324,11 @@ (elmo-message-set-cached (elmo-filter-folder-target-internal folder) number cached)) +(luna-define-method elmo-message-number ((folder elmo-filter-folder) + message-id) + (elmo-message-number (elmo-filter-folder-target-internal folder) + message-id)) + (luna-define-method elmo-message-entity ((folder elmo-filter-folder) key) (elmo-message-entity (elmo-filter-folder-target-internal folder) key)) diff --git a/elmo/elmo-flag.el b/elmo/elmo-flag.el index 13c71f2..86a8505 100644 --- a/elmo/elmo-flag.el +++ b/elmo/elmo-flag.el @@ -40,7 +40,7 @@ (eval-and-compile (luna-define-class elmo-flag-folder (elmo-localdir-folder) - (flag minfo minfo-hash)) + (flag minfo minfo-hash max-number)) (luna-define-internal-accessors 'elmo-flag-folder)) (luna-define-method elmo-folder-initialize ((folder @@ -69,6 +69,10 @@ (elmo-localdir-folder-set-directory-internal folder msgdb-path) + (if (file-exists-p (expand-file-name "max" msgdb-path)) + (elmo-flag-folder-set-max-number-internal + folder + (elmo-object-load (expand-file-name "max" msgdb-path)))) (if (file-exists-p (expand-file-name ".minfo" msgdb-path)) (elmo-flag-folder-set-minfo-internal folder @@ -101,7 +105,11 @@ elmo-flag-folder)) (elmo-object-save (expand-file-name ".minfo" (elmo-folder-msgdb-path folder)) - (elmo-flag-folder-minfo-internal folder))) + (elmo-flag-folder-minfo-internal folder)) + (if (elmo-flag-folder-max-number-internal folder) + (elmo-object-save + (expand-file-name "max" (elmo-folder-msgdb-path folder)) + (elmo-flag-folder-max-number-internal folder)))) (luna-define-method elmo-folder-list-subfolders ((folder elmo-flag-folder) &optional one-level) @@ -245,11 +253,10 @@ FOLDER is the elmo folder structure. FLAG is the symbol of the flag." (when (elmo-global-flag-p flag) (let ((flag-folder (elmo-flag-get-folder flag)) - result entity) + result number) (dolist (elem (elmo-flag-folder-minfo-internal flag-folder)) - (if (setq entity (elmo-message-entity folder (nth 1 elem))) - (setq result (cons (elmo-message-entity-number entity) - result)))) + (if (setq number (elmo-message-number folder (nth 1 elem))) + (setq result (cons number result)))) result))) ;;; @@ -287,10 +294,17 @@ NUMBER is the message number." (elmo-flag-folder-minfo-hash-internal flag-folder))) ;; Append new element. + (elmo-flag-folder-set-max-number-internal + flag-folder + (+ (or (elmo-flag-folder-max-number-internal flag-folder) + ;; This is the first time. + (car (elmo-folder-status flag-folder))) + 1)) (setq new-file (expand-file-name (int-to-string - (setq new-number (1+ (car (elmo-folder-status flag-folder))))) + (setq new-number + (elmo-flag-folder-max-number-internal flag-folder))) (elmo-localdir-folder-directory-internal flag-folder))) (with-temp-buffer (setq cache (and message-id (elmo-file-cache-get message-id))) diff --git a/elmo/elmo-multi.el b/elmo/elmo-multi.el index ac108fe..3df09b0 100644 --- a/elmo/elmo-multi.el +++ b/elmo/elmo-multi.el @@ -154,6 +154,16 @@ (car pair) (elmo-message-entity (car pair) (cdr pair)) ignore-cache))) +(luna-define-method elmo-message-number ((folder elmo-multi-folder) + message-id) + (let ((children (elmo-multi-folder-children-internal folder)) + match) + (while children + (when (setq match (elmo-message-number (car children) message-id)) + (setq children nil)) + (setq children (cdr children))) + match)) + (luna-define-method elmo-message-entity ((folder elmo-multi-folder) key) (cond ((numberp key) @@ -190,6 +200,12 @@ (let ((pair (elmo-multi-real-folder-number folder number))) (elmo-message-field (car pair) (cdr pair) field))) +(luna-define-method elmo-message-flag-available-p ((folder + elmo-multi-folder) number + flag) + (let ((pair (elmo-multi-real-folder-number folder number))) + (elmo-message-flag-available-p (car pair) (cdr pair) flag))) + (luna-define-method elmo-message-flags ((folder elmo-multi-folder) number &optional msgid) (let ((pair (elmo-multi-real-folder-number folder number))) diff --git a/elmo/elmo-pipe.el b/elmo/elmo-pipe.el index fd8b9a4..a6bddd3 100644 --- a/elmo/elmo-pipe.el +++ b/elmo/elmo-pipe.el @@ -332,6 +332,12 @@ (luna-define-method elmo-folder-length ((folder elmo-pipe-folder)) (elmo-folder-length (elmo-pipe-folder-dst-internal folder))) +(luna-define-method elmo-message-flag-available-p ((folder elmo-pipe-folder) + number flag) + (elmo-message-flag-available-p + (elmo-pipe-folder-dst-internal folder) + number flag)) + (luna-define-method elmo-folder-count-flags ((folder elmo-pipe-folder)) (elmo-folder-count-flags (elmo-pipe-folder-dst-internal folder))) @@ -358,6 +364,11 @@ (elmo-message-entity-number entity)) ignore-cache)) +(luna-define-method elmo-message-number ((folder elmo-pipe-folder) + message-id) + (elmo-message-number (elmo-pipe-folder-dst-internal folder) + message-id)) + (luna-define-method elmo-message-entity ((folder elmo-pipe-folder) key) (elmo-message-entity (elmo-pipe-folder-dst-internal folder) key)) diff --git a/elmo/elmo-vars.el b/elmo/elmo-vars.el index 0e887af..f6dd981 100644 --- a/elmo/elmo-vars.el +++ b/elmo/elmo-vars.el @@ -62,7 +62,7 @@ :type '(repeat (symbol :tag "flag")) :group 'elmo) -(defcustom elmo-preserved-flags '(answered cached new unread) +(defcustom elmo-preserved-flags '(forwarded answered cached new unread) "Reserved flags which are not treated as global." :type '(repeat (symbol :tag "flag")) :group 'elmo) diff --git a/elmo/elmo.el b/elmo/elmo.el index 1851371..20a8b25 100644 --- a/elmo/elmo.el +++ b/elmo/elmo.el @@ -370,6 +370,9 @@ FLAG is a symbol which is one of the following: `all' (remove all flags) If optional IS-LOCAL is non-nil, update only local (not server) status.") +(luna-define-generic elmo-message-flag-available-p (folder number flag) + "Return non-nil when a message in the FOLDER with NUMBER treats FLAG.") + (luna-define-generic elmo-folder-next-message-number (folder) "The next message number that will be assigned to a new message. FOLDER is the ELMO folder structure.") @@ -462,6 +465,10 @@ NUMBER is a number of the message. If optional argument MSGID is specified, the message with NUMBER checks whether it has MSGID.") +(luna-define-method elmo-message-flag-available-p ((folder elmo-folder) number + flag) + (elmo-msgdb-flag-available-p (elmo-folder-msgdb folder) flag)) + (luna-define-method elmo-message-flags ((folder elmo-folder) number &optional msgid) (if msgid @@ -1150,6 +1157,12 @@ If CACHED is t, message is set as cached.") (elmo-msgdb-copy-message-entity (elmo-message-entity-handler entity) entity)) +(luna-define-generic elmo-message-number (folder message-id) + "Get message number from MSGDB which corresponds to MESSAGE-ID.") + +(luna-define-method elmo-message-number ((folder elmo-folder) message-id) + (elmo-msgdb-message-number (elmo-folder-msgdb folder) message-id)) + (luna-define-generic elmo-message-entity (folder key) "Return the message-entity structure which matches to the KEY. KEY is a number or a string. @@ -1232,7 +1245,7 @@ NUMBER is a number of the message. FIELD is a symbol of the field.") (luna-define-method elmo-message-field ((folder elmo-folder) number field) - (elmo-message-entity-field (elmo-message-entity folder number) field)) + (elmo-msgdb-message-field (elmo-folder-msgdb folder) number field)) (luna-define-generic elmo-message-set-field (folder number field value) "Set message field value in the msgdb. diff --git a/elmo/modb-entity.el b/elmo/modb-entity.el index b0a52d6..b65594a 100644 --- a/elmo/modb-entity.el +++ b/elmo/modb-entity.el @@ -49,6 +49,7 @@ "Get modb entity handler instance which corresponds to the ENTITY." (if (and entity (car-safe entity) + (not (eq (car entity) t)) (not (stringp (car entity)))) (car entity) (or modb-entity-default-cache-internal diff --git a/elmo/modb-legacy.el b/elmo/modb-legacy.el index 161c0b0..b5b00ec 100644 --- a/elmo/modb-legacy.el +++ b/elmo/modb-legacy.el @@ -61,7 +61,7 @@ (defconst modb-legacy-flag-list '(new unread important answered cached read uncached) - "A list of flag symbol which is suppoted by legacy msgdb.") + "A list of flag symbol which is supported by legacy msgdb.") (eval-and-compile (luna-define-class modb-legacy (modb-generic) @@ -144,7 +144,7 @@ ;;; -(defsubst modb-legacy-suppoted-flag-p (flag) +(defsubst modb-legacy-supported-flag-p (flag) (memq flag modb-legacy-flag-list)) (defvar modb-legacy-unread-marks-internal nil) @@ -364,12 +364,15 @@ Return a list of message numbers which have duplicated message-ids." (luna-define-method elmo-msgdb-length ((msgdb modb-legacy)) (length (modb-legacy-overview-internal msgdb))) +(luna-define-method elmo-msgdb-flag-available-p ((msgdb modb-legacy) flag) + (modb-legacy-supported-flag-p flag)) + (luna-define-method elmo-msgdb-flags ((msgdb modb-legacy) number) (modb-legacy-mark-to-flags (elmo-msgdb-get-mark msgdb number))) (luna-define-method elmo-msgdb-set-flag ((msgdb modb-legacy) number flag) - (unless (modb-legacy-suppoted-flag-p flag) + (unless (modb-legacy-supported-flag-p flag) (error "Flag `%s' is not supproted by this msgdb type" (capitalize (symbol-name flag)))) (case flag @@ -394,7 +397,7 @@ Return a list of message numbers which have duplicated message-ids." (luna-define-method elmo-msgdb-unset-flag ((msgdb modb-legacy) number flag) - (unless (modb-legacy-suppoted-flag-p flag) + (unless (modb-legacy-supported-flag-p flag) (error "Flag `%s' is not supproted by this msgdb type" (capitalize (symbol-name flag)))) (case flag diff --git a/elmo/modb-standard.el b/elmo/modb-standard.el index 0f90e29..53d7b2f 100644 --- a/elmo/modb-standard.el +++ b/elmo/modb-standard.el @@ -40,6 +40,12 @@ number) :group 'elmo) +(defcustom modb-standard-economize-entity-size nil + "*Economize message entity size. +When non-nil, redundunt message-id string are not saved." + :type 'boolean + :group 'elmo) + (defvar modb-standard-entity-filename "entity" "Message entity database.") @@ -169,24 +175,40 @@ (number-to-string section)) modb-standard-entity-filename)) +(defsubst modb-standard-loaded-message-id (msgdb number) + "Get message-id for autoloaded entity." + (let ((ret (elmo-get-hash-val + (modb-standard-key number) + (modb-standard-entity-map-internal msgdb)))) + (cond + ((and ret (eq (car-safe ret) 'autoload)) + (cdr (cdr ret))) ; message-id. + ((and ret (stringp (car-safe ret))) + ;; Already loaded. + (car ret)) + ((null ret) + ;; Garbage entity. + (elmo-clear-hash-val (modb-standard-key number) + (modb-standard-entity-map-internal msgdb))) + (t (error "Internal error: invalid msgdb status"))))) + (defun modb-standard-load-entity (modb path &optional section) (let ((table (or (modb-standard-entity-map-internal modb) - (elmo-make-hash (elmo-msgdb-length modb))))) + (elmo-make-hash (elmo-msgdb-length modb)))) + (inhibit-quit t) + number msgid) (dolist (entity (elmo-object-load (expand-file-name (modb-standard-entity-filename section) path))) - (elmo-set-hash-val (modb-standard-key - (elmo-msgdb-message-entity-number - (elmo-message-entity-handler entity) - entity)) - entity - table) - (elmo-set-hash-val (elmo-msgdb-message-entity-field - (elmo-message-entity-handler entity) - entity 'message-id) - entity - table)) + (setq number (elmo-msgdb-message-entity-number + (elmo-message-entity-handler entity) + entity) + msgid (modb-standard-loaded-message-id modb number)) + (when msgid + (setcar entity msgid) + (elmo-set-hash-val msgid entity table) + (elmo-set-hash-val (modb-standard-key number) entity table))) (modb-standard-set-entity-map-internal modb table))) (defsubst modb-standard-save-entity-1 (modb path &optional section) @@ -198,6 +220,8 @@ (when (and (or (null section) (= section (/ number modb-standard-divide-number))) (setq entity (elmo-msgdb-message-entity modb number))) + (when modb-standard-economize-entity-size + (when (stringp (car entity)) (setcar entity t))) (setq entities (cons entity entities)))) (if entities (elmo-object-save filename entities) @@ -283,6 +307,9 @@ (luna-define-method elmo-msgdb-length ((msgdb modb-standard)) (length (modb-standard-number-list-internal msgdb))) +(luna-define-method elmo-msgdb-flag-available-p ((msgdb modb-standard) flag) + t) + (luna-define-method elmo-msgdb-flags ((msgdb modb-standard) number) (modb-standard-message-flags msgdb number)) @@ -502,6 +529,28 @@ (modb-standard-message-entity msgdb key nil)) ret))) +(luna-define-method elmo-msgdb-message-number ((msgdb modb-standard) + message-id) + (let ((ret (elmo-get-hash-val + message-id + (modb-standard-entity-map-internal msgdb)))) + (if (eq 'autoload (car-safe ret)) + ;; Not loaded yet but can return number. + (nth 1 ret) + (elmo-message-entity-number ret)))) + +(luna-define-method elmo-msgdb-message-field ((msgdb modb-standard) + number field) + (let ((ret (elmo-get-hash-val + (modb-standard-key number) + (modb-standard-entity-map-internal msgdb)))) + (if (and (eq 'autoload (car-safe ret)) (eq field 'message-id)) + ;; Not loaded yet but can return message-id + (cdr (cdr ret)) + (elmo-message-entity-field (elmo-msgdb-message-entity + msgdb (modb-standard-key number)) + field)))) + (luna-define-method elmo-msgdb-message-entity ((msgdb modb-standard) key) (when key (modb-standard-message-entity diff --git a/elmo/modb.el b/elmo/modb.el index 9d5c9af..aa42d4c 100644 --- a/elmo/modb.el +++ b/elmo/modb.el @@ -67,6 +67,9 @@ Return a list of messages which have duplicated message-id.") (luna-define-generic elmo-msgdb-length (msgdb) "Return number of messages in the MSGDB") +(luna-define-generic elmo-msgdb-flag-available-p (msgdb flag) + "Return non-nil when FLAG is available.") + (luna-define-generic elmo-msgdb-flags (msgdb number) "Return a list of flag which corresponds to the message with NUMBER.") @@ -141,12 +144,30 @@ Return non-nil if messages is deleted successfully.") PREDICATE is called with two entities and APP-DATA. Should return non-nil if the first entity is \"less\" than the second.") +(luna-define-generic elmo-msgdb-message-number (msgdb message-id) + "Get message number from MSGDB which corresponds to MESSAGE-ID.") + +(luna-define-method elmo-msgdb-message-number ((msgdb modb-generic) + message-id) + (elmo-message-entity-number + (elmo-msgdb-message-entity msgdb message-id))) + (luna-define-generic elmo-msgdb-message-entity (msgdb key) "Return the message-entity structure which matches to the KEY. 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.") +(luna-define-generic elmo-msgdb-message-field (msgdb number field) + "Get message field value in the MSGDB. +NUMBER is a number of the message. +FIELD is a symbol of the field.") + +(luna-define-method elmo-msgdb-message-field ((msgdb modb-generic) + number field) + (elmo-message-entity-field (elmo-msgdb-message-entity msgdb number) + field)) + (luna-define-generic elmo-msgdb-message-entity-handler (msgdb) "Get modb entity handler instance which corresponds to the MSGDB.")