2 * ========================================================================
3 * Copyright 2013-2017 Eduardo Chappa
4 * Copyright 2008 University of Washington
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
18 static struct headerentry headents_templ
[]={
19 /* TRANSLATORS: these are the headings for setting up a collection of
20 folders, PATH is a filesystem path, VIEW is sort of a technical
21 term that can be used to restrict the View to fewer folders */
22 {"Nickname : ", N_("Nickname"), h_composer_cntxt_nick
, 12, 0, NULL
,
23 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
24 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KS_NONE
},
25 {"Server : ", N_("Server"), h_composer_cntxt_server
, 12, 0, NULL
,
26 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
27 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KS_NONE
},
28 {"Path : ", N_("Path"), h_composer_cntxt_path
, 12, 0, NULL
,
29 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
30 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KS_NONE
},
31 {"View : ", N_("View"), h_composer_cntxt_view
, 12, 0, NULL
,
32 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
33 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KS_NONE
},
34 {NULL
, NULL
, NO_HELP
, 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KS_NONE
}
43 ical_compose_reply(char *url
)
48 //context_edit_screen(struct pine *ps, char *func, char *def_nick,
49 // char *def_serv, char *def_path, char *def_view)
51 int editor_result
, i
, j
;
52 char servpart
[MAILTMPLEN
], new_cntxt
[MAILTMPLEN
];
53 char pathpart
[MAILTMPLEN
], allbutnick
[MAILTMPLEN
];
54 char tmp
[MAILTMPLEN
], *nick
, *serv
, *path
, *view
,
55 *return_cntxt
= NULL
, *val
, *p
;
56 char nickpmt
[100], servpmt
[100], pathpmt
[100], viewpmt
[100];
62 standard_picobuf_setup(&pbf
);
63 pbf
.pine_flags
|= P_NOBODY
;
64 pbf
.exittest
= exit_collection_add
;
65 pbf
.canceltest
= (func
&& !strucmp(func
, "EDIT")) ? cancel_collection_edit
66 : cancel_collection_add
;
67 pbf
.pine_anchor
= set_titlebar(_("CALENDAR EVENT"),
68 ps_global
->mail_stream
,
69 ps_global
->context_current
,
70 ps_global
->cur_folder
,ps_global
->msgmap
,
71 0, FolderName
, 0, 0, NULL
);
73 /* An informational message */
74 if((msgso
= so_get(PicoText
, NULL
, EDIT_ACCESS
)) != NULL
){
75 pbf
.msgtext
= (void *) so_text(msgso
);
77 _("\n Fill in the fields above to add a Folder Collection to your"));
79 _("\n COLLECTION LIST screen."));
81 _("\n Use the \"^G\" command to get help specific to each item, and"));
83 _("\n use \"^X\" when finished."));
87 pbf
.headents
= (struct headerentry
*)fs_get((sizeof(headents_templ
)
88 /sizeof(struct headerentry
))
89 * sizeof(struct headerentry
));
90 memset((void *) pbf
.headents
, 0,
91 (sizeof(headents_templ
)/sizeof(struct headerentry
))
92 * sizeof(struct headerentry
));
94 for(i
= 0; headents_templ
[i
].prompt
; i
++)
95 pbf
.headents
[i
] = headents_templ
[i
];
97 indent
= utf8_width(_("Nickname")) + 2;
99 nick
= cpystr(def_nick
? def_nick
: "");
100 pbf
.headents
[AC_NICK
].realaddr
= &nick
;
101 pbf
.headents
[AC_NICK
].maxlen
= strlen(nick
);
102 utf8_snprintf(nickpmt
, sizeof(nickpmt
), "%-*.*w: ", indent
, indent
, _("Nickname"));
103 pbf
.headents
[AC_NICK
].prompt
= nickpmt
;
104 pbf
.headents
[AC_NICK
].prwid
= indent
+2;
106 serv
= cpystr(def_serv
? def_serv
: "");
107 pbf
.headents
[AC_SERV
].realaddr
= &serv
;
108 pbf
.headents
[AC_SERV
].maxlen
= strlen(serv
);
109 utf8_snprintf(servpmt
, sizeof(servpmt
), "%-*.*w: ", indent
, indent
, _("Server"));
110 pbf
.headents
[AC_SERV
].prompt
= servpmt
;
111 pbf
.headents
[AC_SERV
].prwid
= indent
+2;
113 path
= cpystr(def_path
? def_path
: "");
114 pbf
.headents
[AC_PATH
].realaddr
= &path
;
115 pbf
.headents
[AC_PATH
].maxlen
= strlen(path
);
116 pbf
.headents
[AC_PATH
].bldr_private
= (void *) 0;
117 utf8_snprintf(pathpmt
, sizeof(pathpmt
), "%-*.*w: ", indent
, indent
, _("Path"));
118 pbf
.headents
[AC_PATH
].prompt
= pathpmt
;
119 pbf
.headents
[AC_PATH
].prwid
= indent
+2;
121 view
= cpystr(def_view
? def_view
: "");
122 pbf
.headents
[AC_VIEW
].realaddr
= &view
;
123 pbf
.headents
[AC_VIEW
].maxlen
= strlen(view
);
124 utf8_snprintf(viewpmt
, sizeof(viewpmt
), "%-*.*w: ", indent
, indent
, _("View"));
125 pbf
.headents
[AC_VIEW
].prompt
= viewpmt
;
126 pbf
.headents
[AC_VIEW
].prwid
= indent
+2;
129 * If this is new context, setup to query IMAP server
130 * for location of personal namespace.
132 if(!(def_nick
|| def_serv
|| def_path
|| def_view
)){
133 pbf
.headents
[AC_SERV
].builder
= build_namespace
;
134 pbf
.headents
[AC_SERV
].affected_entry
= &pbf
.headents
[AC_PATH
];
135 pbf
.headents
[AC_SERV
].bldr_private
= (void *) 0;
138 /* pass to pico and let user change them */
139 editor_result
= pico(&pbf
);
141 if(editor_result
& COMP_GOTHUP
){
145 fix_windsize(ps_global
);
149 if(editor_result
& COMP_CANCEL
){
152 else if(editor_result
& COMP_EXIT
){
153 servpart
[0] = pathpart
[0] = new_cntxt
[0] = allbutnick
[0] = '\0';
155 if(serv
[0] == '{' && serv
[strlen(serv
)-1] == '}'){
156 strncpy(servpart
, serv
, sizeof(servpart
)-1);
157 servpart
[sizeof(servpart
)-1] = '\0';
160 snprintf(servpart
, sizeof(servpart
), "{%s}", serv
);
162 if(mail_valid_net_parse(servpart
, &mb
)){
163 if(!struncmp(mb
.service
, "nntp", 4)
164 && (!path
|| strncmp(path
, "#news.", 6)))
165 strncat(servpart
, "#news.", sizeof(servpart
)-1-strlen(servpart
));
168 alpine_panic("Unexpected invalid server");
173 servpart
[sizeof(servpart
)-1] = '\0';
177 val
= quote_if_needed(nick
);
179 strncpy(new_cntxt
, val
, sizeof(new_cntxt
)-2);
180 new_cntxt
[sizeof(new_cntxt
)-2] = '\0';
182 fs_give((void **)&val
);
184 strncat(new_cntxt
, " ", sizeof(new_cntxt
)-strlen(new_cntxt
)-1);
185 new_cntxt
[sizeof(new_cntxt
)-1] = '\0';
190 sstrncpy(&p
, servpart
, sizeof(allbutnick
)-1-(p
-allbutnick
));
191 allbutnick
[sizeof(allbutnick
)-1] = '\0';
194 val
= quote_brackets_if_needed(path
);
196 strncpy(pathpart
, val
, sizeof(pathpart
)-1);
197 pathpart
[sizeof(pathpart
)-1] = '\0';
199 fs_give((void **)&val
);
202 if(pbf
.headents
[AC_PATH
].bldr_private
!= (void *) 0){
203 strncat(pathpart
, (char *) pbf
.headents
[AC_PATH
].bldr_private
,
204 sizeof(pathpart
)-strlen(pathpart
)-1);
205 pathpart
[sizeof(pathpart
)-1] = '\0';
209 sstrncpy(&p
, pathpart
, sizeof(allbutnick
)-1-(p
-allbutnick
));
210 allbutnick
[sizeof(allbutnick
)-1] = '\0';
212 if(view
[0] != '[' && sizeof(allbutnick
)-1-(p
-allbutnick
) > 0){
217 sstrncpy(&p
, view
, sizeof(allbutnick
)-1-(p
-allbutnick
));
218 allbutnick
[sizeof(allbutnick
)-1] = '\0';
219 if((j
=strlen(view
)) < 2 || (view
[j
-1] != ']' &&
220 sizeof(allbutnick
)-1-(p
-allbutnick
) > 0)){
225 val
= quote_if_needed(allbutnick
);
227 strncat(new_cntxt
, val
, sizeof(new_cntxt
)-1-strlen(new_cntxt
));
228 new_cntxt
[sizeof(new_cntxt
)-1] = '\0';
230 if(val
!= allbutnick
)
231 fs_give((void **)&val
);
234 return_cntxt
= cpystr(new_cntxt
);
237 for(i
= 0; headents_templ
[i
].prompt
; i
++)
238 fs_give((void **) pbf
.headents
[i
].realaddr
);
240 if(pbf
.headents
[AC_PATH
].bldr_private
!= (void *) 0)
241 fs_give(&pbf
.headents
[AC_PATH
].bldr_private
);
243 fs_give((void **) &pbf
.headents
);
245 standard_picobuf_teardown(&pbf
);
250 return(return_cntxt
);