1 /*
2 * Author: William Chia-Wei Cheng (bill.cheng@acm.org)
3 *
4 * Copyright (C) 2001-2009, William Chia-Wei Cheng.
5 *
6 * This file may be distributed under the terms of the Q Public License
7 * as defined by Trolltech AS of Norway and appearing in the file
8 * LICENSE.QPL included in the packaging of this file.
9 *
10 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING
11 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
13 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * @(#)$Header: /mm2/home/cvs/bc-src/tgif/help.c,v 1.7 2011/05/16 16:21:57 william Exp $
19 */
20
21 #define _INCLUDE_FROM_HELP_C_
22
23 #include "tgifdefs.h"
24 #include "patchlvl.h"
25
26 #include "color.e"
27 #include "dialog.e"
28 #include "file.e"
29 #include "help.e"
30 #include "menu.e"
31 #include "menuinfo.e"
32 #include "msg.e"
33 #include "navigate.e"
34 #include "remote.e"
35 #include "setup.e"
36 #include "strtbl.e"
37 #include "util.e"
38 #include "version.e"
39
40 #define HELP_ABOUT 0
41 #define HELP_COPYRIGHT 1
42 #define HELP_CURRENT 2
43
44 #define MAXHELPS 3
45
46 int numHelp=MAXHELPS;
47
48 /* ----------------------- About ----------------------- */
49
About()50 void About()
51 {
52 char *c_ptr=NULL;
53
54 GetTgifVersionAndPatchLevel(gszMsgBox, sizeof(gszMsgBox));
55 c_ptr = (&gszMsgBox[strlen(gszMsgBox)]);
56 sprintf(c_ptr, "\n\n%s", copyrightString);
57 c_ptr = (&c_ptr[strlen(c_ptr)]);
58 sprintf(c_ptr, TgLoadString(STID_HYPER_TEXT_HOME), homePageURL);
59 c_ptr = (&c_ptr[strlen(c_ptr)]);
60 sprintf(c_ptr, TgLoadString(STID_LATEST_REL_INFO), currentReleaseURL);
61 c_ptr = (&c_ptr[strlen(c_ptr)]);
62 sprintf(c_ptr, TgLoadString(STID_HYPER_GRAPHICS_INFO), hyperGraphicsURL);
63 c_ptr = (&c_ptr[strlen(c_ptr)]);
64 sprintf(c_ptr, TgLoadString(STID_MAILING_LIST_INFO),
65 mailingList, joinMailingList, mailingURL);
66 c_ptr = (&c_ptr[strlen(c_ptr)]);
67 sprintf(c_ptr, TgLoadString(STID_SEND_BUG_REPORT_TO), "bill.cheng@acm.org");
68 c_ptr = (&c_ptr[strlen(c_ptr)]);
69 MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
70
71 }
72
73 /* ----------------------- Copyright ----------------------- */
74
75 /* do not translate -- program constants */
76 static char *gszCopyright[] = {
77 "",
78 #ifdef QPL_LICENSE
79 "This software is distributed under the terms of the Q Public License",
80 "as defined by Trolltech AS of Norway and appearing in the file",
81 "LICENSE.QPL included in the packaging of this file.",
82 "",
83 "THIS SOFTWARE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING",
84 "THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR",
85 "PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,",
86 "INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING",
87 "FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,",
88 "NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION",
89 "WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.",
90 #else /* ~QPL_LICENSE */
91 "William Cheng (\"Author\") grants to the party hereby receiving \"tgif\"",
92 "(\"Recipient\") a non-exclusive, royalty-free license limited to copy,",
93 "display, and distribute without charging for a fee, and produce derivative",
94 "works of \"tgif\", provided that the above copyright notice appears in",
95 "all copies made of \"tgif\" and both the copyright notice and this license",
96 "appear in supporting documentation, and that the name of Author not be",
97 "used in advertising or publicity pertaining to \"tgif\". All other rights",
98 "(including, but not limited to, the right to sell \"tgif\", the right to",
99 "sell or distribute derivative",
100 "works of \"tgif\", the right to distribute \"tgif\" for a fee, and",
101 "the right to include \"tgif\" or derivative workds of \"tgif\" in a",
102 "for-sale product) are reserved by the Author.",
103 "",
104 "\"Tgif\" is provided \"as is\" without express or implied warranty. Author",
105 "does not and cannot warrant the performance of \"tgif\" or the results",
106 "that may be obtained by its use or its fitness for any specific use by",
107 "Recipient or any third party. In no event shall Author become liable",
108 "to Recipient or any other party, for any loss or damages,",
109 "consequential or otherwise, including but not limited to time, money,",
110 "or goodwill, arising from use or possession, authorized or not, of",
111 "\"tgif\" by Recipient or any other party.",
112 #endif /* QPL_LICENSE */
113 NULL
114 };
115
Copyright()116 void Copyright()
117 {
118 char **s_ptr=gszCopyright, *c_ptr=gszMsgBox;
119
120 sprintf(c_ptr, "%s ", copyrightString);
121 c_ptr = (&gszMsgBox[strlen(c_ptr)]);
122 for ( ; *s_ptr != NULL; s_ptr++) {
123 if (**s_ptr == '\0') {
124 strcpy(c_ptr, "\n\n");
125 } else {
126 sprintf(c_ptr, "%s ", *s_ptr);
127 }
128 c_ptr = (&c_ptr[strlen(c_ptr)]);
129 }
130 MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
131 }
132
LatestReleaseInfo()133 void LatestReleaseInfo()
134 {
135 char tmp_fname[MAXPATHLENGTH+1], final_url[MAXPATHLENGTH+1];
136 char current_url[MAXPATHLENGTH<<1];
137 char *content_type=NULL, *page_spec=NULL;
138 int is_html=FALSE, rc=FALSE;
139
140 *final_url = '\0';
141 strcpy(current_url, currentReleaseURL);
142 navigateRefresh = TRUE;
143 rc = DownloadRemoteFile(current_url, &content_type, &page_spec,
144 &is_html, tmp_fname, final_url, sizeof(final_url));
145 navigateRefresh = FALSE;
146 if (content_type != NULL) FreeRemoteBuf(content_type);
147 if (page_spec != NULL) UtilFree(page_spec);
148 if (rc) {
149 FILE *fp=fopen(tmp_fname, "r");
150 char version_str[MAXPATHLENGTH<<1];
151
152 *version_str = '\0';
153 if (fp == NULL) {
154 sprintf(gszMsgBox, TgLoadString(STID_OPEN_URL_FAIL_USE_BROWSER),
155 currentReleaseURL, currentReleaseURL);
156 MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
157 } else {
158 /* do not translate -- program constants */
159 int len=strlen("The current release of tgif is"), scanning=TRUE;
160 char *buf;
161
162 while (scanning && (buf=UtilGetALine(fp)) != NULL) {
163 /* do not translate -- program constants */
164 if (strncmp(buf, "The current release of tgif is", len) == 0) {
165 char *buf1=UtilGetALine(fp);
166
167 scanning = FALSE;
168 if (buf1 != NULL) {
169 /* do not translate -- program constants */
170 char *version_ptr=strstr(buf1, "Version"), *c_ptr=NULL;
171
172 if (version_ptr != NULL &&
173 (c_ptr=strchr(version_ptr, '<')) != NULL) {
174 *c_ptr = '\0';
175 strcpy(version_str, version_ptr);
176 *c_ptr = '<';
177 }
178 UtilFree(buf1);
179 }
180 }
181 UtilFree(buf);
182 }
183 fclose(fp);
184
185 if (*version_str == '\0') {
186 sprintf(gszMsgBox, TgLoadString(STID_FIND_VER_FAIL_USE_BROWSER),
187 currentReleaseURL, currentReleaseURL);
188 } else if (TGIF_PATCHLEVEL == 0) {
189 if (*specialBuild == '\0') {
190 sprintf(gszMsgBox, TgLoadString(STID_TOOL_CUR_VER_IS_DIFF_INFO),
191 TOOL_NAME, version_str, TOOL_NAME, versionString,
192 (*final_url=='\0' ? currentReleaseURL : final_url));
193 } else {
194 sprintf(gszMsgBox,
195 TgLoadString(STID_TOOL_CUR_VER_IS_DIFF_SPC_INFO),
196 TOOL_NAME, version_str, TOOL_NAME, versionString,
197 specialBuild,
198 (*final_url=='\0' ? currentReleaseURL : final_url));
199 }
200 } else {
201 if (*specialBuild == '\0') {
202 sprintf(gszMsgBox, TgLoadString(STID_TOOL_CUR_VER_PATCH_INFO),
203 TOOL_NAME, version_str, TOOL_NAME, versionString,
204 TGIF_PATCHLEVEL,
205 (*final_url=='\0' ? currentReleaseURL : final_url));
206 } else {
207 sprintf(gszMsgBox,
208 TgLoadString(STID_TOOL_CUR_VER_PATCH_SPC_INFO),
209 TOOL_NAME, version_str, TOOL_NAME, versionString,
210 TGIF_PATCHLEVEL, specialBuild,
211 (*final_url=='\0' ? currentReleaseURL : final_url));
212 }
213 }
214 MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
215 }
216 } else {
217 sprintf(gszMsgBox, TgLoadString(STID_CANT_DOWNLOAD_VER_USE_BROWSER),
218 currentReleaseURL, currentReleaseURL);
219 MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
220 }
221 if (*tmp_fname != '\0') unlink(tmp_fname);
222 }
223
224 /* ----------------------- Init and Clean Up ----------------------- */
225
CleanUpHelp()226 void CleanUpHelp()
227 {
228 }
229
InitHelp()230 void InitHelp()
231 {
232 }
233
234 /* ----------------------- Menu Functions ----------------------- */
235
RefreshHelpMenu(menu)236 void RefreshHelpMenu(menu)
237 TgMenu *menu;
238 {
239 }
240
HelpMenu(X,Y,TrackMenubar)241 int HelpMenu(X, Y, TrackMenubar)
242 int X, Y, TrackMenubar;
243 {
244 int rc=INVALID;
245 TgMenu *menu=(helpMenuInfo.create_proc)(NULL, X, Y, &helpMenuInfo, FALSE);
246
247 activeMenu = MENU_HELP;
248 if (menu != NULL) {
249 menu->track_menubar = TrackMenubar;
250
251 rc = TgMenuLoop(menu);
252 TgDestroyMenu(menu, TRUE);
253 }
254 return rc;
255 }
256