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