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

  1. /* -*- Mode: C++; tab-width: 4; 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.    pref.cpp -- stuff shared by preferences dialog and other modules
  20.    Created: Linda Wei <lwei@netscape.com>, 03-Dec-96.
  21.  */
  22.  
  23.  
  24.  
  25. #include "felocale.h"
  26. #include "structs.h"
  27. #include "fonts.h"
  28. #include "net.h"
  29. #include "xfe.h"
  30. #include "libmocha.h"
  31. #include "java.h"
  32. #include "PrefsDialog.h"
  33.  
  34. extern "C"
  35. {
  36.     char     *fe_mn_getmailbox(void);
  37. }
  38.  
  39. extern "C" void fe_installGeneralAppearance()
  40. {
  41. }
  42.  
  43. extern "C" void fe_installGeneral()
  44. {
  45. }
  46.  
  47. extern "C" void fe_installGeneralFonts()
  48. {
  49. }
  50.  
  51. extern "C" void fe_installGeneralColors()
  52. {
  53.     LO_SetUserOverride(    !fe_globalPrefs.use_doc_colors );
  54. }
  55.  
  56. extern "C" void fe_installGeneralAdvanced()
  57. {
  58. /*    NET_SetCookiePrefs((NET_CookiePrefsEnum)fe_globalPrefs.accept_cookie);*/
  59.     NET_SendEmailAddressAsFTPPassword(fe_globalPrefs.email_anonftp);
  60. }
  61.  
  62. extern "C" void fe_installGeneralPasswd()
  63. {
  64. }
  65.  
  66. extern "C" void fe_installGeneralCache()
  67. {
  68.     FE_CacheDir = fe_globalPrefs.cache_dir;
  69. }
  70.  
  71. extern "C" void fe_installGeneralProxies()
  72. {
  73.     if ((fe_globalPrefs.proxy_mode == 0) ||
  74.         (fe_globalPrefs.proxy_mode == PROXY_STYLE_NONE))
  75.         NET_SelectProxyStyle(PROXY_STYLE_NONE);
  76.     else if (fe_globalPrefs.proxy_mode == PROXY_STYLE_MANUAL)
  77.         NET_SelectProxyStyle(PROXY_STYLE_MANUAL);
  78.     else if (fe_globalPrefs.proxy_mode == PROXY_STYLE_AUTOMATIC) {
  79.         NET_SetProxyServer(PROXY_AUTOCONF_URL, fe_globalPrefs.proxy_url);
  80.         NET_SelectProxyStyle(PROXY_STYLE_AUTOMATIC);
  81.     }
  82. }
  83.  
  84. extern "C" void fe_installBrowser()
  85. {
  86.     if (fe_globalPrefs.global_history_expiration <= 0)
  87.         GH_SetGlobalHistoryTimeout (-1);
  88.     else
  89.         GH_SetGlobalHistoryTimeout (fe_globalPrefs.global_history_expiration
  90.                                     * 24 * 60 * 60);
  91. }
  92.  
  93. extern "C" void fe_installBrowserLang(char *lang)
  94. {
  95.     fe_SetAcceptLanguage(lang);
  96. }
  97.  
  98. extern "C" void fe_installBrowserAppl()
  99. {
  100.     FE_TempDir = fe_globalPrefs.tmp_dir;
  101. }
  102.  
  103. #ifdef MOZ_MAIL_NEWS
  104. extern "C" void fe_installMailNews()
  105. {
  106. }
  107.  
  108. extern "C" void fe_installMailNewsIdentity()
  109. {
  110.     NET_SetMailRelayHost((char *)((fe_globalPrefs.mailhost && *fe_globalPrefs.mailhost)
  111.                                   ? fe_globalPrefs.mailhost : "localhost"));
  112. }
  113.  
  114. extern "C" void fe_installMailNewsComposition()
  115. {
  116.     MIME_ConformToStandard(fe_globalPrefs.qp_p);
  117. }
  118.  
  119. extern "C" void fe_installMailNewsMserver()
  120. {
  121.     NET_SetPopUsername (fe_globalPrefs.pop3_user_id); 
  122.     MSG_SetBiffStatFile(fe_globalPrefs.use_movemail_p ? fe_mn_getmailbox() :
  123.                         (char *)NULL);
  124. }
  125.  
  126. extern "C" void fe_installMailNewsNserver()
  127. {
  128.     FE_UserNewsHost = fe_globalPrefs.newshost;
  129.     NET_SetNewsHost(FE_UserNewsHost);
  130.     FE_UserNewsRC = fe_globalPrefs.newsrc_directory;
  131. }
  132.  
  133. extern "C" void fe_installMailNewsAddrBook()
  134. {
  135. }
  136. #endif  // MOZ_MAIL_NEWS
  137.  
  138. extern "C" void fe_installLangs()
  139. {
  140. }
  141.  
  142. #ifdef MOZ_LDAP
  143. extern "C" void fe_installMserverMore()
  144. {
  145.     MSG_SetFolderDirectory(fe_mailNewsPrefs, fe_globalPrefs.mail_directory);
  146.     NET_SetPopPassword(fe_globalPrefs.rememberPswd
  147.                        ? fe_globalPrefs.pop3_password : (char *)NULL); 
  148. }
  149. #endif  // MOZ_LDAP
  150.  
  151. extern "C" void fe_installProxiesView()
  152. {
  153.     char buf[1024];
  154.  
  155.     // This should be done in libnet with the proxies - malmer
  156.     sprintf(buf, "%s:%d", fe_globalPrefs.socks_host, 
  157.                           fe_globalPrefs.socks_host_port);
  158.     NET_SetSocksHost(buf);
  159. }
  160.  
  161. extern "C" void fe_installSslConfig()
  162. {
  163. }
  164.  
  165. extern "C" void fe_installOffline()
  166. {
  167. }
  168.  
  169. #ifdef MOZ_MAIL_NEWS
  170. extern "C" void fe_installOfflineNews()
  171. {
  172. }
  173. #endif  // MOZ_MAIL_NEWS
  174.  
  175. extern "C" void fe_installDiskSpace()
  176. {
  177. }
  178.  
  179. extern "C" void fe_installDiskMore()
  180. {
  181. }
  182.  
  183. extern "C" void
  184. fe_PrefsDialog(MWContext *context)
  185. {
  186.     Widget             mainw = CONTEXT_WIDGET(context);
  187.     XFE_PrefsDialog   *theDialog = 0;
  188.  
  189.     // Instantiate a preferences dialog
  190.  
  191.     if ((theDialog = new XFE_PrefsDialog(mainw, "prefs", context)) == 0) {
  192.         // TODO: out of memory
  193.     }
  194.  
  195.     // Open some categories
  196.  
  197.     theDialog->openCategory(CAT_APPEARANCE);
  198.     theDialog->openCategory(CAT_MAILNEWS);
  199.  
  200.     // Pop up the preferences dialog
  201.  
  202.     theDialog->show();
  203. }
  204.  
  205. int fe_stringPrefToArray(const char *orig_string, char ***array_p)
  206. {
  207.     int    count = 0;
  208.     int    i;
  209.     int    len = 0;
  210.     char **array = 0;
  211.     char  *string = 0;
  212.     char  *ptr;
  213.  
  214.     len = XP_STRLEN(orig_string);
  215.     if (orig_string && len > 0) {
  216.         string = XP_STRDUP(orig_string);
  217.  
  218.         // Get the number of entries
  219.  
  220.         count = 0;
  221.         char *sep = XP_STRCHR(string, ',');
  222.         while (sep) {
  223.             count++;
  224.             sep = XP_STRCHR(sep+1, ',');
  225.         }
  226.         count++;
  227.  
  228.         array = (char **)XP_CALLOC(count, sizeof(char *));
  229.         i = 0;
  230.  
  231.         ptr = XP_STRTOK(string, ",");
  232.         while (ptr) {
  233.             array[i] = XP_STRDUP(ptr);
  234.             i++;
  235.             ptr = XP_STRTOK(NULL, ",");
  236.         }
  237.     }
  238.  
  239.     if (string) XP_FREE(string);
  240.     *array_p = array;
  241.     return count;
  242. }
  243.  
  244. char *fe_arrayToStringPref(char **array, int count)
  245. {
  246.     char *string = 0;
  247.     int   i;
  248.     char *ptr;
  249.  
  250.     if (array && (count > 0)) {
  251.         int  len = 0;
  252.         for (i = 0; i < count; i++) {
  253.             len += XP_STRLEN(array[i]);
  254.         }
  255.         len = len + count;
  256.         string = (char *)XP_CALLOC(len, sizeof(char));
  257.         for (ptr= string, i = 0; i < count; i++) {
  258.             int l = XP_STRLEN(array[i]);
  259.             XP_MEMCPY(ptr, array[i], l);
  260.             ptr += l;
  261.             if (i == (count-1))
  262.                 *ptr = '\0';
  263.             else
  264.                 *ptr = ',';
  265.             ptr++;
  266.         }
  267.     }
  268.     else {
  269.         string = XP_STRDUP("");
  270.     }
  271.  
  272.     return string;
  273. }
  274.