X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Faddressbook_popup.c;h=0b789f74f5f65ee6acc57988a897ce812dbf0f6b;hb=17ce76a935cdbd2e2fda4a6ee1680e603413eb0c;hp=467d9356c8b18bc9e26bc31666d23fa80ffb35ad;hpb=78585ad10b89a03cd3a14394058148592bc1aa24;p=citadel.git diff --git a/webcit/addressbook_popup.c b/webcit/addressbook_popup.c index 467d9356c..0b789f74f 100644 --- a/webcit/addressbook_popup.c +++ b/webcit/addressbook_popup.c @@ -1,55 +1,108 @@ /* - * $Id: $ - *//** - * \defgroup AjaxAutoCompletion ajax-powered autocompletion... - * \ingroup ClientPower + * AJAX-powered auto-completion + * + * Copyright (c) 1996-2010 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*@{*/ #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") ); @@ -58,46 +111,113 @@ void display_address_book_middle_div(void) { -/** - * \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); } - wprintf("\n"); + 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); - wprintf(" 0) { $('%s').value = $('%s').value + ', '; } $('%s').value=$('%s').value + $('whichaddr').value;\">", - bstr("target_input"), - bstr("target_input"), - bstr("target_input"), - bstr("target_input"), - bstr("target_input") - ); - wprintf(""); + } + 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); + } + + wc_printf("\n"); - wprintf("
\n"); + wc_printf("%s: ", _("Add")); + + 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); +}