(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 <teranisi@gohome.org>
+ * 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 <teranisi@gohome.org>
+
* elmo-version.el (elmo-version): Up to 2.11.31.
2004-09-09 Yuuichi Teranishi <teranisi@gohome.org>
(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)
(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))
(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
(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
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)
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)))
;;;
(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)))
(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)
(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)))
(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)))
(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))
: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)
`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.")
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
(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.
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.
"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
(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)
;;;
-(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)
(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
(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
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.")
(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)
(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)
(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))
(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
(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.")
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.")