X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=elmo%2Fmodb.el;h=6574e63f1efb0cd41b23e069a3f414bdadd91aa4;hb=fceaa7d966c72630d1b8b146ae0414b4d144a8c6;hp=aa42d4cc74fb2d291a63dd2150934fa8380e18ec;hpb=65f449524687f7f37c579ae142aab0f067400a05;p=elisp%2Fwanderlust.git diff --git a/elmo/modb.el b/elmo/modb.el index aa42d4c..6574e63 100644 --- a/elmo/modb.el +++ b/elmo/modb.el @@ -36,9 +36,10 @@ (require 'modb-entity) (eval-and-compile - (luna-define-class modb-generic () (location ; location for save. + (luna-define-class modb-generic () (location ; location for save. message-modified ; message is modified. flag-modified ; flag is modified. + mime-charset ; for encode & decode. )) (luna-define-internal-accessors 'modb-generic)) @@ -134,6 +135,10 @@ Return CONDITION itself if no entity exists in msgdb.") "Append a ENTITY with FLAGS into the MSGDB. Return non-nil if message-id of entity is duplicated.") +(luna-define-generic elmo-msgdb-update-entity (msgdb entity values) + "Update a ENTITY with VALUES into the MSGDB. +VALUES is an alist of field-name and field-value.") + (luna-define-generic elmo-msgdb-delete-messages (msgdb numbers) "Delete messages which are contained NUMBERS from MSGDB. Return non-nil if messages is deleted successfully.") @@ -158,15 +163,17 @@ 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) +(luna-define-generic elmo-msgdb-message-field (msgdb number field + &optional type) "Get message field value in the MSGDB. NUMBER is a number of the message. -FIELD is a symbol of the field.") +FIELD is a symbol of the field. +If optional argument TYPE is specified, return converted value.") (luna-define-method elmo-msgdb-message-field ((msgdb modb-generic) - number field) + number field &optional type) (elmo-message-entity-field (elmo-msgdb-message-entity msgdb number) - field)) + field type)) (luna-define-generic elmo-msgdb-message-entity-handler (msgdb) "Get modb entity handler instance which corresponds to the MSGDB.") @@ -212,14 +219,51 @@ FIELD is a symbol of the field.") &optional numbers) (let ((entity (elmo-msgdb-message-entity msgdb number))) (if entity - (elmo-msgdb-message-match-condition - (elmo-msgdb-message-entity-handler msgdb) + (elmo-condition-match condition - entity - (elmo-msgdb-flags msgdb number) - (or numbers (elmo-msgdb-list-messages msgdb))) + #'elmo-msgdb-match-condition-primitive + (list msgdb number entity + (or numbers (elmo-msgdb-list-messages msgdb)))) condition))) +(defun elmo-msgdb-match-condition-primitive (condition msgdb number entity + population) + (let ((key (elmo-filter-key condition)) + (case-fold-search t)) + (cond + ((string= key "last") + (<= (length (memq number population)) + (string-to-number (elmo-filter-value condition)))) + ((string= key "first") + (< (- (length population) + (length (memq number population))) + (string-to-number (elmo-filter-value condition)))) + ((string= key "flag") + (let ((flags (elmo-msgdb-flags msgdb number))) + (cond ((string= (elmo-filter-value condition) "any") + (and flags (not (equal flags '(cached))))) + ((string= (elmo-filter-value condition) "digest") + (catch 'found + (dolist (flag flags) + (when (or (memq flag elmo-digest-flags) + (elmo-global-flag-p flag)) + (throw 'found t))))) + ((string= (elmo-filter-value condition) "read") + (not (memq 'read flags))) + (t + (memq (intern (elmo-filter-value condition)) flags))))) + (t + (elmo-msgdb-message-match-condition (elmo-message-entity-handler entity) + condition entity))))) + +(luna-define-method elmo-msgdb-update-entity ((msgdb modb-generic) + entity values) + (when (elmo-msgdb-message-entity-update-fields + (elmo-message-entity-handler entity) + entity values) + (modb-generic-set-message-modified-internal msgdb t) + t)) + (luna-define-method elmo-msgdb-message-entity-handler ((msgdb modb-generic)) (or modb-entity-default-cache-internal (setq modb-entity-default-cache-internal