home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UPreferencesView.cp < prev    next >
Encoding:
Text File  |  1994-03-16  |  19.1 KB  |  626 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992 Peter Speck, speck@dat.ruc.dk. All rights reserved.
  2. // UPreferencesView.cp
  3.  
  4. #include "UPreferencesView.h"
  5. #include "UPrefsDatabase.h"
  6. #include "UNntp.h"
  7. #include "UFolderSelectView.h"
  8. #include "Tools.h"
  9. #include "UArticleTextCache.h"
  10. #include "NetAsciiTools.h"
  11. #include "ViewTools.h"
  12.  
  13. #include <Rsrcglobals.h>
  14. #include <ErrorGlobals.h>
  15.  
  16. #include <Folders.h>
  17. #include <UDialog.h>
  18. #include <ToolUtils.h>
  19.  
  20. #ifndef __STDIO__
  21. #include <stdio.h>
  22. #endif
  23.  
  24. #pragma segment MyDialogs
  25.  
  26. #if qDebug
  27. #define macroCheckSubView(view, x) if (!view) {ProgramBreak(CStr255(x) + " is missing");Failure(minErr, 0);}
  28. #else
  29. #define macroCheckSubView(view, x)
  30. #endif
  31.  
  32. TPrefRammeView::TPrefRammeView()
  33. {
  34. }
  35.  
  36. pascal void TPrefRammeView::Initialize()
  37. {
  38.     inherited::Initialize();
  39. }
  40.  
  41. pascal void TPrefRammeView::ReadFields(TStream *aStream)
  42. {
  43.     inherited::ReadFields(aStream);
  44.     FailInfo fi;
  45.     if (fi.Try())
  46.     {
  47.         short id = aStream->ReadInteger();
  48.         TextStyle itsTextStyle;
  49.         MAGetTextStyle(id, itsTextStyle);
  50.         fTextStyle = itsTextStyle;
  51.         fRammeVertOffset = aStream->ReadInteger();
  52.         fTextHorzOffset = aStream->ReadInteger();
  53.         fTextVertOffset = aStream->ReadInteger();
  54.         id = aStream->ReadInteger();
  55.         short index = aStream->ReadInteger();
  56.         CStr255 s;
  57.         GetIndString(s, id, index);
  58.         fText = s;
  59.         fi.Success();
  60.     }
  61.     else // fail
  62.     {
  63.         Free();
  64.         fi.ReSignal();
  65.     }
  66. }
  67.  
  68. void pascal TPrefRammeView::Free()
  69. {
  70.     inherited::Free();
  71. }
  72.  
  73. pascal void TPrefRammeView::Draw(const VRect& /* area */)
  74. {
  75.     CRect r;
  76.     ViewToQDRect(VRect(VPoint(0, 0), fSize), r);
  77.     Lock(true);
  78.     SetPortTextStyle(fTextStyle);
  79.     MoveTo(fTextHorzOffset, fTextVertOffset);
  80.     DrawChar(' ');
  81.     DrawString(fText);
  82.     DrawChar(' ');
  83.     Lock(false);
  84.     PenPat(&qd.gray);
  85.     Move(0, fRammeVertOffset - fTextVertOffset);
  86.     LineTo(r.right - 1, fRammeVertOffset);
  87.     LineTo(r.right - 1, r.bottom - 1);
  88.     LineTo(r.left, r.bottom - 1);
  89.     LineTo(0, fRammeVertOffset);
  90.     LineTo(fTextHorzOffset, fRammeVertOffset);
  91. }
  92.  
  93. // =====================================================================
  94. void DoNewsServerPreferencesDialog()
  95. {
  96.     TWindow *window = gViewServer->NewTemplateWindow(kNewsServerPrefsView, nil);
  97.     macroCheckSubView(window, "Could not create NewsServerPrefs window");
  98.     if (!window) 
  99.         return;
  100. // set all the control-states
  101.  
  102.     window->Center(true, true, window->IsModal() );
  103.     gPrefs->GetSilentWindowPosPrefs('WNPe', window);
  104.     CStr255 s, pre, post;
  105.     
  106.     TCheckBox *alwaysAuth = (TCheckBox*) window->FindSubView('AlAu');
  107.     alwaysAuth->SetState(gPrefs->GetBooleanPrefs('AlAu'), kRedraw);
  108.  
  109.     
  110. // News-Server
  111.     TStaticText *serverIPST = (TStaticText*) window->FindSubView('SeIP');
  112.     macroCheckSubView(serverIPST, "Missing server IP static text");
  113.     TStaticText *serverNameST = (TStaticText*) window->FindSubView('SeNa');
  114.     macroCheckSubView(serverNameST, "Missing server name static text");
  115.     
  116.     char cs[40];
  117.     gPrefs->GetStringPrefs('SvNa', s);
  118.     MyGetIndString(pre, kNewsServerPreName);
  119.     MyGetIndString(post, kNewsServerPostName);
  120.     serverNameST->SetText(pre + s + post, kRedraw);
  121.  
  122.     long ip = gPrefs->GetLongPrefs('SvIP');
  123.     sprintf(cs, "%ld.%ld.%ld.%ld",
  124.         (ip >> 24) & 255,
  125.         (ip >> 16) & 255, 
  126.         (ip >>  8) & 255,
  127.         (ip      ) & 255);
  128.     MyGetIndString(pre, kNewsServerPreIP);
  129.     MyGetIndString(post, kNewsServerPostIP);
  130.     serverIPST->SetText(pre + cs + post, kRedraw);
  131.  
  132. // Timeout:
  133.     TNumberText *timeoutNT = (TNumberText*) window->FindSubView('Time');
  134.     macroCheckSubView(timeoutNT, "Missing timeout TNumberText");
  135.     timeoutNT->SetValue(gPrefs->GetLongPrefs('STio'), kRedraw);
  136.  
  137. // Max idle nntp connections
  138.     TNumberText *maxIdleConnectionsNT = (TNumberText*) window->FindSubView('Mntp');
  139.     macroCheckSubView(maxIdleConnectionsNT, "Missing max # idle TNumberText");
  140.     maxIdleConnectionsNT->SetValue(gPrefs->GetLongPrefs('Mntp'), kRedraw);
  141.     
  142. // Max idle time for nntp connections
  143.     TNumberText *maxIdleTimeNT = (TNumberText*) window->FindSubView('Tntp');
  144.     macroCheckSubView(maxIdleTimeNT, "Missing max idle time TNumberText");
  145.     long maxIdle = gPrefs->GetLongPrefs('Tntp') / 60 / 60;
  146.     maxIdleTimeNT->SetValue(maxIdle, kRedraw);
  147.  
  148. // Max articles in XHDR command
  149.     TNumberText *maxXHDRArticlesNT = (TNumberText*) window->FindSubView('XHSz');
  150.     macroCheckSubView(maxXHDRArticlesNT, "Missing maxXHDRArticlesNT TNumberText");
  151.     maxXHDRArticlesNT->SetValue(gPrefs->GetLongPrefs('XHSz'), kRedraw);
  152.  
  153. // Max articles in XHDR command
  154.     TNumberText *poolNewNT = (TNumberText*) window->FindSubView('CNAT');
  155.     macroCheckSubView(poolNewNT, "Missing poolNewNT TNumberText");
  156.     poolNewNT->SetValue(gPrefs->GetLongPrefs('CNAT'), kRedraw);
  157.  
  158. // TCHR
  159.     TPopup *transPU = (TPopup*)window->FindSubView('Tran');
  160.     macroCheckSubView(transPU, "Missing transPU TPopup");
  161.     MenuHandle transMenuH = MAGetMenu(mNewsServerTranslateMenu);
  162.     FailNILResource(Handle(transMenuH));
  163.     if (!CountMItems(transMenuH))
  164.     {
  165.         AddResMenu(transMenuH, 'TCHR');
  166.         NeedCalcMenuSize(transMenuH);
  167.         transPU->SetLongMax(transPU->GetNumberOfItems(), kDontRedraw);
  168.     }
  169.     short itemNo = CountMItems(transMenuH);
  170.     CStr255 currentTransName;
  171.     gPrefs->GetStringPrefs('Tran', currentTransName);
  172.     while (itemNo >= 1)
  173.     {
  174.         CStr255 itemName;
  175.         GetItem(transMenuH, itemNo, itemName);
  176.         if (itemName == currentTransName)
  177.         {
  178.             transPU->SetCurrentItem(itemNo, !kRedraw);
  179.             break;
  180.         }
  181.         itemNo--;
  182.     }
  183.  
  184. // show the thing
  185.     window->Open();
  186.     IDType dismisser = MyPoseModally(window);
  187.     gPrefs->SetWindowPosPrefs('WNPe', window);
  188.     if (dismisser != 'ok  ')
  189.     {
  190.         window->CloseByUser();
  191.         return;
  192.     }
  193.     gPrefs->SetBooleanPrefs('AlAu', alwaysAuth->IsOn());
  194.     GetItem(transMenuH, transPU->GetVal(), currentTransName);
  195.     gPrefs->SetStringPrefs('Tran', currentTransName);
  196.     LoadTranslateTable(currentTransName, gMac2NetAscii, gNetAscii2Mac);
  197.  
  198.     gPrefs->SetLongPrefs('CNAT', poolNewNT->GetValue());
  199.     gPrefs->SetLongPrefs('XHSz', maxXHDRArticlesNT->GetValue());
  200.     gPrefs->SetLongPrefs('STio', timeoutNT->GetValue());
  201.     long maxIdleConnections = maxIdleConnectionsNT->GetValue();
  202.     gPrefs->SetLongPrefs('Mntp', maxIdleConnections);
  203.     long maxIdleTime = maxIdleTimeNT->GetValue() * 60 * 60;
  204.     gPrefs->SetLongPrefs('Tntp', maxIdleTime);
  205.     gNntpCache->UpdateTiming();
  206.  
  207.     window->Show(false, kDontRedraw);    
  208.     gArticleTextCache->FlushCache(); // changes translate table
  209.     window->CloseByUser();
  210. }
  211.  
  212. // =====================================================================
  213. // --------------------------------------------------------------------------
  214. // now some _realy_ ugly code that checks the names
  215. void ShowTheNameError(short rsrcID, short errorIndex)
  216. {
  217.     CStr255 msg;
  218.     GetIndString(msg, rsrcID, errorIndex);
  219.     ParamText(gEmptyString, gEmptyString, gEmptyString, msg);
  220.     StdAlert(phNameError);
  221. }
  222.  
  223. Boolean CheckIt(TEditText *et,
  224.                                 short minNoAT, short maxNoAT, 
  225.                                 Boolean allowLB, // <> allowed
  226.                                 short rsrcID)
  227. {
  228.     CStr255 text;
  229.     et->GetText(text);
  230.     if (text.Length() == 0)
  231.     {
  232.         et->BecomeTarget();
  233.         et->SetSelection(0, 0, kRedraw);
  234.         ShowTheNameError(rsrcID, 1);
  235.         return false;
  236.     }
  237.     short numAT = 0;
  238.     short numC = 0;
  239.     for (short i = 1; i <= text.Length(); i++)
  240.     {
  241.         char ch = text[i];
  242.         if (ch == '@')
  243.         {
  244.             numAT++;
  245.             if (numAT > maxNoAT)
  246.             {
  247.                 et->BecomeTarget();
  248.                 et->SetSelection(i - 1, i, kRedraw);
  249.                 ShowTheNameError(rsrcID, 2);
  250.                 return false;
  251.             }
  252.         }
  253.         if (ch == '(')
  254.             numC++;
  255.         if (ch == ')')
  256.         {
  257.             numC--;
  258.             if (numC < 0)
  259.             {
  260.                 et->BecomeTarget();
  261.                 et->SetSelection(i - 1, i, kRedraw);
  262.                 ShowTheNameError(rsrcID, 5);
  263.                 return false;
  264.             }
  265.         }
  266.         if (!allowLB && (ch == '<' || ch == '>'))
  267.         {
  268.             et->BecomeTarget();
  269.             et->SetSelection(i - 1, i, kRedraw);
  270.             ShowTheNameError(rsrcID, 4);
  271.             return false;
  272.         }
  273.     }
  274.     if (numAT < minNoAT)
  275.     {
  276.         et->BecomeTarget();
  277.         et->SetSelection(0, text.Length(), kRedraw);
  278.         ShowTheNameError(rsrcID, 3);
  279.         return false;
  280.     }
  281.     if (numC)
  282.     {
  283.         et->BecomeTarget();
  284.         et->SetSelection(0, text.Length(), kRedraw);
  285.         ShowTheNameError(rsrcID, 5);
  286.         return false;
  287.     }
  288.     return true;
  289. }
  290.  
  291. void DoYourNamePreferencesDialog()
  292. {
  293.     TWindow *window = gViewServer->NewTemplateWindow(kYourNamePrefsView, nil);
  294.     if (!window) 
  295.         return;
  296. // set all the control-states
  297.  
  298.     window->Center(true, true, window->IsModal() );
  299.     gPrefs->GetSilentWindowPosPrefs('WYPe', window);
  300.     CStr255 s;
  301.     
  302. // Names
  303.     TEditText *realNameET = (TEditText*)window->FindSubView('Name');
  304.     TEditText *snailNameET = (TEditText*)window->FindSubView('@adr');
  305.     TEditText *organizationET = (TEditText*)window->FindSubView('Orga');
  306.  
  307.     CStr255 realName;
  308.     gPrefs->GetStringPrefs('Name', realName);
  309.     realNameET->SetText(realName, kRedraw);
  310.  
  311.     CStr255 snailName;
  312.     gPrefs->GetStringPrefs('@adr', snailName);
  313.     snailNameET->SetText(snailName, kRedraw);
  314.  
  315.     CStr255 orgaName;
  316.     gPrefs->GetStringPrefs('Orga', orgaName);
  317.     organizationET->SetText(orgaName, kRedraw);
  318.  
  319. // show the thing
  320.     window->Open();
  321.     while (true)
  322.     {
  323.         IDType dismisser = MyPoseModally(window);
  324.         gPrefs->SetWindowPosPrefs('WYPe', window);
  325.         if (dismisser != 'ok  ')
  326.         {
  327.             window->CloseByUser();
  328.             return;
  329.         }
  330.         if (!CheckIt(realNameET, 0, 0, false, kYourNameErrorStrings))
  331.             continue;
  332.         if (!CheckIt(snailNameET, 1, 1, false, kYourSnailErrorStrings))
  333.             continue;
  334.         if (!CheckIt(organizationET, 0, 32767, true, kOrganizErrorStrings))
  335.             continue;
  336.         break;
  337.     }
  338.     realNameET->GetText(realName);
  339.     gPrefs->SetStringPrefs('Name', realName);
  340.     snailNameET->GetText(snailName);
  341.     gPrefs->SetStringPrefs('@adr', snailName);
  342.     organizationET->GetText(orgaName);
  343.     gPrefs->SetStringPrefs('Orga', orgaName);
  344.  
  345.     window->Show(false, kDontRedraw);    
  346.     window->CloseByUser();
  347.     gPrefs->SetBooleanPrefs('NaOK', true);
  348. }
  349.  
  350. // =====================================================================
  351. // =====================================================================
  352. void AskFolderDoEvent(void *, TView *view, EventNumber, TEventHandler*, TEvent*)
  353. {
  354.     TWindow *w = view->GetWindow();
  355.     TCheckBox *askFilenameCB = (TCheckBox*) w->FindSubView('AsFn');
  356.     TFolderSelectView *folSel = (TFolderSelectView*)w->FindSubView('ChFo');
  357.     Boolean askFilename = askFilenameCB->IsOn();
  358.     folSel->DimState(askFilename, kRedraw);
  359.     TCheckBox *useUUname = (TCheckBox*) w->FindSubView('_UU_');
  360.     if (askFilename)
  361.         useUUname->SetState(false, !kRedraw);
  362.     useUUname->DimState(askFilename, kRedraw);
  363. }
  364.  
  365. void AskLaunchExtractorDoEvent(void *, TView *view, EventNumber, TEventHandler*, TEvent*)
  366. {
  367.     TWindow *w = view->GetWindow();
  368.     TCheckBox *doLaunchCB = (TCheckBox*) w->FindSubView('BLau');
  369.     TFileSelectView *applSel = (TFileSelectView*)w->FindSubView('BLID');
  370.     Boolean doLaunch = doLaunchCB->IsOn();
  371.     applSel->DimState(!doLaunch, kRedraw);
  372.     TCheckBox *odocCB = (TCheckBox*) w->FindSubView('BLOP');
  373.     odocCB->DimState(!doLaunch, kRedraw);
  374. }
  375.  
  376. void DoBinariesPreferencesDialog()
  377. {
  378.     TWindow *window = gViewServer->NewTemplateWindow(kBinariesPrefsView, nil);
  379.     if (!window) 
  380.         return;
  381. // set all the control-states
  382.  
  383.     window->Center(true, true, window->IsModal() );
  384.     gPrefs->GetSilentWindowPosPrefs('WBPe', window);
  385.     CStr255 s;
  386.     
  387. // Extracting binaries
  388.     TCheckBox *askFilenameCB = (TCheckBox*) window->FindSubView('AsFn');
  389.     TCheckBox *doLaunchCB = (TCheckBox*) window->FindSubView('BLau');
  390.     TCheckBox *odocCB = (TCheckBox*) window->FindSubView('BLOP');
  391.     TCheckBox *useUUname = (TCheckBox*) window->FindSubView('_UU_');
  392.     TFolderSelectView *folSel = (TFolderSelectView*)window->FindSubView('ChFo');
  393.     folSel->InitializeFromPreferences('FBin');
  394.  
  395.     TFileSelectView *applSel = (TFileSelectView*)window->FindSubView('BLID');
  396.     macroCheckSubView(applSel, "applSel");
  397.     applSel->SpecifyFileTypes('APPL', '????');
  398.     applSel->InitializeFromPreferences('BLid');
  399.  
  400.     Boolean doLaunch = gPrefs->GetBooleanPrefs('BLau');
  401.     doLaunchCB->SetState(doLaunch, kRedraw);
  402.     AddActionBehaviour(doLaunchCB, AskLaunchExtractorDoEvent, nil);
  403.     odocCB->SetState(gPrefs->GetBooleanPrefs('BLOP'), kRedraw);
  404.     applSel->DimState(!doLaunch, kRedraw);
  405.     odocCB->DimState(!doLaunch, kRedraw);
  406.     
  407.     Boolean askFilename = gPrefs->GetBooleanPrefs('BiAs');
  408.     askFilenameCB->SetState(askFilename, kRedraw);
  409.     AddActionBehaviour(askFilenameCB, AskFolderDoEvent, nil);
  410.     
  411.     folSel->DimState(askFilename, kRedraw);
  412.     useUUname->DimState(askFilename, kRedraw);
  413.     useUUname->SetState(gPrefs->GetBooleanPrefs('UUna'), kRedraw);
  414.     
  415. // show the thing
  416.     window->Open();
  417.     IDType dismisser = MyPoseModally(window);
  418.     gPrefs->SetWindowPosPrefs('WBPe', window);
  419.     if (dismisser != 'ok  ')
  420.     {
  421.         window->CloseByUser();
  422.         return;
  423.     }
  424.     window->Show(false, kDontRedraw);
  425.     
  426.     gPrefs->SetBooleanPrefs('BLau', doLaunchCB->IsOn());
  427.     gPrefs->SetBooleanPrefs('BLOP', odocCB->IsOn());
  428.     gPrefs->SetBooleanPrefs('BiAs', askFilenameCB->IsOn());
  429.     gPrefs->SetBooleanPrefs('UUna', useUUname->IsOn());
  430.     folSel->StoreInPreferences('FBin');
  431.     applSel->StoreInPreferences('BLid');
  432.     window->CloseByUser();
  433. }
  434. // =====================================================================
  435. void DoEditorPreferencesDialog()
  436. {
  437.     TWindow *window = gViewServer->NewTemplateWindow(kEditorPrefsView, nil);
  438.     if (!window) 
  439.         return;
  440. // set all the control-states
  441.  
  442.     window->Center(true, true, window->IsModal() );
  443.     gPrefs->GetSilentWindowPosPrefs('WEPe', window);
  444.     CStr255 s;
  445.     
  446. // Editor
  447.     TCheckBox *defaultUseSignatureCB = (TCheckBox*) window->FindSubView('UsSi');
  448.     macroCheckSubView(defaultUseSignatureCB, "defaultUseSignatureCB");
  449.     defaultUseSignatureCB->SetState(gPrefs->GetBooleanPrefs('DUSi'), kRedraw);
  450.  
  451.     TFileSelectView *applSel = (TFileSelectView*)window->FindSubView('ChEd');
  452.     macroCheckSubView(applSel, "applSel");
  453.     applSel->SpecifyFileTypes('APPL', '????');
  454.     applSel->InitializeFromPreferences('EDid');
  455.  
  456.     TFolderSelectView *folderSel = (TFolderSelectView*)window->FindSubView('ChFo');
  457.     macroCheckSubView(folderSel, "folderSel");
  458.     folderSel->InitializeFromPreferences('FEdi');
  459.     
  460. // signature
  461.     TFileSelectView *sigFile = (TFileSelectView*) window->FindSubView('ChSi');
  462.     macroCheckSubView(sigFile, "sigFile");
  463.     sigFile->SpecifyFileTypes('TEXT', '????');
  464.     sigFile->InitializeFromPreferences('Sigu');
  465.  
  466.     TCheckBox *editSignatureCB = (TCheckBox*) window->FindSubView('EdSi');
  467.     macroCheckSubView(editSignatureCB, "editSignatureCB");
  468.     editSignatureCB->SetState(gPrefs->GetBooleanPrefs('EdSi'), kRedraw);
  469.     
  470.     TCheckBox *editHeadersCB = (TCheckBox*) window->FindSubView('EdHe');
  471.     macroCheckSubView(editHeadersCB, "editHeadersCB");
  472.     editHeadersCB->SetState(gPrefs->GetBooleanPrefs('EdHe'), kRedraw);
  473.  
  474. // auto wrap
  475.     TNumberText *wrapNT = (TNumberText*) window->FindSubView('WrLn');
  476.     macroCheckSubView(wrapNT, "Missing auto-wrap TNumberText");
  477.     wrapNT->SetValue(gPrefs->GetLongPrefs('WrLn'), kRedraw);
  478.  
  479. // ISO-2022 encoding for posting
  480.     TCheckBox *encodeCB = (TCheckBox*) window->FindSubView('2022');
  481.     macroCheckSubView(encodeCB, "encodeCB");
  482.     encodeCB->SetState(gPrefs->GetBooleanPrefs('2022'), kRedraw);
  483.  
  484. // show the thing
  485.     window->Open();
  486.     IDType dismisser = MyPoseModally(window);
  487.     gPrefs->SetWindowPosPrefs('WEPe', window);
  488.     if (dismisser != 'ok  ')
  489.     {
  490.         window->CloseByUser();
  491.         return;
  492.     }
  493.     window->Show(false, kDontRedraw);
  494.     
  495.     folderSel->StoreInPreferences('FEdi');
  496.     applSel->StoreInPreferences('EDid');
  497.     if (applSel->GotFile())
  498.         gPrefs->SetSignaturePrefs('EDsi', applSel->GetFileSignature());
  499.     gPrefs->SetBooleanPrefs('DUSi', defaultUseSignatureCB->IsOn());
  500.     gPrefs->SetBooleanPrefs('EdSi', editSignatureCB->IsOn());
  501.     gPrefs->SetBooleanPrefs('EdHe', editHeadersCB->IsOn());
  502.     sigFile->StoreInPreferences('Sigu');
  503.     gPrefs->SetLongPrefs('WrLn', wrapNT->GetValue());
  504.     gPrefs->SetBooleanPrefs('2022', encodeCB->IsOn());
  505.     window->CloseByUser();
  506. }
  507.  
  508. // =====================================================================
  509. void AskUseMailerLaunchDocDoEvent(void *, TView *view, EventNumber, TEventHandler*, TEvent*)
  510. {
  511.     TWindow *w = view->GetWindow();
  512.     TCheckBox *useDocCB = (TCheckBox*) w->FindSubView('EuOp');
  513.     TFileSelectView *docSel = (TFileSelectView*)w->FindSubView('Eudo');
  514.     Boolean useDoc = useDocCB->IsOn();
  515.     docSel->DimState(!useDoc, kRedraw);
  516. }
  517.  
  518. void DoMailerPreferencesDialog()
  519. {
  520.     TWindow *window = gViewServer->NewTemplateWindow(kMailerPrefsView, nil);
  521.     if (!window) 
  522.         return;
  523. // set all the control-states
  524.  
  525.     window->Center(true, true, window->IsModal() );
  526.     gPrefs->GetSilentWindowPosPrefs('WMPe', window);
  527.     CStr255 s;
  528.     
  529. // Eudora application
  530.     TFileSelectView *eudoraAppl = (TFileSelectView*) window->FindSubView('EuAp');
  531.     macroCheckSubView(eudoraAppl, "eudoraAppl");
  532.     eudoraAppl->SpecifyFileTypes('APPL', 'CSOm');
  533.     eudoraAppl->InitializeFromPreferences('EuAp');    
  534.  
  535. // Eudora document
  536.     TFileSelectView *eudoraFile = (TFileSelectView*) window->FindSubView('Eudo');
  537.     macroCheckSubView(eudoraFile, "eudoraFile");
  538.     eudoraFile->SpecifyFileTypes('PREF', 'CSOm');
  539.     eudoraFile->InitializeFromPreferences('Eudo');    
  540.  
  541.     TCheckBox *useDocCB = (TCheckBox*) window->FindSubView('EuOp');
  542.     macroCheckSubView(useDocCB, "useDocCB");
  543.     Boolean useDoc = gPrefs->GetBooleanPrefs('EuOp');
  544.     useDocCB->SetState(useDoc, kRedraw);
  545.     eudoraFile->DimState(!useDoc, kRedraw);
  546.     AddActionBehaviour(useDocCB, AskUseMailerLaunchDocDoEvent, nil);    
  547.  
  548. // show the thing
  549.     window->Open();
  550.     IDType dismisser = MyPoseModally(window);
  551.     gPrefs->SetWindowPosPrefs('WMPe', window);
  552.     if (dismisser != 'ok  ')
  553.     {
  554.         window->CloseByUser();
  555.         return;
  556.     }
  557.     window->Show(false, kDontRedraw);
  558.     
  559.     eudoraAppl->StoreInPreferences('EuAp');
  560.     eudoraFile->StoreInPreferences('Eudo');
  561.     gPrefs->SetBooleanPrefs('EuOp', useDocCB->IsOn());
  562.  
  563.     window->CloseByUser();
  564. }
  565. // =====================================================================
  566. void DoMiscPreferencesDialog()
  567. {
  568.     TWindow *window = gViewServer->NewTemplateWindow(kMiscPrefsView, nil);
  569.     if (!window) 
  570.         return;
  571. // set all the control-states
  572.  
  573.     window->Center(true, true, window->IsModal() );
  574.     gPrefs->GetSilentWindowPosPrefs('WIPe', window);
  575.     
  576. // Notes folder
  577.     TFolderSelectView *folderSel = (TFolderSelectView*)window->FindSubView('ChFo');
  578.     macroCheckSubView(folderSel, "folderSel");
  579.     folderSel->InitializeFromPreferences('FNot');
  580.  
  581. // Auto update
  582.     TCheckBox *autoUpdateCB = (TCheckBox*) window->FindSubView('AuUp');
  583.     macroCheckSubView(autoUpdateCB, "autoUpdateCB");
  584.     autoUpdateCB->SetState(gPrefs->GetBooleanPrefs('AuUp'), kRedraw);
  585.     
  586. // Check for new groups at startup
  587.     TCheckBox *checkNewGroupsCB = (TCheckBox*) window->FindSubView('ChNw');
  588.     macroCheckSubView(checkNewGroupsCB, "checkNewGroupsCB");
  589.     checkNewGroupsCB->SetState(gPrefs->GetBooleanPrefs('ChNw'), kRedraw);
  590.  
  591. // Save open windows
  592.     TCheckBox *saveWindowsInfoCB = (TCheckBox*) window->FindSubView('WSav');
  593.     macroCheckSubView(saveWindowsInfoCB, "saveWindowsInfoCB");
  594.     saveWindowsInfoCB->SetState(gPrefs->GetBooleanPrefs('WSav'), kRedraw);
  595.     
  596. // Article cache size:
  597.     TNumberText *articleCacheSizeNT = (TNumberText*) window->FindSubView('AMem');
  598.     macroCheckSubView(articleCacheSizeNT, "Missing article cache size TNumberText");
  599.     articleCacheSizeNT->SetValue(gPrefs->GetLongPrefs('AMem') / 1024, kRedraw);
  600.  
  601. // Max number of articles in group database:
  602.     TNumberText *maxArticlesInGroupNT = (TNumberText*) window->FindSubView('Mart');
  603.     macroCheckSubView(maxArticlesInGroupNT, "Missing max articles in DB TNumberText");
  604.     maxArticlesInGroupNT->SetValue(gPrefs->GetLongPrefs('Mart'), kRedraw);
  605.  
  606. // show the thing
  607.     window->Open();
  608.     IDType dismisser = MyPoseModally(window);
  609.     gPrefs->SetWindowPosPrefs('WIPe', window);
  610.     if (dismisser != 'ok  ')
  611.     {
  612.         window->CloseByUser();
  613.         return;
  614.     }
  615.     window->Show(false, kDontRedraw);
  616.     
  617.     folderSel->StoreInPreferences('FNot');
  618.     gPrefs->SetBooleanPrefs('AuUp', autoUpdateCB->IsOn());
  619.     gPrefs->SetBooleanPrefs('ChNw', checkNewGroupsCB->IsOn());
  620.     gPrefs->SetBooleanPrefs('WSav', saveWindowsInfoCB->IsOn());
  621.     gPrefs->SetLongPrefs('AMem', articleCacheSizeNT->GetValue() * 1024);
  622.     gPrefs->SetLongPrefs('Mart', maxArticlesInGroupNT->GetValue());
  623.  
  624.     window->CloseByUser();
  625. }
  626.