24 |
;; Boston, MA 02111-1307, USA. |
;; Boston, MA 02111-1307, USA. |
25 |
|
|
26 |
;;; Commentary: |
;;; Commentary: |
27 |
;; This library provides specific CCSO PH/QI protocol support for the |
;; This library provides specific CCSO PH/QI protocol support for the |
28 |
;; Emacs Unified Directory Client package |
;; Emacs Unified Directory Client package |
29 |
|
|
30 |
;;; Code: |
;;; Code: |
50 |
|
|
51 |
(defun eudc-ph-query-internal (query &optional return-fields) |
(defun eudc-ph-query-internal (query &optional return-fields) |
52 |
"Query the PH/QI server with QUERY. |
"Query the PH/QI server with QUERY. |
53 |
QUERY can be a string NAME or a list made of strings NAME |
QUERY can be a string NAME or a list made of strings NAME |
54 |
and/or cons cells (KEY . VALUE) where KEYs should be valid |
and/or cons cells (KEY . VALUE) where KEYs should be valid |
55 |
CCSO database keys. NAME is equivalent to (DEFAULT . NAME), |
CCSO database keys. NAME is equivalent to (DEFAULT . NAME), |
56 |
where DEFAULT is the default key of the database. |
where DEFAULT is the default key of the database. |
57 |
RETURN-FIELDS is a list of database fields to return, |
RETURN-FIELDS is a list of database fields to return, |
61 |
(setq return-fields eudc-default-return-attributes)) |
(setq return-fields eudc-default-return-attributes)) |
62 |
(if (eq 'all return-fields) |
(if (eq 'all return-fields) |
63 |
(setq return-fields '(all))) |
(setq return-fields '(all))) |
64 |
(setq request |
(setq request |
65 |
(concat "query " |
(concat "query " |
66 |
(if (stringp query) |
(if (stringp query) |
67 |
query |
query |
88 |
|
|
89 |
|
|
90 |
(defun eudc-ph-parse-query-result (&optional fields) |
(defun eudc-ph-parse-query-result (&optional fields) |
91 |
"Return a list of alists of key/values from in `eudc-ph-process-buffer'. |
"Return a list of alists of key/values from in `eudc-ph-process-buffer'. |
92 |
Fields not in FIELDS are discarded." |
Fields not in FIELDS are discarded." |
93 |
(let (record |
(let (record |
94 |
records |
records |
95 |
line-regexp |
line-regexp |
96 |
current-key |
current-key |
122 |
(intern (match-string 2))) |
(intern (match-string 2))) |
123 |
value (match-string 3)) |
value (match-string 3)) |
124 |
(if (and current-key |
(if (and current-key |
125 |
(eq key current-key)) |
(eq key current-key)) |
126 |
(setq key nil) |
(setq key nil) |
127 |
(setq current-key key)) |
(setq current-key key)) |
128 |
(if (or (null fields) |
(if (or (null fields) |
156 |
(message "Contacting server...") |
(message "Contacting server...") |
157 |
(setq process (eudc-ph-open-session)) |
(setq process (eudc-ph-open-session)) |
158 |
(if process |
(if process |
159 |
(save-excursion |
(save-excursion |
160 |
(set-buffer (setq buffer (process-buffer process))) |
(set-buffer (setq buffer (process-buffer process))) |
161 |
(eudc-ph-send-command process request) |
(eudc-ph-send-command process request) |
162 |
(message "Request sent, waiting for reply...") |
(message "Request sent, waiting for reply...") |
164 |
(if process |
(if process |
165 |
(eudc-ph-close-session process))) |
(eudc-ph-close-session process))) |
166 |
buffer)) |
buffer)) |
167 |
|
|
168 |
(defun eudc-ph-open-session (&optional server) |
(defun eudc-ph-open-session (&optional server) |
169 |
"Open a connection to the given CCSO/QI SERVER. |
"Open a connection to the given CCSO/QI SERVER. |
170 |
SERVER is either a string naming the server or a list (NAME PORT)." |
SERVER is either a string naming the server or a list (NAME PORT)." |
232 |
(buffer-substring (point) match-end) |
(buffer-substring (point) match-end) |
233 |
return-code)))) |
return-code)))) |
234 |
|
|
235 |
;;}}} |
;;}}} |
236 |
|
|
237 |
;;{{{ High-level interfaces (interactive functions) |
;;{{{ High-level interfaces (interactive functions) |
238 |
|
|