X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=elmo%2Fmodb.el;h=b42261e4912038d7539d88adf255ac67b1efa2c7;hb=e2aea74a5cc8c8cd177a7597808e7697d8db591f;hp=7dd27822f8ec32fdc5f26cf016c105156e158af2;hpb=c2738fdc4e616fb55973a7e285432f60af6c1c57;p=elisp%2Fwanderlust.git diff --git a/elmo/modb.el b/elmo/modb.el index 7dd2782..b42261e 100644 --- a/elmo/modb.el +++ b/elmo/modb.el @@ -33,6 +33,7 @@ (eval-when-compile (require 'cl)) (require 'luna) +(require 'modb-entity) (eval-and-compile (luna-define-class modb-generic () (location ; location for save. @@ -91,27 +92,44 @@ FLAG is a symbol which is one of the following: `answered' ... Message which is answered. `cached' ... Message which is cached.") +(luna-define-generic elmo-msgdb-flag-count (msgdb) + "Return a list of cons cell as (flag . count). +The count is number of message which is set flag in the MSGDB.") + (luna-define-generic elmo-msgdb-list-messages (msgdb) "Return a list of message numbers in the MSGDB.") (luna-define-generic elmo-msgdb-list-flagged (msgdb flag) "Return a list of message numbers which is set FLAG in the MSGDB.") -;;; (luna-define-generic elmo-msgdb-search (msgdb condition &optional numbers) -;;; "Search and return list of message numbers. -;;; MSGDB is the ELMO msgdb structure. -;;; CONDITION is a condition structure for searching. -;;; If optional argument NUMBERS is specified and is a list of message numbers, -;;; messages are searched from the list.") +(luna-define-generic elmo-msgdb-search (msgdb condition &optional numbers) + "Search and return list of message numbers. +MSGDB is the ELMO msgdb structure. +CONDITION is a condition structure for searching. +If optional argument NUMBERS is specified and is a list of message numbers, +messages are searched from the list. +Return t if the condition is unsupported.") + +(luna-define-generic elmo-msgdb-match-condition (msgdb condition number + &optional numbers) + "Check whether the condition of the message is satisfied or not. +MSGDB is the msgdb to search from. +CONDITION is the search condition. +NUMBER is the message number to check. +If optional argument NUMBERS is specified and is a list of message numbers, +messages are searched from the list. +Return CONDITION itself if no entity exists in msgdb.") (luna-define-generic elmo-msgdb-append-entity (msgdb entity &optional flags) "Append a ENTITY with FLAGS into the MSGDB. 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.") + "Delete messages which are contained NUMBERS from MSGDB. +Return non-nil if messages is deleted successfully.") -(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 +140,9 @@ 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-entity-handler (msgdb) + "Get modb entity handler instance which corresponds to the MSGDB.") + ;;; generic implement ;; (luna-define-method elmo-msgdb-load ((msgdb modb-generic)) @@ -153,6 +174,29 @@ A string is for message-id of the message.") (luna-define-method elmo-msgdb-length ((msgdb modb-generic)) 0) +(luna-define-method elmo-msgdb-search ((msgdb modb-generic) + condition &optional numbers) + t) + +(luna-define-method elmo-msgdb-match-condition ((msgdb modb-generic) + condition + number + &optional numbers) + (let ((entity (elmo-msgdb-message-entity msgdb number))) + (if entity + (elmo-msgdb-message-match-condition + (elmo-msgdb-message-entity-handler msgdb) + condition + entity + (elmo-msgdb-flags msgdb number) + (or numbers (elmo-msgdb-list-messages msgdb))) + condition))) + +(luna-define-method elmo-msgdb-message-entity-handler ((msgdb modb-generic)) + (or modb-entity-default-cache-internal + (setq modb-entity-default-cache-internal + (luna-make-entity modb-entity-default-handler)))) + ;; for on demand loading (provide 'modb-generic)