X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Faddressbook_popup.c;h=8b5b97973cafec8c926a642fbc293f6302574546;hb=bb8396949b1fd2c8f96b3d4bc12fd4048b87c6cf;hp=36c01f5ab44b7138b30d12f60e0eedcacf1ea811;hpb=d32604cf468353ce121421a2ae3f26b1ed1fc893;p=citadel.git diff --git a/webcit/addressbook_popup.c b/webcit/addressbook_popup.c index 36c01f5ab..8b5b97973 100644 --- a/webcit/addressbook_popup.c +++ b/webcit/addressbook_popup.c @@ -1,93 +1,222 @@ /* - * $Id: $ - *//** - * \defgroup AjaxAutoCompletion ajax-powered autocompletion... - * \ingroup ClientPower + * AJAX-powered auto-completion + * + * Copyright (c) 1996-2011 by the citadel.org team + * + * This program is open source software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -/*@{*/ #include "webcit.h" -/** - * \brief Address book popup window +/* + * Call this right before wDumpContent() on any page which requires the address book popup + */ +void address_book_popup(void) { + /* Open a new div, hidden initially, for address book popups. */ + wc_printf("\n"); /* End of 'content' div */ + wc_printf("
"); + wc_printf("
"); + wc_printf("
"); + wc_printf("
"); + wc_printf("
"); + /* The 'address_book_popup' div will be closed by wDumpContent() */ +} + +/* + * Address book popup window */ void display_address_book_middle_div(void) { char buf[256]; - char ebuf[256]; + long len; + char *Name; + const char *VCName; + void *Namee; + StrBuf *DefAddrBook; + HashList *List; + HashPos *it; begin_ajax_response(); - wprintf(""); - wprintf(""); - wprintf("
"); + DefAddrBook = get_room_pref("defaddrbook"); + + wc_printf(""); + wc_printf(""); + wc_printf(""); - wprintf(""); + wc_printf("
"); - wprintf("
" + wc_printf("" "
"); - wprintf("
"); + else + wc_printf("\">"); + escputs((char*)Namee); + wc_printf("\n"); + } + DeleteHashPos(&it); + DeleteHash(&List); + wc_printf(""); + + wc_printf(""); - wprintf("
"); + ">"); + wc_printf("
"); - wprintf("\n"); + wc_printf("", + bstr("target_input") + ); end_ajax_response(); } -/** - * \brief Address book popup results +/* + * Address book popup results */ void display_address_book_inner_div() { char buf[256]; + int num_targets = 0; + char target_id[64]; + char target_label[64]; + long len; + char *Name; + const char *VCName; + void *Namee; + HashList *List; + HashPos *it; + int i; + StrBuf *saved_roomname; begin_ajax_response(); - wprintf("
" - "\n"); + + if (!strcasecmp(bstr("which_addr_book"), "__LOCAL_USERS__")) { + serv_puts("LIST"); + serv_getln(buf, sizeof buf); + if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + Name = (char*) malloc(len + 1); + len = extract_token(Name, buf, 0, '|', len + 1); + if((len > 5) && (strncmp(Name, "SYS_", 4) == 0)) { + free(Name); + continue; + } + Put(List, Name, len, Name, NULL); - serv_printf("GOTO %s", bstr("which_addr_book")); - serv_getln(buf, sizeof buf); - serv_puts("DVCA"); - serv_getln(buf, sizeof buf); - if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - wprintf("\n"); + } + SortByHashKey(List, 1); + it = GetNewHashPos(List, 0); + while (GetNextHashPos(List, it, &len, &VCName, &Namee)) { + wc_printf("\n"); + } + DeleteHashPos(&it); + DeleteHash(&List); + } + + else { + set_room_pref("defaddrbook",NewStrBufDup(sbstr("which_addr_book")), 0); + saved_roomname = NewStrBufDup(WC->CurRoom.name); + gotoroom(sbstr("which_addr_book")); + serv_puts("DVCA"); + serv_getln(buf, sizeof buf); + if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + Name = (char*) malloc(len + 1); + len = extract_token(Name, buf, 0, '|', len + 1); + Put(List, Name, len, Name, NULL); + + } + SortByHashKey(List, 1); + it = GetNewHashPos(List, 0); + while (GetNextHashPos(List, it, &len, &VCName, (void**)&Namee)) { + wc_printf("\n"); + } + DeleteHashPos(&it); + DeleteHash(&List); + gotoroom(saved_roomname); + FreeStrBuf(&saved_roomname); } - wprintf("\n"); + wc_printf("\n"); - wprintf(""); - wprintf(""); + wc_printf("%s: ", _("Add")); - wprintf("
\n"); + num_targets = num_tokens(bstr("target_input"), '|'); + for (i=0; i", target_id); + } + + /* This 'close window' button works. Omitting it because we already have a close button + * in the upper right corner, and this one takes up space. + * + wc_printf(""); + */ + + wc_printf("
\n"); end_ajax_response(); } -/** @} */ + + +void +InitModule_ADDRBOOK_POPUP +(void) +{ + WebcitAddUrlHandler(HKEY("display_address_book_middle_div"), "", 0, display_address_book_middle_div, 0); + WebcitAddUrlHandler(HKEY("display_address_book_inner_div"), "", 0, display_address_book_inner_div, 0); +}