* Correction to URL for getting access code from refresh code for Yandex.com.
[alpine.git] / alpine / newuser.c
blob6a84372a05bd2069e856e4516c987c7dc6f7046a
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";
131 if(ps->first_time_user)
132 clrbitn(NUOV_RELNOTES, sargs.keys.bitmap);
134 cmd = scrolltool(&sargs);
136 flush_input();
138 if(F_ON(F_BLANK_KEYMENU,ps_global))
139 FOOTER_ROWS(ps_global) = 1;
141 ClearScreen();
144 so_give(&store);
147 free_handles(&handles);
149 while(cmd == MC_RESIZE);
154 nuov_processor(int cmd, MSGNO_S *msgmap, SCROLL_S *sparms)
156 int rv = 0;
158 switch(cmd){
159 /*----------- Print all the help ------------*/
160 case MC_PRINTMSG :
161 if(open_printer(sparms->text.desc) == 0){
162 print_help(sparms->proc.data.p);
163 close_printer();
166 break;
168 case MC_RELNOTES :
169 helper(h_news, "ALPINE RELEASE NOTES", 0);
170 ps_global->mangled_screen = 1;
171 break;
173 case MC_EXIT :
174 rv = 1;
175 break;
177 default :
178 alpine_panic("Unhandled case");
181 return(rv);