+
+
+/*
+ * Offer to make any page the user's "start page" (only if logged in)
+ */
+void offer_start_page(StrBuf *Target, WCTemplputParams *TP)
+{
+ if (WC->logged_in) {
+ wc_printf("<a href=\"change_start_page?startpage=");
+ urlescputs(ChrPtr(WC->Hdr->this_page));
+ wc_printf("\">");
+ wc_printf(_("Make this my start page"));
+ wc_printf("</a>");
+ };
+}
+
+
+/*
+ * Change the user's start page
+ */
+void change_start_page(void)
+{
+ wcsession *WCC = WC;
+ const char *pch;
+ void *vHandler;
+ int ProhibitSave = 0;
+ const StrBuf *pStartPage = sbstr("startpage");
+
+ if (pStartPage != NULL) {
+ pch = strchr(ChrPtr(pStartPage), '?');
+
+ if ((pch != NULL) && (
+ GetHash(HandlerHash, ChrPtr(pStartPage), pch - ChrPtr(pStartPage), &vHandler),
+ (vHandler != NULL) &&
+ ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0)))
+ { /* OK, This handler doesn't want to be set as start page, prune it. */
+ ProhibitSave = 1;
+ }
+ }
+
+ if ((pStartPage == NULL) ||
+ (ProhibitSave == 1))
+ {
+ set_preference_backend(HKEY("startpage"),
+ 0,
+ NewStrBufPlain(HKEY("")),
+ PRF_STRING,
+ 1,
+ NULL);
+ if (ProhibitSave == 1)
+ StrBufAppendBufPlain(WCC->ImportantMsg,
+ _("This isn't allowed to become the start page."),
+ -1, 0);
+ else
+ StrBufAppendBufPlain(WCC->ImportantMsg,
+ _("You no longer have a start page selected."),
+ -1, 0);
+ display_main_menu();
+ return;
+ }
+
+
+
+ set_preference_backend(HKEY("startpage"),
+ 0,
+ NewStrBufDup(pStartPage),
+ PRF_STRING,
+ 1,
+ NULL);
+
+ output_headers(1, 1, 0, 0, 0, 0);
+ do_template("newstartpage");
+ wDumpContent(1);
+}
+
+
+void LoadStartpage(StrBuf *URL, long lvalue)
+{
+ const char *pch;
+ void *vHandler;
+ pch = strchr(ChrPtr(URL), '?');
+ if (pch == NULL) {
+ /* purge the sins of the past... */
+ pch = strchr(ChrPtr(URL), '&');
+ if (pch != NULL) {
+ StrBufPeek(URL, pch, -1, '?');
+ WC->SavePrefsToServer = 1;
+ }
+ }
+ else if (GetHash(HandlerHash, ChrPtr(URL), pch - ChrPtr(URL), &vHandler),
+ (vHandler != NULL) &&
+ ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0))
+ { /* OK, This handler doesn't want to be set as start page, prune it. */
+ FlushStrBuf(URL);
+ WC->SavePrefsToServer = 1;
+ }
+}
+
+