* A few improvements to the http code, which make the http_* functions not return...
[alpine.git] / alpine / newuser.c
blob2b32b3c06b5a2bf9c9b09c1ea171ad12aaa63597
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: newuser.c 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2013-2020 Eduardo Chappa
8 * Copyright 2006-2008 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
20 #include "headers.h"
21 #include "newuser.h"
22 #include "mailview.h"
23 #include "help.h"
24 #include "keymenu.h"
25 #include "osdep/print.h"
26 #include "../pith/state.h"
27 #include "../pith/conf.h"
28 #include "../pith/msgno.h"
29 #include "../pith/filter.h"
30 #include "../pith/init.h"
31 #include "../pith/margin.h"
35 * Internal prototypes
37 int nuov_processor(int, MSGNO_S *, SCROLL_S *);
41 * Display a new user or new version message.
43 void
44 new_user_or_version(struct pine *ps)
46 char **shown_text;
47 int cmd = MC_NONE;
48 int first_time_alpine_user = 0;
49 char *error = NULL;
50 HelpType text;
51 SCROLL_S sargs;
52 STORE_S *store;
53 HANDLE_S *handles = NULL, *htmp;
54 gf_io_t pc;
55 char *vers = ps->vers_internal;
57 first_time_alpine_user = (ps->first_time_user
58 || (ps->pine_pre_vers
59 && isdigit((unsigned char) ps->pine_pre_vers[0])
60 && ps->pine_pre_vers[1] == '.'
61 && isdigit((unsigned char) vers[0])
62 && vers[1] == '.'
63 && ps->pine_pre_vers[0] < '5' /* it was Pine */
64 && vers[0] >= '5')); /* Alpine */
66 text = ps->first_time_user ? new_user_greeting :
67 first_time_alpine_user ? new_alpine_user_greeting : new_version_greeting;
69 shown_text = text;
72 * At this point, shown_text is a charstarstar with html
73 * Turn it into a charstar with digested html
75 do{
76 init_helper_getc(shown_text);
77 init_handles(&handles);
79 if((store = so_get(CharStar, NULL, EDIT_ACCESS)) != NULL){
80 gf_set_so_writec(&pc, store);
81 gf_filter_init();
83 gf_link_filter(gf_html2plain,
84 gf_html2plain_opt("x-alpine-help:",
85 ps->ttyo->screen_cols, non_messageview_margin(),
86 &handles, NULL, GFHP_LOCAL_HANDLES));
88 error = gf_pipe(helper_getc, pc);
90 gf_clear_so_writec(store);
92 if(!error){
93 struct key_menu km;
94 struct key keys[24];
96 for(htmp = handles; htmp; htmp = htmp->next)
97 if(htmp->type == URL
98 && htmp->h.url.path
99 && (htmp->h.url.path[0] == 'x'
100 || htmp->h.url.path[0] == '#'))
101 htmp->force_display = 1;
103 /* This is mostly here to get the curses variables
104 * for line and column in sync with where the
105 * cursor is on the screen. This gets warped when
106 * the composer is called because it does it's own
107 * stuff
109 ClearScreen();
111 memset(&sargs, 0, sizeof(SCROLL_S));
112 sargs.text.text = so_text(store);
113 sargs.text.src = CharStar;
114 sargs.text.desc = "greeting text";
115 sargs.text.handles = handles;
116 sargs.bar.title = "GREETING TEXT";
117 sargs.bar.style = TextPercent;
118 sargs.proc.tool = nuov_processor;
119 sargs.help.text = main_menu_tx;
120 sargs.help.title = "MAIN PINE HELP";
121 sargs.resize_exit = 1;
122 sargs.keys.menu = &km;
123 km = nuov_keymenu;
124 km.keys = keys;
125 memcpy(&keys[0], nuov_keymenu.keys,
126 (nuov_keymenu.how_many * 12) * sizeof(struct key));
127 setbitmap(sargs.keys.bitmap);
129 km.keys[NUOV_EXIT].label = "[Exit this greeting]";
130 km.keys[NUOV_EXIT].bind.nch = 3;
131 clrbitn(NUOV_VIEW, sargs.keys.bitmap);
133 if(ps->first_time_user)
134 clrbitn(NUOV_RELNOTES, sargs.keys.bitmap);
136 cmd = scrolltool(&sargs);
138 flush_input();
140 if(F_ON(F_BLANK_KEYMENU,ps_global))
141 FOOTER_ROWS(ps_global) = 1;
143 ClearScreen();
146 so_give(&store);
149 free_handles(&handles);
151 while(cmd == MC_RESIZE);
156 nuov_processor(int cmd, MSGNO_S *msgmap, SCROLL_S *sparms)
158 int rv = 0;
160 switch(cmd){
161 /*----------- Print all the help ------------*/
162 case MC_PRINTMSG :
163 if(open_printer(sparms->text.desc) == 0){
164 print_help(sparms->proc.data.p);
165 close_printer();
168 break;
170 case MC_RELNOTES :
171 helper(h_news, "ALPINE RELEASE NOTES", 0);
172 ps_global->mangled_screen = 1;
173 break;
175 case MC_EXIT :
176 rv = 1;
177 break;
179 default :
180 alpine_panic("Unhandled case");
183 return(rv);