home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / prefdialogs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  21.7 KB  |  877 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* 
  19.    dialogs.c --- Preference dialogs.
  20.    Created: Spence Murray <spence@netscape.com>, 30-Sep-95.
  21.  */
  22.  
  23.  
  24. #define PREFS_NET
  25. #define PREFS_SOCKS
  26. #define PREFS_DISK_CACHE
  27. #define PREFS_VERIFY
  28. #define PREFS_CLEAR_CACHE_BUTTONS
  29. #define PREFS_SIG
  30. #define PREFS_NEWS_MAX
  31. #define PREFS_8BIT
  32. /* #define PREFS_EMPTY_TRASH */
  33. /* #define PREFS_QUEUED_DELIVERY */
  34.  
  35. #include <stdio.h>
  36.  
  37. #include "mozilla.h"
  38. #include "xlate.h"
  39. #include "xfe.h"
  40. #include "felocale.h"
  41. #include "nslocks.h"
  42. #include "secnav.h"
  43. #include "cert.h"
  44. #include "mozjava.h"
  45. #include "prnetdb.h"
  46. #include "e_kit.h"
  47. #include "pref_helpers.h"
  48.  
  49. #include "libmocha.h"
  50.  
  51. #include <Xm/Label.h>
  52. #include <Xm/CascadeBG.h>
  53. #include <Xm/PanedW.h>
  54. #include <Xm/PushB.h>
  55. #include <Xm/ToggleB.h>
  56.  
  57. #include <Xm/ArrowBG.h>
  58.  
  59. #ifndef _STDC_
  60. #define _STDC_ 1
  61. #define HACKED_STDC 1
  62. #endif
  63.  
  64. #include <XmL/Folder.h>
  65.  
  66. #ifdef HACKED_STDC
  67. #undef HACKED_STDC
  68. #undef _STDC_
  69. #endif
  70.  
  71. #include "xp_sec.h"
  72.  
  73. #include "msgcom.h"
  74.  
  75. #include "libimg.h"             /* Image Library public API. */
  76.  
  77.  
  78. /* For sys_errlist and sys_nerr */
  79. #include <sys/errno.h>
  80. #if !defined(__FreeBSD__) && !defined(LINUX_GLIBC_2)
  81. extern char *sys_errlist[];
  82. extern int sys_nerr;
  83. #endif
  84.  
  85. #include "prprf.h"
  86. #include "libi18n.h"
  87. #include "fonts.h"
  88.  
  89.  
  90. /* for XP_GetString() */
  91. #include <xpgetstr.h>
  92. extern int XFE_UNKNOWN_ERROR;
  93.  
  94. extern int XFE_FILE_DOES_NOT_EXIST;
  95. extern int XFE_FTP_PROXY_HOST;
  96. #ifdef MOZ_MAIL_NEWS
  97. extern int XFE_GLOBAL_MAILCAP_FILE;
  98. extern int XFE_GLOBAL_MIME_FILE;
  99. #endif
  100. extern int XFE_GOPHER_PROXY_HOST;
  101. extern int XFE_HOST_IS_UNKNOWN;
  102. extern int XFE_HTTPS_PROXY_HOST;
  103. extern int XFE_HTTP_PROXY_HOST;
  104. extern int XFE_NO_PORT_NUMBER;
  105. #ifdef MOZ_MAIL_NEWS
  106. extern int XFE_MAIL_HOST;
  107. extern int XFE_NEWS_HOST;
  108. extern int XFE_NEWS_RC_DIRECTORY;
  109. extern int XFE_PRIVATE_MAILCAP_FILE;
  110. extern int XFE_PRIVATE_MIME_FILE;
  111. #endif
  112. extern int XFE_SOCKS_HOST;
  113. extern int XFE_TEMP_DIRECTORY;
  114. extern int XFE_WAIS_PROXY_HOST;
  115. extern int XFE_WARNING;
  116. extern int XFE_ERROR_SAVING_OPTIONS;
  117. extern int XFE_GENERAL;
  118. extern int XFE_PASSWORDS;
  119. extern int XFE_PERSONAL_CERTIFICATES;
  120. extern int XFE_SITE_CERTIFICATES;
  121. extern int XFE_APPEARANCE;
  122. extern int XFE_BOOKMARKS;
  123. extern int XFE_COLORS;
  124. extern int XFE_FONTS;
  125. extern int XFE_APPLICATIONS;
  126. extern int XFE_HELPERS;
  127. extern int XFE_IMAGES;
  128. extern int XFE_LANGUAGES;
  129. extern int XFE_CACHE;
  130. extern int XFE_CONNECTIONS;
  131. extern int XFE_PROXIES;
  132. extern int XFE_PROTOCOLS;
  133. extern int XFE_LANG;
  134. extern int XFE_APPEARANCE;
  135. extern int XFE_COMPOSE_DLG;
  136. extern int XFE_SERVERS;
  137. extern int XFE_IDENTITY;
  138. extern int XFE_ORGANIZATION;
  139. extern int XFE_CHANGE_PASSWORD;
  140. extern int XFE_SET_PASSWORD;
  141. #ifdef MOZ_MAIL_NEWS
  142. extern int XFE_PRIVATE_MIMETYPE_RELOAD;
  143. extern int XFE_PRIVATE_MAILCAP_RELOAD;
  144. extern int XFE_PRIVATE_RELOADED_MIMETYPE;
  145. extern int XFE_PRIVATE_RELOADED_MAILCAP;
  146. #endif
  147.  
  148. extern void fe_installGeneralAppearance(void);
  149. extern void fe_installGeneralFonts(void);
  150. extern void fe_installGeneralColors(void);
  151. extern void fe_installGeneralAdvanced(void);
  152. extern void fe_installGeneralPasswd(void);
  153. extern void fe_installGeneralCache(void);
  154. extern void fe_installGeneralProxies(void);
  155. extern void fe_installBrowser(void);
  156. extern void fe_installBrowserAppl(void);
  157. #ifdef MOZ_MAIL_NEWS
  158. extern void fe_installMailNews(void);
  159. extern void fe_installMailNewsIdentity(void);
  160. extern void fe_installMailNewsComposition(void);
  161. extern void fe_installMailNewsMserver(void);
  162. extern void fe_installMailNewsNserver(void);
  163. extern void fe_installMailNewsAddrBook(void);
  164. extern void fe_installOfflineNews(void);
  165. extern void fe_installMserverMore(void);
  166. #endif
  167. extern void fe_installProxiesView(void);
  168. extern void fe_installDiskMore(void);
  169. extern void fe_installSslConfig(void);
  170. extern void fe_installOffline(void);
  171. extern void fe_installDiskSpace(void);
  172.  
  173. /* Preferences
  174.  */
  175.  
  176. struct fe_prefs_data
  177. {
  178.   MWContext *context;
  179.  
  180.   Widget shell, form;
  181.   Widget promptDialog;
  182.  
  183.   /*=== General prefs folder ===*/
  184.   Widget general_form;
  185.  
  186.   /* Appearance page */
  187.   Widget styles1_selector, styles1_page;
  188.   Widget icons_p, text_p, both_p, tips_p;
  189.   Widget browser_p, mail_p, news_p;
  190.   Widget blank_p, home_p, home_text;
  191.   Widget underline_p;
  192.   Widget expire_days_p, expire_days_text, never_expire_p;
  193.  
  194.   /* Applications page */
  195.   Widget apps_selector, apps_page;
  196.   Widget tmp_text;
  197.   Widget telnet_text, tn3270_text, rlogin_text, rlogin_user_text;
  198.  
  199. #if 0
  200.   /* Bookmarks page */
  201.   Widget bookmarks_selector, bookmarks_page;
  202.   Widget book_text;
  203. #endif
  204.  
  205.   /* Colors page */
  206.   Widget colors_selector, colors_page;
  207.  
  208.   /* Fonts page */
  209.   Widget fonts_selector, fonts_page;
  210.   Widget prop_family_pulldown, fixed_family_pulldown;
  211.   Widget prop_family_option, fixed_family_option;
  212.   Widget prop_size_pulldown, fixed_size_pulldown;
  213.   Widget prop_size_option, fixed_size_option;
  214.   Widget prop_size_field, fixed_size_field;
  215.   Widget prop_size_toggle, fixed_size_toggle;
  216.   int fonts_changed;
  217.  
  218.   /* Helpers page */
  219.   Widget helpers_selector, helpers_page;
  220.   int helpers_changed;
  221.  
  222.   struct fe_prefs_helpers_data *helpers;
  223.  
  224.   /* Images page */
  225.   Widget images_selector, images_page;
  226.   Widget auto_p, dither_p, closest_p;
  227.   Widget while_loading_p, after_loading_p;
  228.  
  229.   /* Languages page */
  230.   Widget languages_selector, languages_page;
  231.   Widget lang_reg_avail, lang_reg_pref, lang_reg_text;
  232.   Widget tmpDefaultButton;
  233.  
  234.   /*=== Mail/News prefs folder ===*/
  235.   Widget mailnews_form;
  236.  
  237.   /* Appearance page */
  238.   Widget appearance_selector, appearance_page;
  239.   Widget fixed_message_font_p, var_message_font_p;
  240.   Widget cite_plain_p, cite_bold_p, cite_italic_p, cite_bold_italic_p;
  241.   Widget cite_normal_p, cite_bigger_p, cite_smaller_p;
  242.   Widget cite_color_text;
  243.   Widget mail_horiz_p, mail_vert_p, mail_stack_p;
  244.   Widget news_horiz_p, news_vert_p, news_stack_p;
  245.   Widget msgwin_use_mailwin_p, msgwin_use_new_p, msgwin_use_existing_p;
  246.  
  247.   /* Compose page */
  248.   Widget compose_selector, compose_page;
  249.   Widget eightbit_toggle, qp_toggle;
  250.   Widget deliverAuto_toggle, deliverQ_toggle;
  251.   Widget mMailOutSelf_toggle, mMailOutOther_text;
  252.   Widget nMailOutSelf_toggle, nMailOutOther_text;
  253.   Widget mCopyOut_text;
  254.   Widget nCopyOut_text;
  255.   Widget autoquote_toggle;
  256.  
  257.   /* Servers page */
  258.   Widget dirs_selector, dirs_page;
  259.   Widget srvr_text, user_text;
  260.   Widget pop_toggle;
  261.   Widget movemail_text;
  262.   Widget external_toggle, builtin_toggle;
  263.   Widget no_limit, msg_limit, limit_text;
  264.   Widget msg_remove, msg_leave;
  265.   Widget check_every, check_never, check_text;
  266.   Widget smtp_text, maildir_text;
  267.   Widget newshost_text, newsrc_text, newsmax_text;
  268.  
  269.   /* Identity page */
  270.   Widget identity_selector, identity_page;
  271.   Widget user_name_text, user_mail_text, user_org_text, user_sig_text;
  272.  
  273.   /* Organization page */
  274.   Widget organization_selector, organization_page;
  275.   Widget emptyTrash_toggle, rememberPswd_toggle;
  276.   Widget threadmail_toggle, threadnews_toggle;
  277.   Widget mdate_toggle, mnum_toggle, msubject_toggle, msender_toggle;
  278.   Widget ndate_toggle, nnum_toggle, nsubject_toggle, nsender_toggle;
  279.  
  280.   /*=== Network prefs folder ===*/
  281.   Widget network_form;
  282.  
  283.   /* Cache page */
  284.   Widget cache_selector, cache_page;
  285.   Widget memory_text, memory_clear;
  286.   Widget disk_text, disk_dir, disk_clear;
  287.   Widget verify_label, once_p, every_p, expired_p;
  288.   Widget cache_ssl_p;
  289.  
  290.   /* Nework page */
  291.   Widget network_selector, network_page;
  292.   Widget buf_label, buf_text;
  293.   Widget conn_label, conn_text;
  294.  
  295.   /* Proxies page */
  296.   Widget proxies_selector, proxies_page;
  297.   Widget no_proxies_p, manual_p, manual_browse;
  298.   Widget auto_proxies_p, proxy_label, proxy_text;
  299.   Widget proxy_reload;
  300.  
  301.   Widget ftp_text, ftp_port;
  302.   Widget gopher_text, gopher_port;
  303.   Widget http_text, http_port;
  304.   Widget https_text, https_port;
  305.   Widget wais_text, wais_port;
  306.   Widget no_text;
  307.   Widget socks_text, socks_port;
  308.  
  309.   /* Protocols page */
  310.   Widget protocols_selector, protocols_page;
  311.   Widget cookie_p;    /* Show alert before accepting a cookie */
  312.   Widget anon_ftp_p;    /* Use email address for anon ftp */
  313.   Widget email_form_p;    /* Show alert before submiting a form by email */
  314.  
  315.   /* Languages page */
  316.   Widget lang_selector, lang_page;
  317. #ifdef JAVA
  318.   Widget java_toggle;
  319. #endif
  320.  
  321.   Widget javascript_toggle;
  322.  
  323.   /*=== Security prefs folder ===*/
  324.   Widget security_form;
  325.  
  326.   /* General Security page */
  327.   Widget sec_general_selector, sec_general_page;
  328.   Widget enter_toggle, leave_toggle, mixed_toggle, submit_toggle;
  329.   Widget ssl2_toggle, ssl3_toggle;
  330.  
  331.   /* Security Passwords page */
  332.   Widget sec_passwords_selector, sec_passwords_page;
  333.   Widget once_toggle, every_toggle, periodic_toggle;
  334.   Widget periodic_text, change_password;
  335. #ifdef FORTEZZA
  336.   Widget fortezza_toggle, fortezza_timeout;
  337. #endif
  338.  
  339.   /* Personal Certificates page */
  340.   Widget personal_selector, personal_page;
  341.   Widget pers_list, pers_info, pers_delete_cert, pers_new_cert;
  342.   Widget site_default, pers_label;
  343.   Widget pers_cert_menu;
  344.   char *deleted_user_cert;
  345.  
  346.   /* Site Certificates page */
  347.   Widget site_selector, site_page;
  348.   Widget all_list, all_edit_cert, all_delete_cert;
  349.   Widget all_label;
  350.   char *deleted_site_cert;
  351. };
  352.  
  353. void
  354. FE_SetPasswordAskPrefs(MWContext *context, int askPW, int timeout)
  355. {
  356. }
  357.  
  358. void
  359. FE_SetPasswordEnabled(MWContext *context, PRBool usePW)
  360. {
  361. }
  362.  
  363.  
  364. void
  365. fe_MarkHelpersModified(MWContext *context)
  366. {
  367.   /* Mark that the helpers have been modified. We need this
  368.    * to detect if we need to save/reload all these helpers.
  369.    * For doing this, the condition we adopt is
  370.    * (1) User clicked on 'OK' button for the Edit Helpers Dialog
  371.    *    This also covers the "New" case as the same Dialog
  372.    *    is shown for the "New" and "Edit".
  373.    * (2) User deleted a mime/type and confirmed it.
  374.    */
  375.   if (context && CONTEXT_DATA(context)->fep)
  376.     CONTEXT_DATA(context)->fep->helpers_changed = TRUE;
  377. }
  378.  
  379.  
  380. const char *multiline_continuator = "\t\t\n";
  381. /*
  382.  * This belongs in a utility module
  383.  *
  384.  * Convert an array of strings
  385.  * to multiline string (embedded new-lines)
  386.  *
  387.  *  returns a string built up from the array
  388.  *
  389.  * The caller must free the array
  390.  */
  391. char *
  392. array_to_multiline_str(char **array, int cnt)
  393. {
  394.   char *mstring, *p;
  395.   int i, str_len;
  396.  
  397.   /*
  398.    * Handle an empty array
  399.    */
  400.   if (cnt == 0) {
  401.     /* always allocate an array so the caller can free it */
  402.     mstring = strdup("\n");
  403.     return mstring;
  404.   }
  405.  
  406.   /*
  407.    * Get the length of the multiline string
  408.    */
  409.   str_len = 0;
  410.   for (i=0; i<cnt; i++) {
  411.     if (i != 0)
  412.       str_len += strlen(multiline_continuator);
  413.     str_len += strlen(array[i]);
  414.   }
  415.   str_len += 2; /* space for new-line and terminator */
  416.   mstring = (char *)XP_ALLOC(str_len);
  417.  
  418.   for (p=mstring, i=0; i<cnt; i++) {
  419.     if (i != 0) {
  420.       strcpy(p, multiline_continuator);
  421.       p += strlen(multiline_continuator);
  422.     }
  423.     strcpy(p, array[i]);
  424.     p += strlen(array[i]);
  425.   }
  426.   /*
  427.    * Note: don't add a final line-feed for multiline
  428.    * as the prefs_write_string() function handles it funny
  429.    */
  430.   return mstring;
  431. }
  432.  
  433. /*
  434.  * This belongs in a utility module
  435.  *
  436.  * Convert an array of strings
  437.  * to multiline preference (embedded new-lines)
  438.  *
  439.  *  returns a preference value string built up from the array
  440.  *
  441.  * The caller must free the array
  442.  */
  443. char *
  444. array_to_multiline_pref(char **array, int cnt)
  445. {
  446.   char *string;
  447.   string = array_to_multiline_str(array, cnt);
  448.   return string;
  449. }
  450.  
  451. /*
  452.  * This belongs in a utility module
  453.  *
  454.  * Convert a multiline string (embedded new-lines)
  455.  * to an array of strings
  456.  *  create the array
  457.  *  copies the lines into the array
  458.  *  returns length of the array
  459.  *
  460.  * To free the array:
  461.  *   for (i=0; i<cnt; i++)
  462.  *      XP_FREE(array[i]);
  463.  *   XP_FREE(array);
  464.  */
  465. int
  466. multiline_str_to_array(const char *string, char ***array_p)
  467. {
  468.     char *p, *q, **array;
  469.     int i, cnt, len;
  470.     Boolean at_start_of_line;
  471.     
  472.     /* handle null string */
  473.     if (string == NULL) {
  474.     /* always allocate an array so the caller can free it */
  475.     array = (char **)XP_ALLOC(sizeof(char *));
  476.     array[0] = NULL;
  477.     *array_p = array;
  478.     return 0;
  479.     }
  480.  
  481.     /* 
  482.      * count the number of lines 
  483.      * (count beginnings so we will count any last line without a '\n')
  484.      * This supports multibyte text only because '\n' is less than 0x40
  485.      */
  486.     cnt = 0;
  487.     at_start_of_line = True;
  488.     for (p=(char *)string; *p; p++) {
  489.     if (at_start_of_line) {
  490.         cnt += 1;
  491.         at_start_of_line = False;
  492.     }
  493.     if (*p == '\n') {
  494.         at_start_of_line = True;
  495.     }
  496.     }
  497.  
  498.     /* copy lines into the array */
  499.     array = (char **)XP_ALLOC((cnt+1) * sizeof(char *));
  500.     i = 0;
  501.     len = 0;
  502.     for (p=q=(char *)string; *p; p++) {
  503.     if (*p == '\n') {
  504.         array[i] = (char *)XP_ALLOC(len+1);
  505.         strncpy(array[i], q, len);
  506.         /* add a string terminator */
  507.         array[i][len] = '\0';
  508.         i += 1;
  509.         len = 0;
  510.         q = p + 1;
  511.     }
  512.     else
  513.         len += 1;
  514.     }
  515.     if (len) { /* include ending chars with no newline */
  516.     array[i] = (char *)XP_ALLOC(len+1);
  517.     strncpy(array[i], q, len);
  518.     /* add a string terminator */
  519.     array[i][len] = '\0';
  520.     }
  521.  
  522.     *array_p = array;
  523.     return cnt;
  524. }
  525.  
  526. /*
  527.  * This belongs in a utility module
  528.  *
  529.  * Convert a multiline preference (embedded new-lines)
  530.  * to an array of strings
  531.  *  create the array
  532.  *  copies the lines into the array
  533.  *  remove leading/trailing white space
  534.  *  remove blank lines
  535.  *  returns length of the array
  536.  *
  537.  * To free the array:
  538.  *   for (i=0; i<cnt; i++)
  539.  *      XP_FREE(array[i]);
  540.  *   XP_FREE(array);
  541.  */
  542. int
  543. multiline_pref_to_array(const char *string, char ***array_p)
  544. {
  545.   int i, j, cnt;
  546.   char **array;
  547.  
  548.   /*
  549.    * Convert the multiline string to an array
  550.    * (with leading/trailing white space and blank lines)
  551.    */
  552.   cnt = multiline_str_to_array(string, array_p);
  553.  
  554.   /*
  555.    * trim any leading/training white space
  556.    */
  557.   array = *array_p;
  558.   for (i=0; i<cnt; i++) {
  559.     char *tmp;
  560.     tmp = XP_StripLine(array[i]);
  561.     /* we can't lose the malloc address else free will fail */
  562.     /* so if there was white space at the beginning we make a copy */
  563.     if (tmp != array[i]) {
  564.     char *tmp2 = array[i];
  565.           array[i] = strdup(tmp);
  566.           XP_FREE(tmp2);
  567.     }
  568.   }
  569.  
  570.   /*
  571.    * remove any blank lines
  572.    */
  573.   for (i=0; i<cnt; i++) {
  574.     if (array[i][0] == '\0') {
  575.     XP_FREE(array[i]);
  576.     for (j=i+1; j<cnt; j++)
  577.         array[j-1] = array[j];
  578.     cnt -= 1;
  579.     }
  580.   }
  581.  
  582.   return cnt;
  583. }
  584.  
  585. IL_DitherMode
  586. fe_pref_string_to_dither_mode (char *s)
  587. {
  588.   if (!XP_STRCASECMP(s, "True") || !XP_STRCASECMP(s, "Dither"))
  589.     return IL_Dither;
  590.   else if (!XP_STRCASECMP(s, "False") || !XP_STRCASECMP(s, "ClosestColor"))
  591.     return IL_ClosestColor;
  592.  
  593.   /* In the absence of a reasonable value, dithering is auto-selected */
  594.   return IL_Auto;
  595. }
  596.  
  597. #ifdef MOZ_MAIL_NEWS
  598. void
  599. fe_SetMailNewsSortBehavior(MWContext* context, XP_Bool thread, int sortcode)
  600. {
  601.   XP_ASSERT(context->type == MWContextMail || context->type == MWContextNews);
  602.   if (context->type == MWContextMail || context->type == MWContextNews) {
  603.     if (thread) {
  604.       MSG_SetToggleStatus(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByThread, NULL, 0,
  605.               thread ? MSG_Checked : MSG_Unchecked);
  606.     } else {
  607.       switch (sortcode) {
  608.       case 0:
  609.     MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByDate, NULL, 0);
  610.     break;
  611.       case 1:
  612.     MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByMessageNumber, NULL, 0);
  613.     break;
  614.       case 2:
  615.     MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortBySubject, NULL, 0);
  616.     break;
  617.       case 3:
  618.     MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortBySender, NULL, 0);
  619.     break;
  620.       }
  621.     }
  622.   }
  623. }
  624. #endif
  625.  
  626. void
  627. fe_InstallPreferences (MWContext *context)
  628. {
  629.     /* This function is called from main() */
  630.  
  631.     fe_installGeneralAppearance();
  632.     fe_installGeneralFonts();
  633.     fe_installGeneralColors();
  634.     fe_installGeneralAdvanced();
  635.     fe_installGeneralPasswd();
  636.     fe_installGeneralCache();
  637.     fe_installGeneralProxies();
  638.     fe_installDiskSpace();
  639.  
  640.     fe_installBrowser();
  641.     fe_installBrowserAppl();
  642.  
  643. #ifdef MOZ_MAIL_NEWS
  644.     fe_installMailNews();
  645.     fe_installMailNewsIdentity();
  646.     fe_installMailNewsComposition();
  647.     fe_installMailNewsMserver();
  648.     fe_installMailNewsNserver();
  649.     fe_installMailNewsAddrBook();
  650. #endif
  651.  
  652.     fe_installOffline();
  653. #ifdef MOZ_MAIL_NEWS
  654.     fe_installOfflineNews();
  655.     fe_installMserverMore();
  656. #endif
  657.  
  658.     fe_installProxiesView();
  659.     fe_installSslConfig();
  660.     fe_installDiskMore();
  661.  
  662.     /* CACHE
  663.      */
  664.  
  665.     /* spider begin */
  666.         FE_SARCacheDir = fe_globalPrefs.sar_cache_dir ;
  667.         /* spider end */
  668.     NET_DontDiskCacheSSL(!fe_globalPrefs.cache_ssl_p);
  669.  
  670.     /* bookmark_file
  671.      */
  672.  
  673.     FE_GlobalHist = fe_globalPrefs.history_file;
  674.  
  675.     /* NETWORK
  676.      */
  677.  
  678.     NET_ChangeMaxNumberOfConnections (50);
  679.     NET_ChangeMaxNumberOfConnectionsPerContext (fe_globalPrefs.max_connections);
  680.     /* The unit for tcp buffer size is changed from kbyes to btyes */
  681.     NET_ChangeSocketBufferSize (fe_globalPrefs.network_buffer_size);
  682.  
  683.     /* NEWS
  684.      */
  685.  
  686. #ifdef MOZ_MAIL_NEWS
  687.     NET_SetNumberOfNewsArticlesInListing (fe_globalPrefs.news_max_articles);
  688.     NET_SetCacheXOVER (fe_globalPrefs.news_cache_xover);
  689. #endif
  690.  
  691.     /* PROTOCOLS
  692.      */
  693.  
  694. #ifdef MOZ_MAIL_NEWS
  695.     NET_WarnOnMailtoPost(fe_globalPrefs.email_submit);
  696. #endif
  697.  
  698. #ifdef FORTEZZA
  699.     if (fe_globalPrefs.fortezza_toggle) {
  700.         int timeout = fe_globalPrefs.fortezza_timeout;
  701.         /* '0' minute timeout because 1 minute... still pretty darn fast */
  702.         FortezzaSetTimeout(timeout ? timeout : 1);
  703.     } else {
  704.         FortezzaSetTimeout(0);
  705.     }
  706. #endif
  707. }
  708.  
  709. void
  710. fe_GeneralPrefsDialog (MWContext *context)
  711. {
  712. }
  713.  
  714. void
  715. fe_MailNewsPrefsDialog (MWContext *context)
  716. {
  717. }
  718.  
  719. void
  720. fe_NetworkPrefsDialog (MWContext *context)
  721. {
  722. }
  723.  
  724. void
  725. fe_SecurityPrefsDialog (MWContext *context)
  726. {
  727. }
  728.  
  729. /* spider begin */
  730. void
  731. fe_VerifyDiskCache (MWContext *context)
  732. {
  733.  
  734. #ifdef PREFS_DISK_CACHE
  735.  
  736.   static Boolean done = False;
  737.   if (done) return;
  738.   done = True;
  739.  
  740.   if (fe_globalPrefs.disk_cache_size <= 0)
  741.     return;
  742.  
  743.   fe_VerifyDiskCacheExistence(context, fe_globalPrefs.cache_dir) ;
  744.  
  745. #endif /* PREFS_DISK_CACHE */
  746.  
  747. #ifdef PREFS_OLD_WAY
  748. #ifdef PREFS_DISK_CACHE
  749.   struct stat st;
  750.   char file [1024];
  751.   char message [4000];
  752.   static Boolean done = False;
  753.   if (done) return;
  754.   done = True;
  755.  
  756.   if (fe_globalPrefs.disk_cache_size <= 0)
  757.     return;
  758.  
  759.   strcpy (file, fe_globalPrefs.cache_dir);
  760.   if (file [strlen (file) - 1] == '/')
  761.     file [strlen (file) - 1] = 0;
  762.  
  763.   if (stat (file, &st))
  764.     {
  765.       /* Doesn't exist - try to create it. */
  766.       if (mkdir (file, 0700))
  767.     {
  768.       /* Failed. */
  769.       char *error = ((errno >= 0 && errno < sys_nerr)
  770.              ? sys_errlist [errno]
  771.              : XP_GetString( XFE_UNKNOWN_ERROR));
  772.       PR_snprintf (message, sizeof (message),
  773.             fe_globalData.create_cache_dir_message,
  774.             file, error);
  775.     }
  776.       else
  777.     {
  778.       /* Suceeded. */
  779.       PR_snprintf (message, sizeof (message),
  780.             fe_globalData.created_cache_dir_message, file);
  781.     }
  782.     }
  783.   else if (! (st.st_mode & S_IFDIR))
  784.     {
  785.       /* Exists but isn't a directory. */
  786.       PR_snprintf (message, sizeof (message),
  787.             fe_globalData.cache_not_dir_message, file);
  788.     }
  789.   else
  790.     {
  791.       /* The disk cache is ok! */
  792.       *message = 0;
  793.     }
  794.  
  795.   if (*message)
  796.     {
  797.       PR_snprintf(message + strlen (message), sizeof (message),
  798.           fe_globalData.cache_suffix_message,
  799.           fe_globalPrefs.disk_cache_size, fe_progclass);
  800.       FE_Alert (context, message);
  801.     }
  802. #endif /* PREFS_DISK_CACHE */
  803. #endif /* PREFS_OLD_WAY */
  804. }
  805.  
  806. void
  807. fe_VerifySARDiskCache (MWContext *context)
  808. {
  809.  
  810. #ifdef PREFS_DISK_CACHE
  811.  
  812.   fe_VerifyDiskCacheExistence(context, fe_globalPrefs.sar_cache_dir) ;
  813.  
  814. #endif /* PREFS_DISK_CACHE */
  815. }
  816.  
  817. void
  818. fe_VerifyDiskCacheExistence (MWContext *context, char * cache_directory)
  819. {
  820.  
  821. #ifdef PREFS_DISK_CACHE
  822.   struct stat st;
  823.   char file [1024];
  824.   char message [4000];
  825.  
  826.   if (!cache_directory)
  827.     return ;
  828.  
  829.   strcpy (file, cache_directory);
  830.   if (file [strlen (file) - 1] == '/')
  831.     file [strlen (file) - 1] = 0;
  832.  
  833.   if (stat (file, &st))
  834.     {
  835.       /* Doesn't exist - try to create it. */
  836.       if (mkdir (file, 0700))
  837.     {
  838.       /* Failed. */
  839.       char *error = ((errno >= 0 && errno < sys_nerr)
  840.              ? sys_errlist [errno]
  841.              : XP_GetString( XFE_UNKNOWN_ERROR));
  842.       PR_snprintf (message, sizeof (message),
  843.             fe_globalData.create_cache_dir_message,
  844.             file, error);
  845.     }
  846.       else
  847.     {
  848.       /* Suceeded. */
  849.       PR_snprintf (message, sizeof (message),
  850.             fe_globalData.created_cache_dir_message, file);
  851.     }
  852.     }
  853.   else if (! (st.st_mode & S_IFDIR))
  854.     {
  855.       /* Exists but isn't a directory. */
  856.       PR_snprintf (message, sizeof (message),
  857.             fe_globalData.cache_not_dir_message, file);
  858.     }
  859.   else
  860.     {
  861.       /* The disk cache is ok! */
  862.       *message = 0;
  863.     }
  864.  
  865.   if (*message)
  866.     {
  867.       PR_snprintf(message + strlen (message), sizeof (message),
  868.           fe_globalData.cache_suffix_message,
  869.           fe_globalPrefs.disk_cache_size, fe_progclass);
  870.       FE_Alert (context, message);
  871.     }
  872. #endif /* PREFS_DISK_CACHE */
  873. }
  874.  
  875. /* spider end */
  876.  
  877.