/usr/share/emacs/site-lisp/wl/elmo/modb.el is in wl-beta 2.15.9+0.20130701-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | ;;; modb.el --- Message Orchestration DataBase.
;; Copyright (C) 2003 Yuuichi Teranishi <teranisi@gohome.org>
;; Author: Yuuichi Teranishi <teranisi@gohome.org>
;; Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
;; Keywords: mail, net news
;; This file is part of ELMO (Elisp Library for Message Orchestration).
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;;; Commentary:
;;
;;; Code:
;;
(eval-when-compile (require 'cl))
(require 'luna)
(require 'modb-entity)
(eval-and-compile
(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))
(luna-define-generic elmo-msgdb-load (msgdb)
"Load the MSGDB.")
(luna-define-generic elmo-msgdb-save (msgdb)
"Save the MSGDB.")
(luna-define-generic elmo-msgdb-location (msgdb)
"Return the location of MSGDB.")
(luna-define-generic elmo-msgdb-message-modified-p (msgdb)
"Return non-nil if message is modified.")
(luna-define-generic elmo-msgdb-flag-modified-p (msgdb)
"Return non-nil if flag is modified.")
(luna-define-generic elmo-msgdb-append (msgdb msgdb-append)
"Append the MSGDB-APPEND to the MSGDB.
Return a list of messages which have duplicated message-id.")
(luna-define-generic elmo-msgdb-clear (msgdb)
"Clear the MSGDB structure.")
(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.")
(luna-define-generic elmo-msgdb-set-flag (msgdb number flag)
"Set message flag.
MSGDB is the ELMO msgdb.
NUMBER is a message number to set flag.
FLAG is a symbol which is one of the following:
`new' ... Message which is new.
`unread' ... Message which is not read.
`important' ... Message which is important.
`answered' ... Message which is answered.
`cached' ... Message which is cached.
'sugar' flag:
`read' ... Message which is already read.
`uncached' ... Message which is not cached.")
(luna-define-generic elmo-msgdb-unset-flag (msgdb number flag)
"Unset message flag.
MSGDB is the ELMO msgdb.
NUMBER is a message number to set flag.
FLAG is a symbol which is one of the following:
`new' ... Message which is new.
`unread' ... Message which is not read.
`important' ... Message which is important.
`answered' ... Message which is answered.
`cached' ... Message which is cached.
'sugar' flag:
`read' ... Message which is already read.
`uncached' ... Message which is not cached.
`all' ... Remove all flags.")
(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.
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-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.")
(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.")
(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
&optional type)
"Get message field value in the MSGDB.
NUMBER is a number of the message.
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 &optional type)
(elmo-message-entity-field (elmo-msgdb-message-entity msgdb number)
field type))
(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))
t)
(luna-define-method elmo-msgdb-location ((msgdb modb-generic))
(modb-generic-location-internal msgdb))
(luna-define-method elmo-msgdb-message-modified-p ((msgdb modb-generic))
(modb-generic-message-modified-internal msgdb))
(luna-define-method elmo-msgdb-flag-modified-p ((msgdb modb-generic))
(modb-generic-flag-modified-internal msgdb))
(luna-define-method elmo-msgdb-append ((msgdb modb-generic) msgdb-append)
(let (duplicates)
(dolist (number (elmo-msgdb-list-messages msgdb-append))
(when (elmo-msgdb-append-entity
msgdb
(elmo-msgdb-message-entity msgdb-append number)
(elmo-msgdb-flags msgdb-append number))
(setq duplicates (cons number duplicates))))
duplicates))
(luna-define-method elmo-msgdb-clear ((msgdb modb-generic))
(modb-generic-set-message-modified-internal msgdb nil)
(modb-generic-set-flag-modified-internal msgdb nil))
(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-condition-match
condition
#'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
(luna-make-entity modb-entity-default-handler))))
;; for on demand loading
(provide 'modb-generic)
(require 'product)
(product-provide (provide 'modb) (require 'elmo-version))
;;; modb.el ends here
|