rename wprintf to wc_printf; wchar.h also has a wprintf
[citadel.git] / webcit / openid.c
index a4af9d257a1bb4dda1f7618017d3a14b19a8ad01..b489a55c484af1ba6124e4aefb31bb6e7b244e68 100644 (file)
  */
 void display_openids(void)
 {
+       wcsession *WCC = WC;
        char buf[1024];
        int bg = 0;
 
        output_headers(1, 1, 1, 0, 0, 0);
 
-       wprintf("<div class=\"fix_scrollbar_bug\">");
+       wc_printf("<div class=\"fix_scrollbar_bug\">");
 
        svput("BOXTITLE", WCS_STRING, _("Manage Account/OpenID Associations"));
        do_template("beginboxx", NULL);
 
-       if (serv_info.serv_supports_openid) {
+       if (WCC->serv_info->serv_supports_openid) {
 
-               wprintf("<table class=\"altern\">");
+               wc_printf("<table class=\"altern\">");
        
                serv_puts("OIDL");
                serv_getln(buf, sizeof buf);
                if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                        bg = 1 - bg;
-                       wprintf("<tr class=\"%s\">", (bg ? "even" : "odd"));
-                       wprintf("<td><img src=\"static/openid-small.gif\"></td><td>");
+                       wc_printf("<tr class=\"%s\">", (bg ? "even" : "odd"));
+                       wc_printf("<td><img src=\"static/openid-small.gif\"></td><td>");
                        escputs(buf);
-                       wprintf("</td><td>");
-                       wprintf("<a href=\"openid_detach?id_to_detach=");
+                       wc_printf("</td><td>");
+                       wc_printf("<a href=\"openid_detach?id_to_detach=");
                        urlescputs(buf);
-                       wprintf("\" onClick=\"return confirm('%s');\">",
+                       wc_printf("\" onClick=\"return confirm('%s');\">",
                                _("Do you really want to delete this OpenID?"));
-                       wprintf("%s</a>", _("(delete)"));
-                       wprintf("</td></tr>\n");
+                       wc_printf("%s</a>", _("(delete)"));
+                       wc_printf("</td></tr>\n");
                }
        
-               wprintf("</table><br />\n");
+               wc_printf("</table><br />\n");
        
-               wprintf("<form method=\"POST\" action=\"openid_attach\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-               wprintf(_("Add an OpenID: "));
-               wprintf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
-               wprintf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
+               wc_printf("<form method=\"POST\" action=\"openid_attach\">\n");
+               wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
+               wc_printf(_("Add an OpenID: "));
+               wc_printf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
+               wc_printf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
                        "</form></center>\n", _("Attach"));
        }
 
        else {
-               wprintf(_("%s does not permit authentication via OpenID."), ChrPtr(serv_info.serv_humannode));
+               wc_printf(_("%s does not permit authentication via OpenID."), ChrPtr(WCC->serv_info->serv_humannode));
        }
 
        do_template("endbox", NULL);
-       wprintf("</div>");
+       wc_printf("</div>");
        wDumpContent(2);
 }
 
@@ -74,8 +75,8 @@ void openid_attach(void) {
                snprintf(buf, sizeof buf,
                         "OIDS %s|%s://%s/finalize_openid_login|%s://%s",
                         bstr("openid_url"),
-                        (is_https ? "https" : "http"), ChrPtr(WCC->http_host),
-                        (is_https ? "https" : "http"), ChrPtr(WCC->http_host)
+                        (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host),
+                        (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host)
                );
 
                serv_puts(buf);
@@ -85,6 +86,9 @@ void openid_attach(void) {
                        http_redirect(&buf[4]);
                        return;
                }
+               else {
+                       lprintf(CTDL_DEBUG, "OpenID attach failed: %s\n", &buf[4]);
+               }
        }
 
        /* If we get to this point then something failed. */
@@ -113,7 +117,7 @@ void
 InitModule_OPENID
 (void)
 {
-       WebcitAddUrlHandler(HKEY("display_openids"), display_openids, 0);
-       WebcitAddUrlHandler(HKEY("openid_attach"), openid_attach, 0);
-       WebcitAddUrlHandler(HKEY("openid_detach"), openid_detach, 0);
+       WebcitAddUrlHandler(HKEY("display_openids"), "", 0, display_openids, 0);
+       WebcitAddUrlHandler(HKEY("openid_attach"), "", 0, openid_attach, 0);
+       WebcitAddUrlHandler(HKEY("openid_detach"), "", 0, openid_detach, 0);
 }