-
Notifications
You must be signed in to change notification settings - Fork 0
/
Inetnav.cpp
2933 lines (2426 loc) · 77.4 KB
/
Inetnav.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// inetnav.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "inetnav.h"
#include "dialogs.h"
#include "propshts.h"
#include "mainfrm.h"
#include "finger.h"
#include "ftp.h"
#include "text.h"
#include "gopher.h"
#include "mail.h"
#include "news.h"
#include "ircdoc.h"
#include "ircview.h"
#include "ircwnd.h"
#include "whoisdoc.h"
#include "whoiswnd.h"
#include "whoisvw.h"
#include "mainmenu.h" // for Main Menu area
#include "helpinfo.h" // for Help & Information area
#include "prefview.h" // for Preferences area
#include "prefsdoc.h" // for Preferences area
#include "tipofday.h"
#include "askstaff.h"
#include <direct.h>
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp
BEGIN_MESSAGE_MAP(CInternetNavApp, CWinApp)
//{{AFX_MSG_MAP(CInternetNavApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_FILE_NEW, DisplayMainMenu)
ON_COMMAND(ID_NEW_TEXT, OnNewTextFile)
ON_COMMAND(ID_PLACES_FINGER, OnPlacesFinger)
ON_COMMAND(ID_PLACES_WHOIS, OnPlacesWhois)
ON_COMMAND(ID_PLACES_FTP_CLIENT, OnPlacesFTPClient)
ON_COMMAND(ID_PLACES_POST_OFFICE, OnPlacesPostOffice)
ON_COMMAND(ID_PLACES_PREFERENCES, OnPlacesPreferences)
ON_COMMAND(ID_PLACES_HELPINFO, OnPlacesHelpAndInfo)
ON_COMMAND(ID_PLACES_CHAT_CENTER, OnPlacesChatCenter)
ON_COMMAND(ID_PLACES_NEWSGROUPS, OnPlacesNewsgroups)
ON_COMMAND(ID_PLACES_GOPHER_CENTER, OnPlacesGopherCenter)
ON_COMMAND(ID_PLACES_SIGN_ON, OnPlacesSignOn)
ON_UPDATE_COMMAND_UI(ID_PLACES_SIGN_ON, OnUpdatePlacesSignOn)
ON_COMMAND(ID_PLACES_SIGN_OFF, OnPlacesSignOff)
ON_UPDATE_COMMAND_UI(ID_PLACES_SIGN_OFF, OnUpdatePlacesSignOff)
ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateDisplayMainMenu)
ON_UPDATE_COMMAND_UI(ID_PLACES_CHAT_CENTER, OnUpdatePlacesChatCenter)
ON_UPDATE_COMMAND_UI(ID_PLACES_FINGER, OnUpdatePlacesFinger)
ON_UPDATE_COMMAND_UI(ID_PLACES_FTP_CLIENT, OnUpdatePlacesFTPClient)
ON_UPDATE_COMMAND_UI(ID_PLACES_GOPHER_CENTER, OnUpdatePlacesGopherCenter)
ON_UPDATE_COMMAND_UI(ID_PLACES_NEWSGROUPS, OnUpdatePlacesNewsgroups)
ON_UPDATE_COMMAND_UI(ID_PLACES_WHOIS, OnUpdatePlacesWhois)
ON_COMMAND(ID_APP_EXIT, OnAppExit)
ON_COMMAND(ID_CHAT_JOIN_GROUP, OnChatJoinGroup)
ON_UPDATE_COMMAND_UI(ID_CHAT_JOIN_GROUP, OnUpdateChatJoinGroup)
ON_COMMAND(ID_CHAT_SEND_COMMAND, OnChatSendCommand)
ON_COMMAND(ID_TIP_OF_DAY, OnTipOfDay)
ON_UPDATE_COMMAND_UI(ID_PLACES_POST_OFFICE, OnUpdatePlacesPostOffice)
ON_COMMAND(ID_MAILBOX_COMPOSE_OFFLINE, OnMailboxCompose)
ON_COMMAND(ID_ARTICLE_ADD_OFFLINE, OnArticleAdd)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_MAILBOX_CHECK, OnMailboxCheck)
ON_COMMAND(ID_CANCEL_CALL, OnCancelCall)
ON_COMMAND(ID_INTERNET_MAILBOXES, OnInternetMailboxes)
ON_COMMAND(ID_GOPHER_SITE, OnPlacesGopherCenter)
//}}AFX_MSG_MAP
// Standard ID_HELP command
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
// Standard file based document commands
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
// Default Help command -- shows Help & Info area
ON_COMMAND(ID_DEFAULT_HELP, OnPlacesHelpAndInfo)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp construction
CInternetNavApp::CInternetNavApp()
{
// TODO: add construction code here
m_pStatusBar = NULL;
m_bTopLevelMenu = TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CInternetNavApp object
CInternetNavApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp initialization
BOOL CInternetNavApp::InitInstance()
{
CWaitCursor wait;
// Initialize data structures
m_userData.Attach(this);
m_prefs.Initialize(this);
m_bToolTipsOff = FALSE;
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
SetDialogBkColor();
CInternetNavApp::Serialize(FALSE); // Load information from INI
UseCTL3D(Ctl3dRegister(AfxGetInstanceHandle()));
if (IsUseCTL3D())
Ctl3dAutoSubclass(AfxGetInstanceHandle());
if (m_lpCmdLine[0] != '/' && m_lpCmdLine[1] != 'S')
{
if (m_wndSplash.Create())
{
wait.Restore();
m_wndSplash.ShowWindow(SW_SHOW);
m_wndSplash.CenterWindow(CWnd::GetDesktopWindow());
m_wndSplash.UpdateWindow();
}
}
wait.Restore();
// create main MDI Frame window
TRY
{
m_pMainFrame = new CMainFrame;
}
CATCH(CMemoryException, pMemoryException)
{
AfxMessageBox("Insufficient system resources to create main window.");
return FALSE;
}
END_CATCH
if (m_lpCmdLine[0] == '/' && m_lpCmdLine[1] == 'S')
m_pMainFrame->m_bCreateToolBar = m_pMainFrame->m_bCreateStatBar = FALSE;
else
m_pMainFrame->m_bCreateToolBar = m_pMainFrame->m_bCreateStatBar = TRUE;
if (!m_pMainFrame->LoadFrame(IDR_MAINFRAME,
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL))
{
AfxMessageBox("Insufficient system resources to create main window.");
return FALSE;
}
m_pMainWnd = m_pMainFrame;
m_pStatusBar = GetMainFrame()->GetStatusBar();
// If we made it this far,
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
// In Internet Navigator, each document type can retrieve and display
// different types of information from the Internet.
m_pTextTXT = new CMultiDocTemplate(
IDR_TEXTTYPE,
RUNTIME_CLASS(CTextDoc),
RUNTIME_CLASS(CTextWnd), // custom MDI child frame
RUNTIME_CLASS(CTextView));
AddDocTemplate(m_pTextTXT);
m_pFinger = new CMultiDocTemplate(
IDR_FINGERTYPE,
RUNTIME_CLASS(CFingerDoc),
RUNTIME_CLASS(CFingerWnd), // custom MDI child frame
RUNTIME_CLASS(CFingerView));
AddDocTemplate(m_pFinger);
m_pWhois = new CMultiDocTemplate(
IDR_WHOISTYPE,
RUNTIME_CLASS(CWhoisDoc),
RUNTIME_CLASS(CWhoisWnd), // custom MDI child frame
RUNTIME_CLASS(CWhoisView));
AddDocTemplate(m_pWhois);
m_pFTP = new CMultiDocTemplate(
IDR_FTPTYPE,
RUNTIME_CLASS(CFtpDoc),
RUNTIME_CLASS(CFtpWnd), // custom MDI child frame
RUNTIME_CLASS(CFtpView));
AddDocTemplate(m_pFTP);
m_pMainMenu = new CMultiDocTemplate(
IDR_MAINMENUTYPE,
RUNTIME_CLASS(CMainMenuDoc),
RUNTIME_CLASS(CMainMenuFrm), // custom MDI child frame
RUNTIME_CLASS(CMainMenuView));
AddDocTemplate(m_pMainMenu);
// The Help & Information area
m_pHelpInfoArea = new CMultiDocTemplate(
IDR_HELPINFO,
RUNTIME_CLASS(CHelpInfoDoc),
RUNTIME_CLASS(CHelpInfoWnd),
RUNTIME_CLASS(CHelpInfoView));
AddDocTemplate(m_pHelpInfoArea);
m_pIRCConverse = new CMultiDocTemplate(
IDR_IRCTYPE,
RUNTIME_CLASS(CIRClientDoc),
RUNTIME_CLASS(CIRClientWnd),
RUNTIME_CLASS(CIRClientView));
AddDocTemplate(m_pIRCConverse);
m_pGopherMenu = new CMultiDocTemplate(
IDR_GOPHERMENU,
RUNTIME_CLASS(CGopherDoc),
RUNTIME_CLASS(CGopherWnd),
RUNTIME_CLASS(CGopherMenu));
AddDocTemplate(m_pGopherMenu);
m_pGopherDocument = new CMultiDocTemplate(
IDR_GOPHEROUTPUT,
RUNTIME_CLASS(COutputDoc),
RUNTIME_CLASS(CTextWnd),
RUNTIME_CLASS(COutputView));
AddDocTemplate(m_pGopherDocument);
m_pGopherCenter = new CMultiDocTemplate(
IDR_GOPHCENTERTYPE,
RUNTIME_CLASS(CGophCenterDoc),
RUNTIME_CLASS(CGophCenterWnd),
RUNTIME_CLASS(CGopherCenter));
AddDocTemplate(m_pGopherCenter);
m_pPrefs = new CMultiDocTemplate(
IDR_PREFERENCES,
RUNTIME_CLASS(CPrefsDoc),
RUNTIME_CLASS(CPrefsWnd),
RUNTIME_CLASS(CPrefsView));
AddDocTemplate(m_pPrefs);
m_pMailBox = new CMultiDocTemplate(
IDR_MAILBOXTYPE,
RUNTIME_CLASS(CMailBoxDoc),
RUNTIME_CLASS(CMailBoxWnd),
RUNTIME_CLASS(CMailBoxView));
AddDocTemplate(m_pMailBox);
m_pInbox = new CMultiDocTemplate(
IDR_NEWMAILTYPE,
RUNTIME_CLASS(CMailBoxDoc),
RUNTIME_CLASS(CNewMailWnd),
RUNTIME_CLASS(CNewMailView));
AddDocTemplate(m_pInbox);
m_pMailMessage = new CMultiDocTemplate(
IDR_MESSAGETYPE,
RUNTIME_CLASS(CMailBoxDoc),
RUNTIME_CLASS(CMessageWnd),
RUNTIME_CLASS(CMessageView));
AddDocTemplate(m_pMailMessage);
m_pMailCompose = new CMultiDocTemplate(
IDR_MAILCOMPOSETYPE,
RUNTIME_CLASS(CMailBoxDoc),
RUNTIME_CLASS(CComposeWnd),
RUNTIME_CLASS(CComposeView));
AddDocTemplate(m_pMailCompose);
m_pInternetNewsgroups = new CMultiDocTemplate(
IDR_NEWSAREATYPE,
RUNTIME_CLASS(CNewsDoc),
RUNTIME_CLASS(CNewsWnd),
RUNTIME_CLASS(CNewsView));
AddDocTemplate(m_pInternetNewsgroups);
m_pNewsgroupsManager = new CMultiDocTemplate(
IDR_GROUPMAN,
RUNTIME_CLASS(CNewsDoc),
RUNTIME_CLASS(CNewsgroupsManagerWnd),
RUNTIME_CLASS(CNewsgroupsManager));
AddDocTemplate(m_pNewsgroupsManager);
m_pNewsgroup = new CMultiDocTemplate(
IDR_ARTSELTYPE,
RUNTIME_CLASS(CNewsDoc),
RUNTIME_CLASS(CArticleSelectionWnd),
RUNTIME_CLASS(CArticleSelectionView));
AddDocTemplate(m_pNewsgroup);
m_pNewsArticle = new CMultiDocTemplate(
IDR_ARTICLETYPE,
RUNTIME_CLASS(CNewsDoc),
RUNTIME_CLASS(CArticleWnd),
RUNTIME_CLASS(CArticleView));
AddDocTemplate(m_pNewsArticle);
m_pComposeNewsArticle = new CMultiDocTemplate(
IDR_NEWSCOMPOSETYPE,
RUNTIME_CLASS(CNewsDoc),
RUNTIME_CLASS(CArticleComposeWnd),
RUNTIME_CLASS(CArticleComposeView));
AddDocTemplate(m_pComposeNewsArticle);
m_pAskStaff = new CMultiDocTemplate(
IDR_ASKSTAFF,
RUNTIME_CLASS(CAskStaffDoc),
RUNTIME_CLASS(CAskStaffWnd),
RUNTIME_CLASS(CAskStaffView));
AddDocTemplate(m_pAskStaff);
if (!IsWindows95())
{
// enable file manager drag/drop and DDE Execute open
TRACE0("INF: Enabling DDE Execute Open for File Manager...\r\n");
EnableShellOpen();
TRACE0("INF: Registering file types with Windows Shell...\r\n");
RegisterShellFileTypes();
TRACE0("INF: Enabling drag-and-drop for files...\r\n");
m_pMainWnd->DragAcceptFiles();
}
// simple command line parsing
if (m_lpCmdLine[0] == '\0')
{
// do nothing -- the Sign On function called above shows the
// main menu to the user if the signon was successfull.
// Otherwise, we can't show any windows or areas yet because
// the user is not yet online
// We set m_nCmdShow to SW_SHOWMAXIMIZED here to make sure the
// main window is always shown maximized on startup
m_nCmdShow = SW_SHOWMAXIMIZED;
}
else if (m_lpCmdLine[0] == '/' && m_lpCmdLine[1] == 'S')
{
// first time setup -- guide the user through setting up preferences
// and the connection
CWnd* pParent = NULL;
// TODO: Add code here to guide the user through setup
m_nCmdShow = SW_SHOWMINNOACTIVE;
GetMainFrame()->ShowWindow(m_nCmdShow);
GetMainFrame()->UpdateWindow();
pParent = CWnd::GetActiveWindow();
CInetnavWelcomeDlg theWelcome(pParent);
if (theWelcome.DoModal() == IDCANCEL)
return FALSE; // exit
CInternetNavApp::Serialize(FALSE);
CUserInformation userInfo(pParent);
userInfo.DoModal();
// Now ask the user to set Application Preferences
CAppPrefsSheet appSheet(pParent);
appSheet.Serialize(FALSE);
if (appSheet.DoModal() == IDOK)
appSheet.Serialize(TRUE);
// Now ask the user to choose Internet Preferences
CInetPrefsSheet inetSheet(pParent);
inetSheet.Serialize(FALSE);
if (inetSheet.DoModal() == IDOK)
inetSheet.Serialize(TRUE);
CFtpViruses theDialog(pParent);
theDialog.DoModal();
CWaitCursor wait;
// Set the user up with a new mailbox
// using CInternetNavApp::AddNewMailbox()
AddNewMailbox();
// Have the user set up the Internet Newsgroups area
// using CNewsDoc::OnNewDocument()'s setup procedure
m_pMainFrame->ShowWindow(SW_SHOWMINNOACTIVE);
m_pMainFrame->UpdateWindow();
m_pInternetNewsgroups->OpenDocumentFile(NULL);
m_pMainFrame->ShowWindow(SW_SHOWMINNOACTIVE);
m_pMainFrame->UpdateWindow();
m_pInternetNewsgroups->CloseAllDocuments(TRUE);
m_pMainFrame->ShowWindow(SW_SHOWMINNOACTIVE);
m_pMainFrame->UpdateWindow();
CInternetNavApp::Serialize(TRUE);
// Save the mailbox the user created
SaveMailboxes();
return FALSE;
}
else if (m_lpCmdLine[0] == '/' && m_lpCmdLine[1] == 'M' &&
m_lpCmdLine[2] == 'A' && m_lpCmdLine[3] == 'I')
{
// Create a new Mailbox
AddNewMailbox();
return FALSE;
}
else if (m_lpCmdLine[0] == '/' && m_lpCmdLine[1] == 'N' &&
m_lpCmdLine[2] == 'W' && m_lpCmdLine[3] == 'S')
{
// Create a new Newsgroups Settings file
// Have the user set up the Internet Newsgroups area
// using CNewsDoc::OnNewDocument()'s setup procedure
m_pMainFrame->ShowWindow(SW_SHOWMINNOACTIVE);
m_pMainFrame->UpdateWindow();
m_pInternetNewsgroups->OpenDocumentFile(NULL);
m_pMainFrame->ShowWindow(SW_SHOWMINNOACTIVE);
m_pMainFrame->UpdateWindow();
m_pInternetNewsgroups->CloseAllDocuments(TRUE);
m_pMainFrame->ShowWindow(SW_SHOWMINNOACTIVE);
m_pMainFrame->UpdateWindow();
return FALSE;
}
else
{
// open an existing document
Serialize(TRUE);
CString strLine = m_lpCmdLine;
if (!IsOnline() && strLine.Right(3) == "FNG" ||
strLine.Right(3) == "FTP" || strLine.Right(3) == "WHO" ||
strLine.Right(3) == "IRC")
{
if (!SignOn()) // connect to Internet
return FALSE;
}
if (strLine.Right(4) == ".MAI")
{
OnMailboxCompose();
}
else if (strLine.Right(4) == ".NWS")
{
OnArticleAdd();
}
else
{
OpenDocumentFile(strLine);
}
m_nCmdShow = SW_SHOWMAXIMIZED;
}
if (m_lpCmdLine[0] != '/' && m_lpCmdLine[1] != 'S')
{
// The main window has been initialized, so show and update it.
m_pMainFrame->ShowWindow(m_nCmdShow);
m_pMainFrame->UpdateWindow();
}
BOOL bDontRemoveAll = FALSE;
TRY
{
m_pIRCChanList = new CMapStringToOb(10);
}
CATCH(CMemoryException, e)
{
m_pIRCChanList = NULL;
bDontRemoveAll = TRUE;
SetIRCConnected(FALSE);
m_pIRCSocket = NULL;
return TRUE;
}
END_CATCH
if (!bDontRemoveAll) m_pIRCChanList->RemoveAll();
SetIRCConnected(FALSE);
m_pIRCSocket = NULL;
m_bSaveUserData = TRUE;
LoadMailboxes();
return TRUE;
}
BOOL CInternetNavApp::OnIdle(LONG lCount)
{
return CWinApp::OnIdle(lCount);
}
BOOL CInternetNavApp::PreTranslateMessage(MSG* pMsg)
{
BOOL bResult = CWinApp::PreTranslateMessage(pMsg);
if (m_wndSplash.m_hWnd != NULL &&
(pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_SYSKEYDOWN ||
pMsg->message == WM_LBUTTONDOWN ||
pMsg->message == WM_RBUTTONDOWN ||
pMsg->message == WM_MBUTTONDOWN ||
pMsg->message == WM_NCLBUTTONDOWN ||
pMsg->message == WM_NCRBUTTONDOWN ||
pMsg->message == WM_NCMBUTTONDOWN))
{
if (m_lpCmdLine[0] == '/'&& m_lpCmdLine[1] == 'S')
return bResult;
m_wndSplash.ShowWindow(SW_HIDE);
m_wndSplash.UpdateWindow();
m_wndSplash.DestroyWindow();
m_pMainFrame->UpdateWindow();
if (m_lpCmdLine[0] != '\0')
return bResult;
// Show the user the Tip Of The Day, if they said they want to see it
// in Preferences
if (IsShowTOD() && GetShowTips() == 0)
{
m_bPseudoShowTOD = TRUE;
OnTipOfDay();
}
else
m_bPseudoShowTOD = FALSE;
if (StartOnline() && !IsOnline())
{
m_bPseudoOnline = TRUE;
OnPlacesSignOn();
}
return bResult;
}
return bResult;
}
int CInternetNavApp::ExitInstance()
{
// Cleanup application and system resources
CWaitCursor wait;
// Save mailboxes
SaveMailboxes();
if (IsUseCTL3D())
Ctl3dUnregister(AfxGetInstanceHandle());
CInternetNavApp::Serialize(TRUE);
if (m_pIRCSocket)
delete m_pIRCSocket;
m_pIRCSocket = NULL;
m_pStatusBar = NULL;
if (m_pIRCChanList)
{
m_pIRCChanList->RemoveAll();
delete m_pIRCChanList;
}
m_pIRCChanList = NULL;
m_userData.Detach();
return CWinApp::ExitInstance();
}
// AddToRecentFileList
// Our implementation of this function first calls the base class version
// of this function and then calls
// CInternetNavApp::Serialize(IsStoring=TRUE) to save the MRU file list to
// the INI file.
void CInternetNavApp::AddToRecentFileList(const char* pszPathName)
{
CWaitCursor wait;
// Check pszPathName. Only proceed if there isn't a '.MAI' or a '.NWS'
// on the end of the filename. Otherwise, prevent the filename
// from being added to the MRU list
// So we can deal with pszPathName better, save it in a CString
CString strPathName = pszPathName;
int nEndPosition = strPathName.GetLength() - 1;
if (strPathName.Right(4) == ".MAI" ||
strPathName.Right(4) == ".NWS")
{
return;
}
else if (strPathName[nEndPosition - 3] != '.')
{
// If the path name has no file extension, which would mean
// we weren't even passed a valid filename path name in the first
// place, just ignore it and return
return;
}
// Call the base class version of this function first
CWinApp::AddToRecentFileList(pszPathName);
// Now save the most-recently-used-files list to the INI file and
// return
CInternetNavApp::Serialize(TRUE);
return;
}
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp INI file information helper functions
void CInternetNavApp::Serialize(BOOL IsStoring /*=TRUE*/)
{
// Call CInternetNavApp::SaveStdProfileSettings() to save settings
// or CInternetNavApp::LoadStdProfileSettings() to load settings
// depending on whether or not bSave is TRUE or FALSE.
// Call Serialize functions of data structures so they too can
// read/write their settings to/from the INI file.
GetUserData()->Serialize(IsStoring);
GetPrefs()->Serialize(IsStoring);
if (IsStoring)
{
CInternetNavApp::SaveStdProfileSettings();
}
else
{
CInternetNavApp::LoadStdProfileSettings();
}
return;
}
void CInternetNavApp::LoadStdProfileSettings()
{
CWaitCursor wait;
CWinApp::LoadStdProfileSettings();
CString strGeneralSec = "Global Settings";
m_bWindows95 = GetProfileInt(strGeneralSec, "IsWindows95", TRUE);
// TODO: Add calls here to GetProfileString() and GetProfileInt() to load
// additional global data and preferences from the INI file
return;
}
void CInternetNavApp::SaveStdProfileSettings()
{
CWaitCursor wait;
CWinApp::SaveStdProfileSettings();
// save global settings to INI
CString strGeneralSec = "Global Settings";
WriteProfileInt(strGeneralSec, "IsWindows95", IsWindows95());
// TODO: Add calls to WriteProfileString() and WriteProfileInt() to save
// additional data and preferences to the INI file
return;
}
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp sign on/sign off functions
BOOL CInternetNavApp::SignOn()
{
CWaitCursor wait;
if (!m_bOnline)
OnPlacesSignOn();
wait.Restore();
return IsOnline();
}
BOOL CInternetNavApp::SignOff()
{
CWaitCursor wait;
if (m_bOnline)
OnPlacesSignOff();
wait.Restore();
return !IsOnline();
}
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp FlashConnect helper functions
BOOL CInternetNavApp::SetFlashConnect(BOOL bFlashConnect /*=TRUE*/)
{
CWaitCursor wait;
if (bFlashConnect) // begin FlashConnect
{
CWaitCursor wait;
// Show the 'Begin FlashConnect' message -- if the user presses
// cancel then cancel the FlashConnect
CFlashConnectBegin theMessage(GetMainFrame());
if (theMessage.DoModal() == IDCANCEL) return FALSE;
m_bFlashConnect = TRUE;
// Attempt to connect to the user's Internet provider and begin
// the FlashConnect
if (!SignOn())
return FALSE;
return TRUE;
}
else // end FlashConnect
{
CWaitCursor wait;
// The SetFlashConnect function must always be successful here --
// OnPlacesSignOff() forces the user to disconnect, so SignOff() will
// always return TRUE.
// Show the user the 'End FlashConnect' message
if (!m_bFlashConnectError)
{
CFlashConnectEnd theMessage(GetMainFrame());
theMessage.DoModal();
}
else
{
MessageBeep(-1);
CFlashConnectAbort theMessage(GetMainFrame());
theMessage.DoModal();
m_bFlashConnectError = FALSE;
}
m_pStatusBar->SetText("Ending FlashConnect...");
// Disconnect from the Internet
SignOff();
// set the m_bFlashConnect variable to FALSE
m_bFlashConnect = FALSE;
return TRUE;
}
}
BOOL CInternetNavApp::AbortFlashConnect()
{
// A failed FlashConnect must be aborted -- a fatal repception,
// transmission, or other communication error has occurred
m_bFlashConnectError = TRUE;
SetFlashConnect(FALSE);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp Help & Information helper functions
void CInternetNavApp::EnterHelpArea()
{
CWaitCursor wait;
OnPlacesHelpAndInfo();
}
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp socket helper functions
QSocket* CInternetNavApp::GetNewConnection(BOOL bCreateSocket /*= TRUE*/)
{
CWaitCursor wait;
QSocket* pResult = NULL;
// Try to allocate memory for a new socket
TRY
{
pResult = new QSocket(bCreateSocket);
}
CATCH(CMemoryException, pMemoryException) // a memory allocation error
{
// We were unable to allocate memory for a new connection --
// tell the user that
MessageBeep(-1);
AfxMessageBox(IDP_FAILED_MEMORY_SOCKET_ALLOC, MB_ICONSTOP);
return NULL;
}
END_CATCH
if (pResult)
return pResult;
return NULL;
}
/////////////////////////////////////////////////////////////////////////////
// Directory Chooser common dialog helper
CString CInternetNavApp::DoDirectoryDialog(CWnd* pParent,
CString& strInitialDir)
{
CString strReturn = ""; // return string is chosen directory name
strReturn.Empty();
if (strInitialDir.IsEmpty())
{
strInitialDir = "C:\\";
}
_chdir(strInitialDir);
_chdir(strInitialDir);
_chdir(strInitialDir);
CDirectoryDialog cfdlg(FALSE, NULL, "Junk", OFN_SHOWHELP |
OFN_HIDEREADONLY | OFN_ENABLETEMPLATE,
NULL, pParent);
cfdlg.m_ofn.hwndOwner = pParent->GetSafeHwnd();
cfdlg.m_ofn.hInstance = AfxGetInstanceHandle();
cfdlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(FILEOPENORD);
cfdlg.m_ofn.lpstrTitle = "Select Directory";
cfdlg.m_ofn.lpstrInitialDir = strInitialDir;
if (cfdlg.DoModal() == IDOK)
{
strReturn = cfdlg.GetPathName();
// Find the 'Junk' and chop it off
int nJunk = strReturn.ReverseFind('J');
strReturn = strReturn.Left(nJunk); // since nJunk is 0-based, we
// just chop off the Junk!
// now return the directory name to the caller!
return strReturn;
}
else
{
strReturn = "";
}
return strReturn;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg(CWnd* pParent = NULL);
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInternetNavApp commands
// App command to run the About dialog box
void CInternetNavApp::OnAppAbout()
{
CWaitCursor wait;
CAboutDlg aboutDlg(m_pMainFrame);
aboutDlg.DoModal();
return;
}
void CInternetNavApp::DisplayMainMenu()
{
CWaitCursor wait;
// Show the Main Menu to the user. Since the Main Menu window
// is a form view, we use a document template. Displaying the
// window is like opening a new copy of the document in the
// template, so we call CDocTemplate::OpenDocumentFile with
// no file name parameter (we don't want to open a file; we
// want a new one
if (IsOnline())
{
if (m_pWndMainMenu != NULL &&
::IsWindow(m_pWndMainMenu->GetSafeHwnd()))
{
m_pWndMainMenu->ActivateFrame(SW_RESTORE);
m_pWndMainMenu->BringWindowToTop();
return;
}
m_pMainMenu->OpenDocumentFile(NULL);
return;
}
else
{
UINT nType = MB_OK|MB_ICONSTOP;
MessageBeep(-1);
AfxMessageBox(IDP_INETNAV_SIGN_ON, nType);
return;
}
return;
}
void CInternetNavApp::OnNewTextFile()
{
CWaitCursor wait;
// Make a new document of the Text File template with OpenDocumentFile
// passed a NULL parameter
// Soon, we will ask the user whether or not they want to open
// a TXT file or a HTM file with a dialog box.
// The same template but different file extension will be used for HTM
// files
m_pTextTXT->OpenDocumentFile(NULL);
}
void CInternetNavApp::OnPlacesFinger()
{
CWaitCursor wait;
// Open the Internet Users Information Browser
if (IsOnline())
m_pFinger->OpenDocumentFile(NULL);
else
{
UINT nType = MB_OK|MB_ICONSTOP;
MessageBeep(-1);
AfxMessageBox(IDP_INETNAV_SIGN_ON, nType);
return;
}
return;
// TODO: Add a preferences option here to let the user decide on whether
// or not to have the File Open dialog box be displayed here instead of
// a blank file; this way the user can open a file they've already
// made
}
void CInternetNavApp::OnPlacesWhois()
{
CWaitCursor wait;
// Open the InterNIC Site Information Browser
if (IsOnline())
m_pWhois->OpenDocumentFile(NULL);
else
{
UINT nType = MB_OK|MB_ICONSTOP;
MessageBeep(-1);