2 * Dynamic HTML (formerly known as "AJAX") powered auto-completion
4 * Copyright (c) 1996-2012 by the citadel.org team
6 * This program is open source software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
19 * Address book popup results
21 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),
51 ((BufLen != 3) || strcmp(ChrPtr(Line), "000"))))
53 if (IsLocalAddrBook &&
55 (strncmp(ChrPtr(Line), "SYS_", 4) == 0))
59 Name = NewStrBufPlain(NULL, StrLength(Line));
60 StrBufExtract_token(Name, Line, 0, '|');
61 Put(List, SKEY(Name), Name, HFreeStrBuf);
64 SortByHashKey(List, 1);
67 if (!IsLocalAddrBook) {
68 gotoroom(saved_roomname);
69 FreeStrBuf(&saved_roomname);
79 InitModule_ADDRBOOK_POPUP
83 RegisterIterator("ITERATE:ABNAMES", 0, NULL, GetAddressbookList, NULL, NULL, CTX_STRBUF, CTX_NONE, IT_NOFLAG);