3 * Dynamic HTML (formerly known as "AJAX") powered auto-completion
5 * Copyright (c) 1996-2012 by the citadel.org team
7 * This program is open source software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 3.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
20 * Address book popup results
22 HashList *GetAddressbookList() {
23 HashList *List = NULL;
24 const StrBuf *WhichAddrBook;
25 StrBuf *saved_roomname;
31 WhichAddrBook = sbstr("which_addr_book");
32 IsLocalAddrBook = strcasecmp(ChrPtr(WhichAddrBook), "__LOCAL_USERS__") == 1;
34 if (IsLocalAddrBook) {
38 /* remember the default addressbook for this room */
39 set_room_pref("defaddrbook", NewStrBufDup(WhichAddrBook), 0);
40 saved_roomname = NewStrBufDup(WC->CurRoom.name);
41 gotoroom(WhichAddrBook);
46 StrBuf_ServGetln(Line);
47 if (GetServerStatus(Line, NULL) == 1) {
48 List = NewHash(1, NULL);
49 while (BufLen = StrBuf_ServGetln(Line), ((BufLen >= 0) && ((BufLen != 3) || strcmp(ChrPtr(Line), "000")))) {
50 if (IsLocalAddrBook && (BufLen > 5) && (strncmp(ChrPtr(Line), "SYS_", 4) == 0)) {
53 Name = NewStrBufPlain(NULL, StrLength(Line));
54 StrBufExtract_token(Name, Line, 0, '|');
55 Put(List, SKEY(Name), Name, HFreeStrBuf);
58 SortByHashKey(List, 1);
61 if (!IsLocalAddrBook) {
62 gotoroom(saved_roomname);
63 FreeStrBuf(&saved_roomname);
72 void InitModule_ADDRBOOK_POPUP(void) {
74 RegisterIterator("ITERATE:ABNAMES", 0, NULL, GetAddressbookList, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);