]> code.citadel.org Git - citadel.git/blobdiff - webcit/addressbook_popup.c
* remove Dave's SYS_ users from the addressbookpopup, since you don't want to send...
[citadel.git] / webcit / addressbook_popup.c
index add472740648e933217b80e77bf556c94c851f13..6cfb5b5c3a8b02c918d619ac102628334d257857 100644 (file)
@@ -1,16 +1,14 @@
 /*
  * $Id$
  *
- * \defgroup AjaxAutoCompletion ajax-powered autocompletion...
- * \ingroup ClientPower
+ * AJAX-powered auto-completion
  */
 
-/*@{*/
 #include "webcit.h"
 
 
-/**
- * \brief Call this right before wDumpContent() on any page which requires the address book popup
+/*
+ * 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. */
@@ -23,13 +21,14 @@ void address_book_popup(void) {
        /* The 'address_book_popup' div will be closed by wDumpContent() */
 }
 
-/**
- * \brief Address book popup window
+/*
+ * Address book popup window
  */
 void display_address_book_middle_div(void) {
        char buf[256];
        long len;
-       char *Name, *Namee;
+       char *Name;
+       void *Namee;
        HashList *List;
        HashPos  *it;
 
@@ -50,7 +49,7 @@ void display_address_book_middle_div(void) {
        wprintf("</option>\n");
 
        
-       List = NewHash();
+       List = NewHash(1, NULL);
        serv_puts("LKRA");
        serv_getln(buf, sizeof buf);
        if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
@@ -61,13 +60,13 @@ void display_address_book_middle_div(void) {
                }
        }
 
-       SortByHashKey(List);
+       SortByHashKey(List, 1);
        it = GetNewHashPos();
-       while (GetNextHashPos(List, it, &len, &Name, (void**)&Namee)) {
+       while (GetNextHashPos(List, it, &len, &Name, &Namee)) {
                wprintf("<option value=\"");
-               urlescputs(Namee);
+               urlescputs((char*)Namee);
                wprintf("\">");
-               escputs(Namee);
+               escputs((char*)Namee);
                wprintf("</option>\n");
        }
        DeleteHashPos(&it);
@@ -91,8 +90,8 @@ 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];
@@ -100,7 +99,8 @@ void display_address_book_inner_div() {
        char target_id[64];
        char target_label[64];
        long len;
-       char *Name, *Namee;
+       char *Name;
+       void *Namee;
        HashList *List;
        HashPos  *it;
        int i;
@@ -108,7 +108,7 @@ void display_address_book_inner_div() {
 
        begin_ajax_response();
 
-       List = NewHash();
+       List = NewHash(1, NULL);
        wprintf("<div align=center><form onSubmit=\"return false;\">"
                "<select multiple name=\"whichaddr\" id=\"whichaddr\" size=\"15\">\n");
 
@@ -118,16 +118,20 @@ void display_address_book_inner_div() {
                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);
 
                }
-               SortByHashKey(List);
+               SortByHashKey(List, 1);
                it = GetNewHashPos();
-               while (GetNextHashPos(List, it, &len, &Name, (void**)&Namee)) {
+               while (GetNextHashPos(List, it, &len, &Name, &Namee)) {
                        wprintf("<option value=\"");
-                       urlescputs(Namee);
+                       escputs((char*)Namee);
                        wprintf("\">");
-                       escputs(Namee);
+                       escputs((char*)Namee);
                        wprintf("</option>\n");
                }
                DeleteHashPos(&it);
@@ -145,18 +149,18 @@ void display_address_book_inner_div() {
                        Put(List, Name, len, Name, NULL);
 
                }
-               SortByHashKey(List);
+               SortByHashKey(List, 1);
                it = GetNewHashPos();
                while (GetNextHashPos(List, it, &len, &Name, (void**)&Namee)) {
                        wprintf("<option value=\"");
-                       urlescputs(Namee);
+                       escputs((char*)Namee);
                        wprintf("\">");
-                       escputs(Namee);
+                       escputs((char*)Namee);
                        wprintf("</option>\n");
                }
                DeleteHashPos(&it);
                DeleteHash(&List);
-               gotoroom(bstr(saved_roomname));
+               gotoroom(saved_roomname);
        }
 
        wprintf("</select>\n");
@@ -184,4 +188,12 @@ void display_address_book_inner_div() {
 }
 
 
-/** @} */
+
+
+void 
+InitModule_ADDRBOOK_POPUP
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_address_book_middle_div"), display_address_book_middle_div, 0);
+       WebcitAddUrlHandler(HKEY("display_address_book_inner_div"), display_address_book_inner_div, 0);
+}