]> code.delx.au - gnu-emacs/blob - lisp/net/eudc-vars.el
Merge from origin/emacs-24
[gnu-emacs] / lisp / net / eudc-vars.el
1 ;;; eudc-vars.el --- Emacs Unified Directory Client -*- coding: utf-8 -*-
2
3 ;; Copyright (C) 1998-2015 Free Software Foundation, Inc.
4
5 ;; Author: Oscar Figueiredo <oscar@cpe.fr>
6 ;; Pavel Janík <Pavel@Janik.cz>
7 ;; Maintainer: Thomas Fitzsimmons <fitzsim@fitzsim.org>
8 ;; Keywords: comm
9 ;; Package: eudc
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (require 'custom)
31
32 ;;{{{ EUDC Main Custom Group
33
34 (defgroup eudc nil
35 "Emacs Unified Directory Client."
36 :version "21.1"
37 :link '(info-link "(eudc)")
38 :group 'mail
39 :group 'comm)
40
41 (defcustom eudc-server nil
42 "The name or IP address of the directory server.
43 A port number may be specified by appending a colon and a
44 number to the name of the server. Use `localhost' if the directory
45 server resides on your computer (BBDB backend).
46
47 To specify multiple servers, customize eudc-server-hotlist
48 instead."
49 :type '(choice (string :tag "Server") (const :tag "None" nil)))
50
51 ;; Known protocols (used in completion)
52 ;; Not to be mistaken with `eudc-supported-protocols'
53 (defvar eudc-known-protocols '(bbdb ph ldap))
54
55 (defcustom eudc-server-hotlist nil
56 "Directory servers to query.
57 This is an alist of the form (SERVER . PROTOCOL). SERVER is the
58 host name or URI of the server, PROTOCOL is a symbol representing
59 the EUDC backend with which to access the server.
60
61 The BBDB backend ignores SERVER; `localhost' can be used as a
62 placeholder string."
63 :tag "Directory Servers to Query"
64 :type `(repeat (cons :tag "Directory Server"
65 (string :tag "Server Host Name or URI")
66 (choice :tag "Protocol"
67 :menu-tag "Protocol"
68 ,@(mapcar (lambda (s)
69 (list 'const
70 ':tag (symbol-name s) s))
71 eudc-known-protocols)
72 (const :tag "None" nil))))
73 :version "25.1")
74
75 (defvar eudc-supported-protocols nil
76 "Protocols currently supported by EUDC.
77 This variable is updated when protocol-specific libraries
78 are loaded, *do not change manually*.")
79
80 (defcustom eudc-protocol nil
81 "The directory protocol to use to query the server.
82 Supported protocols are specified by `eudc-supported-protocols'."
83 :type `(choice :menu-tag "Protocol"
84 ,@(mapcar (lambda (s)
85 (list 'const ':tag (symbol-name s) s))
86 eudc-known-protocols)
87 (const :tag "None" nil)))
88
89
90 (defcustom eudc-strict-return-matches t
91 "Ignore or allow entries not containing all requested return attributes.
92 If non-nil, such entries are ignored."
93 :type 'boolean)
94
95 (defcustom eudc-default-return-attributes nil
96 "A list of default attributes to extract from directory entries.
97 If set to the symbol `all', return all attributes.
98 A value of nil means return the default attributes as configured in the
99 server."
100 :type '(choice :menu-tag "Return Attributes"
101 (const :menu-tag "Server defaults (nil)" nil)
102 (const :menu-tag "All" all)
103 (repeat :menu-tag "Attribute list"
104 :tag "Attribute name"
105 :value (nil)
106 (symbol :tag "Attribute name"))))
107
108 (defcustom eudc-multiple-match-handling-method 'select
109 "What to do when multiple entries match an inline expansion query.
110 Possible values are:
111 `first' (equivalent to nil) which means keep the first match only,
112 `select' pop-up a selection buffer,
113 `all' expand to all matches,
114 `abort' the operation is aborted, an error is signaled."
115 :type '(choice :menu-tag "Method"
116 (const :menu-tag "Use First"
117 :tag "Use First" first)
118 (const :menu-tag "Select Interactively"
119 :tag "Select Interactively" select)
120 (const :menu-tag "Use All"
121 :tag "Use All" all)
122 (const :menu-tag "Abort Operation"
123 :tag "Abort Operation" abort)
124 (const :menu-tag "Default (Use First)"
125 :tag "Default (Use First)" nil)))
126
127 (defcustom eudc-duplicate-attribute-handling-method '((email . duplicate))
128 "A method to handle entries containing duplicate attributes.
129 This is either an alist (ATTR . METHOD) or a symbol METHOD.
130 The alist form of the variable associates a method to an individual attribute,
131 the second form specifies a method applicable to all attributes.
132 Available methods are:
133 `list' or nil lets the value of the attribute be a list of values,
134 `first' keeps the first value and discards the others,
135 `concat' concatenates the values into a single multiline string,
136 `duplicate' duplicates the entire entry into as many instances as
137 different values."
138 :type '(choice (const :menu-tag "List" list)
139 (const :menu-tag "First" first)
140 (const :menu-tag "Concat" concat)
141 (const :menu-tag "Duplicate" duplicate)
142 (repeat :menu-tag "Per Attribute Specification"
143 :tag "Per Attribute Specification"
144 (cons :tag "Attribute/Method"
145 :value (nil . list)
146 (symbol :tag "Attribute name")
147 (choice :tag "Method"
148 :menu-tag "Method"
149 (const :menu-tag "List" list)
150 (const :menu-tag "First" first)
151 (const :menu-tag "Concat" concat)
152 (const :menu-tag "Duplicate" duplicate))))))
153
154 (defcustom eudc-inline-query-format '((email)
155 (firstname)
156 (firstname name))
157 "Format of an inline expansion query.
158 This is a list of FORMATs. A FORMAT is itself a list of one or more
159 EUDC attribute names. A FORMAT applies if it contains as many attributes as
160 there are individual words in the inline query string.
161 If several FORMATs apply then they are tried in order until a match
162 is found.
163 If nil, all the words are mapped onto the default server or protocol
164 attribute name.
165
166 The attribute names in FORMATs are not restricted to EUDC attribute names
167 but can also be protocol/server specific names. In this case, this variable
168 must be set in a protocol/server-local fashion, see `eudc-server-set' and
169 `eudc-protocol-set'."
170 :tag "Format of Inline Expansion Queries"
171 :type '(repeat
172 (repeat
173 :menu-tag "Format"
174 :tag "Format"
175 (choice
176 :tag "Attribute"
177 (const :menu-tag "First Name" :tag "First Name" firstname)
178 (const :menu-tag "Surname" :tag "Surname" name)
179 (const :menu-tag "Email Address" :tag "Email Address" email)
180 (const :menu-tag "Phone" :tag "Phone" phone)
181 (symbol :menu-tag "Other" :tag "Attribute name"))))
182 :version "25.1")
183
184 ;; Default to nil so that the most common use of eudc-expand-inline,
185 ;; where replace is nil, does not affect the kill ring.
186 (defcustom eudc-expansion-overwrites-query nil
187 "If non-nil, expanding a query overwrites the query string."
188 :type 'boolean
189 :version "25.1")
190
191 (defcustom eudc-inline-expansion-format '("%s %s <%s>" firstname name email)
192 "A list specifying the format of the expansion of inline queries.
193 This variable controls what `eudc-expand-inline' actually inserts in
194 the buffer. First element is a string passed to `format'. Remaining
195 elements are symbols indicating attribute names; the corresponding values
196 are passed as additional arguments to `format'."
197 :type '(list
198 (string :tag "Format String")
199 (repeat :inline t
200 :tag "Attributes"
201 (choice
202 :tag "Attribute"
203 (const :menu-tag "First Name" :tag "First Name" firstname)
204 (const :menu-tag "Surname" :tag "Surname" name)
205 (const :menu-tag "Email Address" :tag "Email Address" email)
206 (const :menu-tag "Phone" :tag "Phone" phone)
207 (symbol :menu-tag "Other")
208 (symbol :tag "Attribute name"))))
209 :version "25.1")
210
211 (defcustom eudc-inline-expansion-servers 'server-then-hotlist
212 "Which servers to contact for the expansion of inline queries.
213 Possible values are:
214 `current-server': the EUDC current server.
215 `hotlist': the servers of the hotlist in the order they appear,
216 `server-then-hotlist': the current server and then the servers of
217 the hotlist."
218 :type '(choice :tag "Servers"
219 :menu-tag "Servers"
220 (const :menu-tag "Current server" current-server)
221 (const :menu-tag "Servers in the hotlist" hotlist)
222 (const :menu-tag "Current server then hotlist" server-then-hotlist)))
223
224 (defcustom eudc-max-servers-to-query nil
225 "Maximum number of servers to query for an inline expansion.
226 If nil, query all servers available from `eudc-inline-expansion-servers'."
227 :tag "Max Number of Servers to Query"
228 :type '(choice :tag "Max. Servers"
229 :menu-tag "Max. Servers"
230 (const :menu-tag "No limit" nil)
231 (const :menu-tag "1" 1)
232 (const :menu-tag "2" 2)
233 (const :menu-tag "3" 3)
234 (const :menu-tag "4" 4)
235 (const :menu-tag "5" 5)
236 (integer :menu-tag "Set")))
237
238 (defcustom eudc-query-form-attributes '(name firstname email phone)
239 "A list of attributes presented in the query form."
240 :tag "Attributes in Query Forms"
241 :type '(repeat
242 (choice
243 :tag "Attribute"
244 (const :menu-tag "First Name" :tag "First Name" firstname)
245 (const :menu-tag "Surname" :tag "Surname" name)
246 (const :menu-tag "Email Address" :tag "Email Address" email)
247 (const :menu-tag "Phone" :tag "Phone" phone)
248 (symbol :menu-tag "Other" :tag "Attribute name"))))
249
250 (defcustom eudc-user-attribute-names-alist '((url . "URL")
251 (callsign . "HAM Call Sign")
252 (id . "ID")
253 (email . "E-Mail")
254 (firstname . "First Name")
255 (cn . "Full Name")
256 (sn . "Surname")
257 (givenname . "First Name")
258 (ou . "Unit")
259 (labeledurl . "URL")
260 (postaladdress . "Address")
261 (postalcode . "Postal Code")
262 (l . "Location")
263 (c . "Country")
264 (o . "Organization")
265 (roomnumber . "Office")
266 (telephonenumber . "Phone")
267 (uniqueidentifier . "ID")
268 (objectclass . "Object Class"))
269 "Alist of user-defined names for directory attributes.
270 These names are used as prompt strings in query/response forms
271 instead of the raw directory attribute names.
272 Prompt strings for attributes that are not listed here
273 are derived by splitting the attribute name
274 at `_' characters and capitalizing the individual words."
275 :tag "User-defined Names of Directory Attributes"
276 :type '(repeat (cons :tag "Field"
277 (symbol :tag "Directory attribute")
278 (string :tag "User friendly name "))))
279
280 (defcustom eudc-use-raw-directory-names nil
281 "If non-nil, use attributes names as defined in the directory.
282 Otherwise, directory query/response forms display the user attribute
283 names defined in `eudc-user-attribute-names-alist'."
284 :type 'boolean)
285
286 (defcustom eudc-attribute-display-method-alist nil
287 "An alist specifying methods to display attribute values.
288 Each member of the list is of the form (NAME . FUNC) where NAME is a lowercased
289 string naming a directory attribute (translated according to
290 `eudc-user-attribute-names-alist' if `eudc-use-raw-directory-names' is
291 non-nil) and FUNC a function that will be passed the corresponding
292 attribute values for display."
293 :tag "Attribute Decoding Functions"
294 :type '(repeat (cons :tag "Attribute"
295 (symbol :tag "Name")
296 (symbol :tag "Display Function"))))
297
298 (defcustom eudc-external-viewers '(("ImageMagick" "display" "-")
299 ("ShowAudio" "showaudio"))
300 "A list of viewer program specifications.
301 Viewers are programs which can be piped a directory attribute value for
302 display or arbitrary processing. Each specification is a list whose
303 first element is a string naming the viewer. The second element is the
304 executable program which should be invoked, and following elements are
305 arguments that should be passed to the program."
306 :tag "External Viewer Programs"
307 :type '(repeat (list :tag "Viewer"
308 (string :tag "Name")
309 (string :tag "Executable program")
310 (repeat
311 :tag "Arguments"
312 :inline t
313 (string :tag "Argument")))))
314
315 (defcustom eudc-options-file "~/.eudc-options"
316 "A file where the `servers' hotlist is stored."
317 :type '(file :Tag "File Name:"))
318
319 (defcustom eudc-mode-hook nil
320 "Normal hook run on entry to EUDC mode."
321 :type 'hook)
322
323 ;;}}}
324
325 ;;{{{ PH Custom Group
326
327 (defgroup eudc-ph nil
328 "Emacs Unified Directory Client - CCSO PH/QI Backend."
329 :group 'eudc)
330
331 (defcustom eudc-ph-bbdb-conversion-alist
332 '((name . name)
333 (net . email)
334 (address . (eudc-bbdbify-address address "Address"))
335 (phone . ((eudc-bbdbify-phone phone "Phone")
336 (eudc-bbdbify-phone office_phone "Office Phone"))))
337 "A mapping from BBDB to PH/QI fields.
338 This is a list of cons cells (BBDB-FIELD . SPEC-OR-LIST) where
339 BBDB-FIELD is the name of a field that must be defined in your BBDB
340 environment (standard field names are `name', `company', `net', `phone',
341 `address' and `notes'). SPEC-OR-LIST is either a single SPEC or a list
342 of SPECs. Lists of specs are valid only for the `phone' and `address'
343 BBDB fields. SPECs are sexps which are evaluated:
344 a string evaluates to itself,
345 a symbol evaluates to the symbol value. Symbols naming PH/QI fields
346 present in the record evaluate to the value of the field in the record,
347 a form is evaluated as a function. The argument list may contain PH/QI
348 field names which eval to the corresponding values in the
349 record. The form evaluation should return something appropriate for
350 the particular BBDB-FIELD (see `bbdb-create-internal').
351 `eudc-bbdbify-phone' and `eudc-bbdbify-address' are provided as convenience
352 functions to parse phones and addresses."
353 :tag "BBDB to PH Field Name Mapping"
354 :type '(repeat (cons :tag "Field Name"
355 (symbol :tag "BBDB Field")
356 (sexp :tag "Conversion Spec"))))
357
358 ;;}}}
359
360 ;;{{{ LDAP Custom Group
361
362 (defgroup eudc-ldap nil
363 "Emacs Unified Directory Client - LDAP Backend."
364 :group 'eudc)
365
366 (defcustom eudc-ldap-bbdb-conversion-alist
367 '((name . cn)
368 (net . mail)
369 (address . (eudc-bbdbify-address postaladdress "Address"))
370 (phone . ((eudc-bbdbify-phone telephonenumber "Phone"))))
371 "A mapping from BBDB to LDAP attributes.
372 This is a list of cons cells (BBDB-FIELD . SPEC-OR-LIST) where
373 BBDB-FIELD is the name of a field that must be defined in your BBDB
374 environment (standard field names are `name', `company', `net', `phone',
375 `address' and `notes'). SPEC-OR-LIST is either a single SPEC or a list
376 of SPECs. Lists of specs are valid only for the `phone' and `address'
377 BBDB fields. SPECs are sexps which are evaluated:
378 a string evaluates to itself,
379 a symbol evaluates to the symbol value. Symbols naming LDAP attributes
380 present in the record evaluate to the value of the field in the record,
381 a form is evaluated as a function. The argument list may contain LDAP
382 field names which eval to the corresponding values in the
383 record. The form evaluation should return something appropriate for
384 the particular BBDB-FIELD (see `bbdb-create-internal').
385 `eudc-bbdbify-phone' and `eudc-bbdbify-address' are provided as convenience
386 functions to parse phones and addresses."
387 :tag "BBDB to LDAP Attribute Names Mapping"
388 :type '(repeat (cons :tag "Field Name"
389 (symbol :tag "BBDB Field")
390 (sexp :tag "Conversion Spec"))))
391
392 ;;}}}
393
394 ;;{{{ BBDB Custom Group
395
396 (defgroup eudc-bbdb nil
397 "Emacs Unified Directory Client - BBDB Backend."
398 :group 'eudc)
399
400 (defcustom eudc-bbdb-use-locations-as-attribute-names t
401 "If non-nil, BBDB address and phone locations are used as attribute names.
402 This has no effect on queries (you can't search for a specific location)
403 but influences the way records are displayed."
404 :type 'boolean)
405
406 (defcustom eudc-bbdb-enable-substring-matches t
407 "If non-nil, authorize substring match in the same way BBDB does.
408 Otherwise records must match queries exactly."
409 :type 'boolean)
410
411 ;;}}}
412
413
414 (provide 'eudc-vars)
415
416 ;;; eudc-vars.el ends here