00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "EnterKeyDlg.h"
00009 #include "fsUrlsToDownloadRegKeyMgr.h"
00010 #include "mfchelp.h"
00011 #include "SiteManagerSheet.h"
00012
00013 #include "MainFrm.h"
00014 #include "fsPluginMgr.h"
00015 #include "DownloadsWnd.h"
00016 #include "ShedulerWnd.h"
00017 #include "PrgSheet.h"
00018 #include "DialDlg.h"
00019 #include "system.h"
00020 #include "SitesWnd.h"
00021 #include "HFEWnd.h"
00022 #include "SpiderWnd.h"
00023 #include "inetutil.h"
00024 #include "DlgExportDownloads.h"
00025 #include "DlgFind.h"
00026 #include "Dlg_SpreadHelp2.h"
00027 #include "Dlg_TUMChanged.h"
00028 #include "Dlg_ShutdownType.h"
00029 #include "DlgExportHistory.h"
00030 #include "Dlg_ChooseGroup.h"
00031 #include "vmsFirefoxMonitoring.h"
00032 #include "MyMessageBox.h"
00033 #include "Dlg_MakePortableVer.h"
00034 #include "FlashVideoDownloadsWnd.h"
00035 #include "UploadsWnd.h"
00036
00037 #ifdef _DEBUG
00038 #define new DEBUG_NEW
00039 #undef THIS_FILE
00040 static char THIS_FILE[] = __FILE__;
00041 #endif
00042
00043 #define WM_TRAYMSG (WM_APP + 100)
00044 #define ID_TUM_CHANGED 36999
00045 #define ID_SWITCH_TO_START 37000
00046 #define ID_SWITCH_TO_END (ID_SWITCH_TO_START+100)
00047 #define ID_LNGMENU_START (ID_SWITCH_TO_END+1)
00048 #define ID_LNGMENU_END (ID_LNGMENU_START+100)
00049 #define ID_THREAD_UPDATE (10000)
00050
00051 extern fsPluginMgr _PluginMgr;
00052 extern CDownloadsWnd* _pwndDownloads;
00053 extern CHFEWnd *_pwndHFE;
00054 extern CShedulerWnd* _pwndScheduler;
00055 extern CSitesWnd* _pwndSites;
00056 extern CSpiderWnd* _pwndSpider;
00057
00058 IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
00059
00060 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
00061
00062 ON_WM_CREATE()
00063 ON_WM_SETFOCUS()
00064 ON_WM_CLOSE()
00065 ON_COMMAND(ID_DLDDEFOPTIONS, OnDlddefoptions)
00066 ON_COMMAND(ID_DLDROPTIONS, OnDldroptions)
00067 ON_COMMAND(ID_TUM_HEAVY, OnTumHeavy)
00068 ON_UPDATE_COMMAND_UI(ID_TUM_HEAVY, OnUpdateTumHeavy)
00069 ON_COMMAND(ID_TUM_LIGHT, OnTumLight)
00070 ON_UPDATE_COMMAND_UI(ID_TUM_LIGHT, OnUpdateTumLight)
00071 ON_COMMAND(ID_TUM_MEDIUM, OnTumMedium)
00072 ON_UPDATE_COMMAND_UI(ID_TUM_MEDIUM, OnUpdateTumMedium)
00073 ON_COMMAND(ID_OPTMASTER, OnOptmaster)
00074 ON_COMMAND(ID_DLD_CREATE, OnDldCreate)
00075 ON_COMMAND(ID_TASK_CREATE_NEW, OnTaskCreateNew)
00076 ON_COMMAND(ID_NEED_EXIT, OnNeedExit)
00077 ON_WM_SIZE()
00078 ON_WM_INITMENUPOPUP()
00079 ON_COMMAND(ID_SAVEALL, OnSaveall)
00080 ON_COMMAND(ID_APP_EXIT, OnAppExit)
00081 ON_WM_MEASUREITEM()
00082 ON_WM_DRAWITEM()
00083 ON_COMMAND(ID_SHOWMAINWINDOW, OnShowmainwindow)
00084 ON_COMMAND(ID_STARTALL, OnStartall)
00085 ON_COMMAND(ID_STOPALL, OnStopall)
00086 ON_COMMAND(ID_HELP, OnHelp)
00087 ON_COMMAND(ID_HOMEPAGE, OnHomepage)
00088 ON_COMMAND(ID_RECOMMEND, OnRecommend)
00089 ON_COMMAND(ID_SUPPORT, OnSupport)
00090 ON_COMMAND(ID_UPDATE, OnUpdate)
00091 ON_COMMAND(ID_PROGGENERALSETTINGS, OnProggeneralsettings)
00092 ON_WM_SYSCOMMAND()
00093 ON_COMMAND(ID_DIAL, OnDial)
00094 ON_WM_ENDSESSION()
00095 ON_COMMAND(ID_HOWREGISTER, OnHowregister)
00096 ON_COMMAND(ID_HANGUPWHENDONE, OnHangupwhendone)
00097 ON_UPDATE_COMMAND_UI(ID_HANGUPWHENDONE, OnUpdateHangupwhendone)
00098 ON_COMMAND(ID_TURNOFFWHENDONE, OnTurnoffwhendone)
00099 ON_UPDATE_COMMAND_UI(ID_TURNOFFWHENDONE, OnUpdateTurnoffwhendone)
00100 ON_COMMAND(ID_ENTERKEY, OnEnterkey)
00101 ON_COMMAND(ID_BUYONLINE, OnBuyonline)
00102 ON_COMMAND(ID_MONITORBROWSER, OnMonitorbrowser)
00103 ON_UPDATE_COMMAND_UI(ID_MONITORBROWSER, OnUpdateMonitorbrowser)
00104 ON_COMMAND(ID_MONITORCLIPBOARD, OnMonitorclipboard)
00105 ON_UPDATE_COMMAND_UI(ID_MONITORCLIPBOARD, OnUpdateMonitorclipboard)
00106 ON_COMMAND(ID_ADDSITE, OnAddsite)
00107 ON_COMMAND(ID_VIEW_SWBAR, OnViewSwbar)
00108 ON_UPDATE_COMMAND_UI(ID_VIEW_SWBAR, OnUpdateViewSwbar)
00109 ON_WM_NCRBUTTONUP()
00110 ON_WM_TIMER()
00111 ON_WM_QUERYENDSESSION()
00112 ON_COMMAND(ID_INSERT, OnInsert)
00113 ON_COMMAND(ID_DLINFOBOX, OnDlinfobox)
00114 ON_COMMAND(ID_DLLANGFILES, OnDllangfiles)
00115 ON_COMMAND(ID_FDC, OnFDC)
00116 ON_COMMAND(ID_PROCCEEDFURTHERINIT, OnProceedFurherInitialization)
00117 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
00118 ON_COMMAND(ID_FILE_EXPORT_EXPORTLISTOFDOWNLOADS, OnExportlistofdownloads)
00119 ON_COMMAND(ID_FILE_IMPORT_IMPORTLISTOFDOWNLOADS, OnImportlistofdownloads)
00120 ON_COMMAND(ID_EXITWHENDONE, OnExitwhendone)
00121 ON_UPDATE_COMMAND_UI(ID_EXITWHENDONE, OnUpdateExitwhendone)
00122 ON_COMMAND(ID_FIND, OnFind)
00123 ON_COMMAND(ID_FINDNEXT, OnFindnext)
00124 ON_UPDATE_COMMAND_UI(ID_FINDNEXT, OnUpdateFindnext)
00125 ON_WM_ERASEBKGND()
00126 ON_COMMAND(ID_DONATE, OnDonate)
00127 ON_COMMAND(ID_DLD_CREATEBATCH, OnDldCreatebatch)
00128 ON_COMMAND(ID_FILE_IMPORT_IMPORTLISTOFDOWNLOADSFROMCLIPBOARD, OnFileImportImportlistofdownloadsfromclipboard)
00129 ON_COMMAND(ID_OPTIONS_SM, OnOptionsSm)
00130 ON_COMMAND(ID_SPREADHELP, OnSpreadhelp)
00131 ON_COMMAND(ID_EXPORTDLHIST, OnExportdlhist)
00132 ON_UPDATE_COMMAND_UI(ID_EXPORTDLHIST, OnUpdateExportdlhist)
00133 ON_COMMAND(ID_LDF_CLEAR, OnLdfClear)
00134 ON_UPDATE_COMMAND_UI(ID_LDF_CLEAR, OnUpdateLdfClear)
00135 ON_COMMAND(ID_PAUSEALLDLDS, OnPausealldlds)
00136 ON_UPDATE_COMMAND_UI(ID_PAUSEALLDLDS, OnUpdatePausealldlds)
00137 ON_UPDATE_COMMAND_UI(ID_DLINFOBOX, OnUpdateDlinfobox)
00138 ON_COMMAND(ID_APP_EXIT_2, OnAppExit2)
00139 ON_COMMAND(ID_PORTABLE_FDM, OnPortableFdm)
00140 ON_COMMAND(ID_UPLDROPTIONS, OnUpldroptions)
00141 ON_COMMAND(ID_EXPORTSETTINGS, OnExportSettings)
00142 ON_COMMAND(ID_IMPORTSETTINGS, OnImportSettings)
00143 ON_COMMAND(ID_SPIDERDLWEBPAGE, OnSpiderDLWebPage)
00144 ON_COMMAND(ID_SPIDERDEFSETTINGS, OnSpiderDefSettings)
00145 ON_MESSAGE (WM_TRAYMSG, OnTrayMsg)
00146 ON_COMMAND(ID_VIEW_TOOLBAR, OnViewToolbar)
00147 ON_COMMAND(ID_VIEW_STATUS_BAR, OnViewStatusbar)
00148 ON_COMMAND(ID_DROPBOX, OnDropBox)
00149 ON_UPDATE_COMMAND_UI(ID_DROPBOX, OnUpdateDropBox)
00150 ON_MESSAGE(WM_SHOWTRAYMENU, OnShowTrayMenu)
00151 ON_MESSAGE(WM_POWERBROADCAST, OnPowerBroadCast)
00152 ON_COMMAND(ID_LOADATSTARTUP, OnLoadatstartup)
00153 ON_UPDATE_COMMAND_UI(ID_LOADATSTARTUP, OnUpdateLoadatstartup)
00154
00155 ON_COMMAND_RANGE(ID_SWITCH_TO_START, ID_SWITCH_TO_END, OnSwitchTo)
00156 ON_UPDATE_COMMAND_UI_RANGE(ID_SWITCH_TO_START, ID_SWITCH_TO_START+100, OnUpdateSwitchTo)
00157 ON_UPDATE_COMMAND_UI_RANGE(WGP_MENU_VIEWSMPLITEM_CMDSTART, WGP_MENU_CMDLAST, OnUpdatePluginMenuView)
00158 ON_COMMAND_RANGE(ID_LNGMENU_START, ID_LNGMENU_END, OnLngMenu)
00159 ON_UPDATE_COMMAND_UI_RANGE(ID_LNGMENU_START, ID_LNGMENU_END, OnUpdateLngMenu)
00160 ON_COMMAND_RANGE(ID_ALT1, ID_ALT9, OnAltPlusDigit)
00161 ON_COMMAND (ID_THREAD_UPDATE, OnIdUpdate)
00162 ON_COMMAND_RANGE (ID_SKIN_0, ID_SKIN_N, OnSkin)
00163 ON_UPDATE_COMMAND_UI_RANGE (ID_SKIN_0, ID_SKIN_N, OnUpdateSkin)
00164 ON_COMMAND (ID_TUM_CHANGED, OnTUMChanged)
00165 ON_COMMAND_RANGE (ID_LDF_0, ID_LDF_0+9, OnLDF)
00166 ON_UPDATE_COMMAND_UI_RANGE(ID_LDF_0, ID_LDF_0+9, OnUpdateLdf0)
00167 ON_UPDATE_COMMAND_UI(ID_SB_TRAFFIC_THISMONTH, OnUpdateTrafficThisMonth)
00168 ON_UPDATE_COMMAND_UI(ID_SB_TOTALSPEED, OnUpdateTotalSpeed)
00169 END_MESSAGE_MAP()
00170
00171 static UINT indicators[] =
00172 {
00173 ID_SEPARATOR,
00174 ID_SB_TRAFFIC_THISMONTH,
00175 ID_SB_TOTALSPEED,
00176 };
00177
00178 CMainFrame::CMainFrame()
00179 {
00180 m_cMenuMainItemsAdded = m_cMenuViewItemsAdded = 0;
00181 m_bQueryForExit = TRUE;
00182 ReadSettings ();
00183 m_pUpdateDlg = NULL;
00184 m_cPluginMenuViewInserted = 0;
00185 m_umsgTaskBarCreated = 0;
00186
00187 m_bTrayMenuShowing = m_bBalloonShowing = FALSE;
00188
00189 m_bInited = FALSE;
00190 m_btnFDC.m_pCusts = &m_Customizations;
00191
00192 m_bNeedSpreadHelpDialog = m_bDontShowSHD = false;
00193
00194 m_nTrafficUsedPrevMonth = 0;
00195 m_nTrafficUsedThisMonth = 0;
00196
00197 m_nTrafficUpldPrevMonth = 0;
00198 m_nTrafficUpldThisMonth = 0;
00199
00200 m_nShutdownMsg = RegisterWindowMessage ("FDM - shutdown");
00201
00202 m_nUploadsMsg1 = RegisterWindowMessage (vmsUploadsDll::MSG_NAME_1);
00203 }
00204
00205 CMainFrame::~CMainFrame()
00206 {
00207 SAFE_DELETE (m_pUpdateDlg);
00208 }
00209
00210 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
00211 {
00212 if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
00213 return -1;
00214
00215 if (FALSE == ReadCusomizationInfo ())
00216 return -1;
00217
00218 LOG ("building title...");
00219
00220 UpdateTitle ();
00221
00222 LOG ("ok." << nl);
00223
00224 LOG ("building main menu...");
00225
00226 m_odmenu.Attach (GetMenu (), TRUE);
00227 LoadMenuImages ();
00228
00229 LOG ("ok." << nl);
00230
00231 LOG ("building main toolbar...");
00232
00233 if (FALSE == _TBMgr.Create (this))
00234 return -1;
00235
00236 CBitmap bmp, bmpd, bmph;
00237
00238 bmp.Attach (SBMP (IDB_TOOL0));
00239 bmpd.Attach (SBMP (IDB_TOOL0_D));
00240
00241 if (_TB_USE_ALPHA)
00242 {
00243 ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmp, GetSysColor (COLOR_3DFACE));
00244 ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmpd, GetSysColor (COLOR_3DFACE));
00245 }
00246
00247 wgTButtonInfo btns [] =
00248 {
00249
00250 wgTButtonInfo (0, TBSTYLE_SEP, ""),
00251 wgTButtonInfo (ID_TUM_LIGHT, TBSTYLE_BUTTON, ""),
00252 wgTButtonInfo (ID_TUM_MEDIUM, TBSTYLE_BUTTON, ""),
00253 wgTButtonInfo (ID_TUM_HEAVY, TBSTYLE_BUTTON, ""),
00254 wgTButtonInfo (0, TBSTYLE_SEP, ""),
00255 wgTButtonInfo (ID_STARTALL, TBSTYLE_BUTTON, ""),
00256 wgTButtonInfo (ID_STOPALL, TBSTYLE_BUTTON, ""),
00257 wgTButtonInfo (ID_PAUSEALLDLDS, TBSTYLE_BUTTON, ""),
00258 wgTButtonInfo (0, TBSTYLE_SEP, ""),
00259 wgTButtonInfo (ID_DLDROPTIONS, TBSTYLE_BUTTON, ""),
00260 wgTButtonInfo (ID_DIAL, TBSTYLE_BUTTON, ""),
00261 wgTButtonInfo (ID_HELP, TBSTYLE_BUTTON, ""),
00262 wgTButtonInfo (0, 0, ""),
00263 wgTButtonInfo (ID_APP_ABOUT, TBSTYLE_BUTTON, ""),
00264 wgTButtonInfo (0, 0, ""),
00265 wgTButtonInfo (0, 0, ""),
00266 wgTButtonInfo (0, 0, ""),
00267 wgTButtonInfo (0, 0, ""),
00268 wgTButtonInfo (0, 0, ""),
00269 wgTButtonInfo (0, 0, ""),
00270
00271 };
00272
00273 if (FALSE == _TBMgr.InsertGroup (btns, &bmp, &bmpd, sizeof (btns) / sizeof (wgTButtonInfo)))
00274 return -1;
00275
00276 _TBMgr.ShowGroup (0, 0);
00277
00278 LOG ("ok." << nl);
00279
00280 LOG ("building status bar...");
00281
00282 if (!m_wndStatusBar.Create(this) ||
00283 !m_wndStatusBar.SetIndicators(indicators,
00284 sizeof(indicators)/sizeof(UINT)))
00285 {
00286 TRACE0("Failed to create status bar\n");
00287 return -1;
00288 }
00289
00290 UINT nID, nStyle;
00291 int cx;
00292
00293 m_wndStatusBar.GetPaneInfo (0, nID, nStyle, cx);
00294 nStyle &= ~ SBPS_NOBORDERS;
00295 m_wndStatusBar.SetPaneInfo (0, nID, nStyle, cx);
00296
00297 LOG ("ok." << nl);
00298
00299 LOG ("creating rebar...");
00300
00301 m_wndReBar.Create (this);
00302
00303 LOG ("ok." << nl);
00304
00305 if (m_Customizations.get_BannerCount ())
00306 {
00307 m_wndBanner.Create (this, 15);
00308
00309 DWORD dw = GetTickCount ();
00310 int r = dw % (int)(m_Customizations.get_BannerCount () * 1.333);
00311 r = r % m_Customizations.get_BannerCount ();
00312 DisplayBanner (r);
00313
00314 LOG ("building rebar..." << nl);
00315
00316 m_wndReBar.AddBar (&m_wndBanner, NULL, NULL, RBBS_FIXEDBMP|RBBS_NOGRIPPER);
00317 }
00318
00319 m_wndReBar.AddBar (&_TBMgr, NULL, NULL, RBBS_FIXEDBMP|RBBS_NOGRIPPER|RBBS_BREAK);
00320 REBARBANDINFO rbbi;
00321 rbbi.cbSize = sizeof (rbbi);
00322 rbbi.fMask = RBBIM_ID;
00323 rbbi.wID = 1;
00324 VERIFY (m_wndReBar.GetReBarCtrl ().SetBandInfo (m_wndReBar.GetReBarCtrl ().GetBandCount ()-1, &rbbi));
00325
00326 if (m_Customizations.get_UseButton ())
00327 SetupButton ();
00328
00329 if (0)
00330 {
00331 m_wndFDMCustBtn.Create (&m_wndReBar);
00332 m_wndFDMCustBtn.set_AffiliateID (m_Customizations.get_AffiliateID ());
00333 DWORD dwBarStyle = RBBS_NOGRIPPER|RBBS_FIXEDBMP;
00334 if (m_Customizations.get_BannerCount () == 0)
00335 dwBarStyle |= RBBS_FIXEDSIZE;
00336 m_wndReBar.AddBar (&m_wndFDMCustBtn, NULL, NULL, dwBarStyle);
00337
00338 REBARBANDINFO rbbi;
00339 rbbi.cbSize = sizeof (rbbi);
00340 rbbi.fMask = RBBIM_IDEALSIZE | RBBIM_SIZE;
00341 int nIndex = m_wndReBar.GetReBarCtrl ().GetBandCount ()-1;
00342 CRect rc; m_wndFDMCustBtn.GetWindowRect (&rc);
00343 rbbi.cx = rbbi.cxIdeal = rc.Width ();
00344 m_wndReBar.GetReBarCtrl ().SetBandInfo (nIndex, &rbbi);
00345 }
00346
00347 LOG ("ok." << nl);
00348
00349 _ClipbrdMgr.Initialize (m_hWnd);
00350
00351
00352 if (!m_wndView.Create(AfxRegisterWndClass (0, LoadCursor (NULL, IDC_ARROW),
00353 (HBRUSH) (COLOR_3DFACE+1), NULL), NULL, AFX_WS_DEFAULT_VIEW | WS_CHILD,
00354 CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
00355 {
00356 TRACE0("Failed to create view window\n");
00357 return -1;
00358 }
00359
00360 if (_App.View_Toolbar () == FALSE)
00361 {
00362 CControlBar* pBar = GetControlBar(AFX_IDW_TOOLBAR);
00363 if (pBar != NULL)
00364 ShowControlBar (pBar, FALSE, FALSE);
00365 }
00366
00367 if (_App.View_Statusbar () == FALSE)
00368 {
00369 CControlBar* pBar = GetControlBar(AFX_IDW_STATUS_BAR);
00370 if (pBar != NULL)
00371 ShowControlBar (pBar, FALSE, FALSE);
00372 }
00373
00374 ApplyLanguage ();
00375
00376 m_umsgTaskBarCreated = RegisterWindowMessage(TEXT ("TaskbarCreated"));
00377
00378 UINT pnIcons [] = {IDI_TRAY_NORMAL, IDI_TRAY_DOWNLOADING, IDI_TRAY_ERRORS, IDI_TRAY_UNKNOWN};
00379 _TrayMgr.Create (m_hWnd, pnIcons, sizeof (pnIcons) / sizeof (UINT),
00380 GetShell32Version () >= 5 ? "" : PRG_NAME, WM_TRAYMSG);
00381
00382 m_pFloatWndsThread = (CFloatingWndsThread*) AfxBeginThread (RUNTIME_CLASS (CFloatingWndsThread));
00383
00384
00385 if (_UpdateMgr.m_enAUT != AUT_TURNOFF && IS_PORTABLE_MODE == FALSE)
00386 {
00387 LOG ("creating update thread...");
00388
00389 DWORD dw;
00390 CreateThread (NULL, 0, _threadUpdate, this, 0, &dw);
00391
00392 LOG ("ok." << nl);
00393 }
00394
00395 ReadTotalTrafficInfo ();
00396
00397
00398 PostMessage (WM_COMMAND, ID_PROCCEEDFURTHERINIT);
00399 return 0;
00400 }
00401
00402 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
00403 {
00404 if( !CFrameWnd::PreCreateWindow(cs) )
00405 return FALSE;
00406 cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
00407
00408 WNDCLASS wc;
00409 ZeroMemory (&wc, sizeof (wc));
00410 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
00411 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
00412 wc.hIcon = LoadIcon (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDR_MAINFRAME));
00413 wc.hInstance = AfxGetInstanceHandle ();
00414 wc.lpfnWndProc = ::DefWindowProc;
00415 wc.lpszClassName = "Free Download Manager Main Window";
00416 cs.lpszClass = wc.lpszClassName;
00417
00418 return AfxRegisterClass (&wc);
00419 }
00420
00421 #ifdef _DEBUG
00422 void CMainFrame::AssertValid() const
00423 {
00424 CFrameWnd::AssertValid();
00425 }
00426
00427 void CMainFrame::Dump(CDumpContext& dc) const
00428 {
00429 CFrameWnd::Dump(dc);
00430 }
00431
00432 #endif
00433
00434 void CMainFrame::OnSetFocus(CWnd* )
00435 {
00436
00437 m_wndView.SetFocus();
00438 }
00439
00440 BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
00441 {
00442
00443
00444 if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
00445 return TRUE;
00446
00447
00448 return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
00449 }
00450
00451 void CMainFrame::AddPluginMenu(HMENU hSrcMenu, fsSetImage* pImages, int cImages)
00452 {
00453 if (hSrcMenu == NULL)
00454 return;
00455
00456 if (m_cMenuMainItemsAdded)
00457 return;
00458
00459 int iAddAfter = GetMenu ()->GetMenuItemCount () - 3;
00460
00461 int cSrcItems = m_odmenu.InsertMenu (CMenu::FromHandle (hSrcMenu), iAddAfter);
00462 m_cMenuMainItemsAdded = cSrcItems;
00463
00464 if (pImages) m_odmenu.SetImages (pImages, cImages);
00465
00466 DrawMenuBar ();
00467 }
00468
00469 void CMainFrame::RemovePluginMenu()
00470 {
00471 int iWhere = GetMenu ()->GetMenuItemCount () - 4;
00472
00473 m_odmenu.RemoveMenu (iWhere, m_cMenuMainItemsAdded);
00474 m_cMenuMainItemsAdded = 0;
00475
00476 DrawMenuBar ();
00477 }
00478
00479 void CMainFrame::OnClose()
00480 {
00481 static bool _bInFunc = false;
00482 if (_bInFunc)
00483 return;
00484 _bInFunc = true;
00485
00486
00487 if (_PluginMgr.IsWasExit ())
00488 {
00489 CFrameWnd::OnClose();
00490
00491 LOG ("CMF::OnClose: exit" << nl);
00492
00493 _bInFunc = false;
00494 return;
00495 }
00496
00497 SaveState ();
00498
00499 if (m_bQueryForExit == FALSE || _PluginMgr.QueryExit ())
00500 {
00501
00502 _UpdateMgr.SetEventsFunc (NULL, 0);
00503 _UpdateMgr.SetDescEventsFunc (NULL, 0);
00504 _UpdateMgr.Stop ();
00505 m_odmenu.Detach ();
00506 _TrayMgr.Remove ();
00507
00508 m_pFloatWndsThread->m_wndFloating.HideAlways ();
00509 m_pFloatWndsThread->m_wndFloatingInfo.HideAlways ();
00510
00511 ShowWindow (SW_HIDE);
00512
00513 _PluginMgr.OnAppExit (FALSE);
00514
00515 CFdmApp::ScheduleExitProcess (30);
00516
00517 LOG ("CMF::OC: proceed to default handler..." << nl);
00518 CFrameWnd::OnClose();
00519 LOG ("CMF::OC: default handler done.");
00520 }
00521
00522 _bInFunc = false;
00523 }
00524 void CMainFrame::OnDlddefoptions()
00525 {
00526 _pwndDownloads->OnDownloadDefProperties ();
00527 }
00528
00529 void CMainFrame::OnDldroptions()
00530 {
00531 _pwndDownloads->OnDownloaderProperties ();
00532 }
00533
00534 void CMainFrame::OnTumHeavy()
00535 {
00536 if (_pwndDownloads->GetTUM () == TUM_HEAVY)
00537 return;
00538
00539 _pwndDownloads->SetTUM (TUM_HEAVY);
00540 _App.CurrentTUM (TUM_HEAVY);
00541
00542 if (_App.View_TUMChanged ())
00543 {
00544 _TBMgr.GetToolBarCtrl ().SetState (ID_TUM_MEDIUM, TBSTATE_ENABLED);
00545 _TBMgr.GetToolBarCtrl ().SetState (ID_TUM_LIGHT, TBSTATE_ENABLED);
00546 PostMessage (WM_COMMAND, ID_TUM_CHANGED);
00547 }
00548 }
00549
00550 void CMainFrame::OnUpdateTumHeavy(CCmdUI* pCmdUI)
00551 {
00552 pCmdUI->SetCheck (_pwndDownloads->GetTUM () == TUM_HEAVY);
00553 }
00554
00555 void CMainFrame::OnTumLight()
00556 {
00557 if (_pwndDownloads->GetTUM () == TUM_LIGHT)
00558 return;
00559
00560 _pwndDownloads->SetTUM (TUM_LIGHT);
00561 _App.CurrentTUM (TUM_LIGHT);
00562
00563 if (_App.View_TUMChanged ())
00564 {
00565 _TBMgr.GetToolBarCtrl ().SetState (ID_TUM_HEAVY, TBSTATE_ENABLED);
00566 _TBMgr.GetToolBarCtrl ().SetState (ID_TUM_MEDIUM, TBSTATE_ENABLED);
00567 PostMessage (WM_COMMAND, ID_TUM_CHANGED);
00568 }
00569 }
00570
00571 void CMainFrame::OnUpdateTumLight(CCmdUI* pCmdUI)
00572 {
00573 pCmdUI->SetCheck (_pwndDownloads->GetTUM () == TUM_LIGHT);
00574 }
00575
00576 void CMainFrame::OnTumMedium()
00577 {
00578 if (_pwndDownloads->GetTUM () == TUM_MEDIUM)
00579 return;
00580
00581 _pwndDownloads->SetTUM (TUM_MEDIUM);
00582 _App.CurrentTUM (TUM_MEDIUM);
00583
00584 if (_App.View_TUMChanged ())
00585 {
00586 _TBMgr.GetToolBarCtrl ().SetState (ID_TUM_HEAVY, TBSTATE_ENABLED);
00587 _TBMgr.GetToolBarCtrl ().SetState (ID_TUM_LIGHT, TBSTATE_ENABLED);
00588 PostMessage (WM_COMMAND, ID_TUM_CHANGED);
00589 }
00590 }
00591
00592 void CMainFrame::OnUpdateTumMedium(CCmdUI* pCmdUI)
00593 {
00594 pCmdUI->SetCheck (_pwndDownloads->GetTUM () == TUM_MEDIUM);
00595 }
00596
00597 void CMainFrame::OnOptmaster()
00598 {
00599 _pwndDownloads->OnOptimizationWizard ();
00600 }
00601
00602 void CMainFrame::OnDldCreate()
00603 {
00604 if (_DldsMgr.IsDeletingNow ())
00605 return;
00606 _pwndDownloads->OnDownloadCreate ();
00607 }
00608
00609 void CMainFrame::OnTaskCreateNew()
00610 {
00611 _pwndScheduler->OnCreatenewtask ();
00612 }
00613
00614 void CMainFrame::OnNeedExit()
00615 {
00616 m_bQueryForExit = FALSE;
00617 SendMessage (WM_CLOSE);
00618 }
00619
00620 LRESULT CMainFrame::OnTrayMsg(WPARAM , LPARAM lp)
00621 {
00622 switch (lp)
00623 {
00624 case WM_MOUSEMOVE:
00625 if (m_bBalloonShowing == FALSE)
00626 {
00627 POINT pt;
00628 GetCursorPos (&pt);
00629 m_balloonX = pt.x; m_balloonY = pt.y;
00630
00631 SetTimer (4, 1000, NULL);
00632 }
00633 break;
00634
00635 case WM_LBUTTONDOWN:
00636 if (IsIconic ())
00637 OnShowmainwindow ();
00638 else
00639 ShowWindow (SW_MINIMIZE);
00640 break;
00641
00642 case WM_RBUTTONUP:
00643 if (is_MouseInTray ())
00644 {
00645 KillTimer (2);
00646 HideBalloon ();
00647 ShowTrayMenu ();
00648 }
00649 break;
00650
00651 case NIN_BALLOONUSERCLICK:
00652 case NIN_BALLOONTIMEOUT:
00653 case NIN_BALLOONHIDE:
00654 m_bBalloonShowing = FALSE;
00655 m_strTimeoutBallon_Msgs = "";
00656 break;
00657 }
00658
00659 return 0;
00660 }
00661
00662 void CMainFrame::OnSize(UINT nType, int cx, int cy)
00663 {
00664 if (nType == SIZE_MINIMIZED)
00665 {
00666 if (m_bMinToTray)
00667 ShowWindow (SW_HIDE);
00668 }
00669 else
00670 {
00671 if (IsWindow (m_wndBanner))
00672 m_wndBanner.Invalidate ();
00673
00674 CFrameWnd::OnSize(nType, cx, cy);
00675
00676 if (nType == SIZE_MAXIMIZED || nType == SIZE_RESTORED)
00677 RecalcLayout ();
00678 }
00679
00680 _TBMgr.Invalidate (TRUE);
00681 if (IsWindow (m_btnFDC))
00682 m_btnFDC.Invalidate ();
00683 }
00684
00685 void CMainFrame::ShowTrayMenu(BOOL bModeTray)
00686 {
00687 if (m_bTrayMenuShowing)
00688 return;
00689
00690 m_bTrayMenuShowing = TRUE;
00691
00692 CMenu menu;
00693 menu.LoadMenu (IDM_TRAY);
00694 CMenu *pPopup = menu.GetSubMenu (0);
00695
00696 const vmsFileRecentList* pLFD = _DldsMgr.get_LastFilesDownloaded ();
00697 CMenu* pmenuLFD = pPopup->GetSubMenu (12);
00698
00699 for (int i = 0; i < pLFD->get_Count (); i++)
00700 {
00701 if (i == 0)
00702 pmenuLFD->RemoveMenu (0, MF_BYPOSITION);
00703
00704 LPCSTR pszDispName = pLFD->get_FileDispName (i);
00705
00706 if (*pszDispName == 0)
00707 pszDispName = LS (L_UNKNOWN);
00708
00709 pmenuLFD->InsertMenu (0, MF_STRING | MF_BYPOSITION, ID_LDF_0 + i, pszDispName);
00710 }
00711
00712 pPopup->SetDefaultItem (ID_SHOWMAINWINDOW);
00713
00714 CPoint pt;
00715 GetCursorPos (&pt);
00716
00717 SetForegroundWindow ();
00718
00719 m_odTrayMenu.Attach (&menu, FALSE);
00720
00721 fsSetImage img [] =
00722 {
00723 fsSetImage (ID_DLD_CREATE, 18),
00724 fsSetImage (ID_TUM_LIGHT, 0),
00725 fsSetImage (ID_TUM_MEDIUM, 1),
00726 fsSetImage (ID_TUM_HEAVY, 2),
00727 fsSetImage (ID_STARTALL, 3),
00728 fsSetImage (ID_STOPALL, 4),
00729 fsSetImage (ID_PAUSEALLDLDS, 5),
00730 fsSetImage (ID_DIAL, 7),
00731 fsSetImage (ID_APP_ABOUT, 8),
00732 };
00733
00734 m_odTrayMenu.SetImages (img, sizeof (img) / sizeof (fsSetImage));
00735
00736 CString strSMW = LS (L_SHOWMAINWND); strSMW += '\t';
00737 CString strCND = LS (L_NEWDL); strCND += "\tIns";
00738 CString strL = LS (L_LIGHT); strL += "\tCtrl+1";
00739 CString strM = LS (L_MEDIUM); strM += "\tCtrl+2";
00740 CString strH = LS (L_HEAVY); strH += "\tCtrl+3";
00741 CString strDial = LS (L_DIAL); strDial += "\tCtrl+D";
00742 CString strExit = LS (L_EXIT); strExit += "\tAlt+X";
00743
00744 fsSetText texts [] = {
00745 fsSetText (ID_SHOWMAINWINDOW, strSMW),
00746 fsSetText (ID_MONITORBROWSER, LS (L_MONITORBROWSER)),
00747 fsSetText (ID_MONITORCLIPBOARD, LS (L_MONITORCLIPBOARD)),
00748 fsSetText (ID_DLD_CREATE, strCND),
00749 fsSetText (ID_DLD_CREATEBATCH, LS (L_CREATEBATCHDLD)),
00750 fsSetText (ID_STARTALL, LS (L_STARTALLDLDS)),
00751 fsSetText (ID_STOPALL, LS (L_STOPALLDLDS)),
00752 fsSetText (ID_TUM_LIGHT, strL),
00753 fsSetText (ID_TUM_MEDIUM, strM),
00754 fsSetText (ID_TUM_HEAVY, strH),
00755 fsSetText (ID_DIAL, strDial),
00756 fsSetText (ID_DLINFOBOX, LS (L_SHOWDLDSINFOWHILEDOWNLOADING)),
00757 fsSetText (ID_DROPBOX, LS (L_DROPBOX)),
00758 fsSetText (ID_APP_ABOUT, LS (L_ABOUT)),
00759 fsSetText (ID_APP_EXIT, strExit),
00760 fsSetText (ID_LDF_CLEAR, LS (L_CLEAR)),
00761 fsSetText (ID_PAUSEALLDLDS, LS (L_PAUSEALLDOWNLOADS)),
00762 fsSetText (ID_LOADATSTARTUP, LS (L_AUTOSTART)),
00763 };
00764 m_odTrayMenu.SetMenuItemsText (&menu, texts, sizeof (texts) / sizeof (fsSetText), FALSE);
00765
00766 m_odTrayMenu.SetMenuItemText (menu.GetSubMenu (0), LS (L_LASTDOWNLOADEDFILES), 12, TRUE);
00767 if (pLFD->get_Count () == 0)
00768 m_odTrayMenu.SetMenuItemText (menu.GetSubMenu (0)->GetSubMenu (12), LS (L_EMPTY), 0, TRUE);
00769
00770 m_odTrayMenu.SetMenuItemText (menu.GetSubMenu (0), LS (L_TUM), 14, TRUE);
00771
00772 UINT uFlags = TPM_RIGHTBUTTON;
00773 if (bModeTray)
00774 uFlags |= TPM_BOTTOMALIGN | TPM_RIGHTALIGN;
00775 else
00776 uFlags |= TPM_LEFTALIGN | TPM_TOPALIGN;
00777
00778 pPopup->TrackPopupMenu (uFlags, pt.x, pt.y, this);
00779 m_odTrayMenu.Detach ();
00780
00781 menu.DestroyMenu ();
00782
00783 m_bTrayMenuShowing = FALSE;
00784 }
00785
00786 void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
00787 {
00788 CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
00789
00790 HMENU ahMenus [100];
00791
00792 for (int i = 0; i < m_cMenuMainItemsAdded; i++)
00793 ahMenus [i] = GetMenu ()->GetSubMenu (GetMenu ()->GetMenuItemCount () - 3 - m_cMenuMainItemsAdded + i)->m_hMenu;
00794
00795 _PluginMgr.UpdateMenuMain ((HMENU*) ahMenus);
00796
00797 if (m_cMenuViewItemsAdded)
00798 {
00799 for (i = 0; i < m_cMenuViewItemsAdded; i++)
00800 ahMenus [i] = GetMenu ()->GetSubMenu (1)->GetSubMenu (8+i)->m_hMenu;
00801
00802 _PluginMgr.UpdateMenuView ((HMENU*) ahMenus);
00803 }
00804 }
00805
00806 void CMainFrame::OnSaveall()
00807 {
00808 _pwndDownloads->SaveAll ();
00809 _pwndFVDownloads->SaveAll ();
00810 if (_pwndUploads)
00811 _pwndUploads->SaveAll ();
00812 _pwndScheduler->SaveAll ();
00813 _pwndHFE->SaveAll ();
00814 _pwndSites->SaveAll ();
00815 _pwndSpider->SaveAll (TRUE);
00816 ((CFdmApp*)AfxGetApp ())->SaveSettings ();
00817 ((CFdmApp*) AfxGetApp ())->SaveHistory ();
00818
00819 SaveState ();
00820 }
00821
00822 void CMainFrame::OnAppExit()
00823 {
00824
00825 OnAppExit2 ();
00826 }
00827
00828 void CMainFrame::OnMeasureItem(int , LPMEASUREITEMSTRUCT lpMeasureItemStruct)
00829 {
00830 m_odmenu.OnMeasureItem (lpMeasureItemStruct);
00831 }
00832
00833 void CMainFrame::OnDrawItem(int , LPDRAWITEMSTRUCT lpDrawItemStruct)
00834 {
00835 m_odmenu.OnDrawItem (lpDrawItemStruct);
00836 }
00837
00838 void CMainFrame::LoadMenuImages()
00839 {
00840 if (!m_imgsMenu.Create (16, 16, ILC_COLOR32 | ILC_MASK, 30, 5))
00841 return;
00842
00843 if (!m_dimgsMenu.Create (16, 16, ILC_COLOR32 | ILC_MASK, 30, 5))
00844 return;
00845
00846 UINT aImgs [] = {
00847 IDB_TOOL0_16, IDB_TOOL_DLD_16, IDB_TOOL_DLD_16,
00848 IDB_TOOL_DLD_16,
00849 IDB_TOOL_SCH_16,
00850 IDB_TOOL_HFE_16, IDB_TOOL_SITES_16, IDB_TOOL_SPIDER_16,
00851 };
00852
00853 UINT adImgs [] = {
00854 IDB_TOOL0_16_D, IDB_TOOL_DLD_16_D, IDB_TOOL_DLD_16_D,
00855 IDB_TOOL_DLD_16_D,
00856 IDB_TOOL_SCH_16_D,
00857 IDB_TOOL_HFE_16_D, IDB_TOOL_SITES_16_D, IDB_TOOL_SPIDER_16_D,
00858 };
00859
00860 const int _uplIndex = 3;
00861
00862 for (int i = 0; i < sizeof (aImgs) / sizeof (UINT); i++)
00863 {
00864 if (i == _uplIndex && FALSE == CUploadsWnd::LoadFumCoreDll ())
00865 continue;
00866
00867 CBitmap bmp, bmpd;
00868
00869 bmp.Attach (SBMP (aImgs [i]));
00870 bmpd.Attach (SBMP (adImgs [i]));
00871
00872 if (_TB_USE_ALPHA)
00873 {
00874 if (i == 0 || _SkinMgr.tbUseAlpha_ForAllPluginMenuImages ())
00875 {
00876 ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmp, GetSysColor (COLOR_MENU));
00877 ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmpd, GetSysColor (COLOR_MENU));
00878
00879 m_imgsMenu.Add (&bmp, GetSysColor (COLOR_MENU));
00880 m_dimgsMenu.Add (&bmpd, RGB (255, 0, 255));
00881 }
00882 else
00883 {
00884 m_imgsMenu.Add (&bmp, RGB (255, 0, 255));
00885 m_dimgsMenu.Add (&bmpd, RGB (255, 0, 255));
00886 }
00887 }
00888 else
00889 {
00890 m_imgsMenu.Add (&bmp, RGB (255, 0, 255));
00891 m_dimgsMenu.Add (&bmpd, RGB (255, 0, 255));
00892 }
00893 }
00894
00895 m_odmenu.SetImageList (&m_imgsMenu, &m_dimgsMenu);
00896
00897 LoadToolImages ();
00898 }
00899
00900 void CMainFrame::OnShowmainwindow()
00901 {
00902 if (IsIconic ())
00903 ShowWindow (SW_RESTORE);
00904 else
00905 ShowWindow (SW_SHOW);
00906
00907 SetForegroundWindow ();
00908
00909 ShowSpreadHelpDialogIfRequired ();
00910 }
00911
00912 void CMainFrame::OnStartall()
00913 {
00914 _DldsMgr.StartAllDownloads (TRUE);
00915 }
00916
00917 void CMainFrame::OnStopall()
00918 {
00919 _pwndSpider->GetMgr ()->StopAll ();
00920 _DldsMgr.StopAllDownloads (TRUE);
00921 }
00922
00923 void CMainFrame::OnHelp()
00924 {
00925 HtmlHelp (m_hWnd, "Help\\Open Download Manager.chm", HH_DISPLAY_TOC, NULL);
00926 }
00927
00928 void CMainFrame::OnHomepage()
00929 {
00930 fsOpenUrlInBrowser ("http://www.opendownloadmanager.org/");
00931 }
00932
00933 void CMainFrame::OnRecommend()
00934 {
00935 ShellExecute (NULL, "open", "mailto:@?subject=Open%20Download%20Manager%20[http://www.opendownloadmanager.org]", NULL, NULL, SW_SHOW);
00936 }
00937
00938 void CMainFrame::OnSupport()
00939 {
00940 fsOpenUrlInBrowser ("http://www.opendownloadmanager.org/support/");
00941 }
00942
00943 void CMainFrame::OnUpdate()
00944 {
00945
00946 if (_UpdateMgr.IsStartUpdaterNeeded (FALSE))
00947 {
00948 MessageBox (LS (L_ALRUPDATED), NULL, MB_ICONEXCLAMATION);
00949 return;
00950 }
00951
00952 StartUpdate (TRUE);
00953 }
00954
00955 void CMainFrame::OnProggeneralsettings()
00956 {
00957 CPrgSheet sheet (LS (L_PRGGENSET), this);
00958
00959 sheet.Init ();
00960
00961 _DlgMgr.OnDoModal (&sheet);
00962 sheet.DoModal ();
00963 SaveSettings ();
00964 _DlgMgr.OnEndDialog (&sheet);
00965 }
00966
00967 void CMainFrame::ReadSettings()
00968 {
00969 m_bCloseAsMinimize = _App.Prg_CloseAsMinimize ();
00970 m_bMinToTray = _App.Prg_MinToTray ();
00971 }
00972
00973 void CMainFrame::SaveSettings()
00974 {
00975 _App.Prg_CloseAsMinimize (m_bCloseAsMinimize);
00976 _App.Prg_MinToTray (m_bMinToTray);
00977 }
00978
00979 void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
00980 {
00981 if (nID == SC_CLOSE && m_bCloseAsMinimize)
00982 {
00983 ShowWindow (SW_MINIMIZE);
00984 return;
00985 }
00986
00987 CFrameWnd::OnSysCommand(nID, lParam);
00988 }
00989
00990 void CMainFrame::OnDial()
00991 {
00992 if (_DldsMgr.IsDeletingNow ())
00993 return;
00994
00995 CDialDlg dlg (this);
00996
00997 dlg.Init (NULL);
00998
00999 _DlgMgr.OnDoModal (&dlg);
01000 dlg.DoModal ();
01001 _DlgMgr.OnEndDialog (&dlg);
01002 }
01003
01004 void CMainFrame::_UpdateMgrEvents(fsUpdateMgrEvent , UINT* , LPVOID )
01005 {
01006
01007 }
01008
01009 void CMainFrame::StartUpdate(BOOL bShowDlg)
01010 {
01011 if (_UpdateMgr.IsRunning () == FALSE)
01012 {
01013 SAFE_DELETE (m_pUpdateDlg);
01014 fsnew1 (m_pUpdateDlg, CUpdateDlg);
01015 m_pUpdateDlg->m_bCheckingByUser = bShowDlg != FALSE;
01016 m_pUpdateDlg->Create (IDD_UPDATE, this);
01017 }
01018
01019 if (bShowDlg)
01020 m_pUpdateDlg->ShowWindow (SW_SHOW);
01021 }
01022
01023 void CMainFrame::OnEndSession(BOOL bEnding)
01024 {
01025 _PluginMgr.OnAppExit (FALSE);
01026 ((CFdmApp*)AfxGetApp ())->SaveSettings ();
01027 ((CFdmApp*)AfxGetApp ())->SaveHistory ();
01028 CFrameWnd::OnEndSession(bEnding);
01029 }
01030
01031 void CMainFrame::OnHowregister()
01032 {
01033 HtmlHelp (m_hWnd, "Help\\Open Download Manager.chm::/Topics/Registration.html", HH_DISPLAY_TOPIC, NULL);
01034 }
01035
01036 void CMainFrame::OnHangupwhendone()
01037 {
01038 _pwndScheduler->HangupWhenDone (_pwndScheduler->HangupWhenDone () == FALSE);
01039 }
01040
01041 void CMainFrame::OnUpdateHangupwhendone(CCmdUI* pCmdUI)
01042 {
01043 pCmdUI->SetCheck (_pwndScheduler->HangupWhenDone () ? 1 : 0);
01044 }
01045
01046 void CMainFrame::OnTurnoffwhendone()
01047 {
01048 fsShutdownType enType = (fsShutdownType) _App.WD_LastShutdownType ();
01049
01050
01051 if (_pwndScheduler->TurnoffWhenDone (enType))
01052 {
01053 _pwndScheduler->TurnoffWhenDone (enType, FALSE);
01054 return;
01055 }
01056
01057 if (_App.WD_LastShutdownType_DontAsk () == FALSE)
01058 {
01059 CDlg_ShutdownType dlg;
01060 dlg.m_enType = enType;
01061 if (IDCANCEL == _DlgMgr.DoModal (&dlg))
01062 return;
01063
01064 enType = dlg.m_enType;
01065 _App.WD_LastShutdownType (enType);
01066
01067 if (dlg.m_bRemember)
01068 _App.WD_LastShutdownType_DontAsk (TRUE);
01069 }
01070
01071 _pwndScheduler->TurnoffWhenDone (enType, TRUE);
01072 }
01073
01074 void CMainFrame::OnUpdateTurnoffwhendone(CCmdUI* pCmdUI)
01075 {
01076 fsShutdownType enType = (fsShutdownType) _App.WD_LastShutdownType ();
01077 pCmdUI->SetCheck (_pwndScheduler->TurnoffWhenDone (enType) ? 1 : 0);
01078 }
01079
01080 void CMainFrame::OnEnterkey()
01081 {
01082 CEnterKeyDlg dlg;
01083
01084 _DlgMgr.OnDoModal (&dlg);
01085 if (IDOK == dlg.DoModal ())
01086 UpdateTitle ();
01087 _DlgMgr.OnEndDialog (&dlg);
01088 }
01089
01090 void CMainFrame::UpdateTitle()
01091 {
01092 CString strCaption = PRG_NAME;
01093
01094 LPCSTR pszCustomizer = m_Customizations.get_Customizer ();
01095 if (pszCustomizer != NULL && lstrlen (pszCustomizer) != 0)
01096 {
01097 strCaption += ", ";
01098 strCaption += pszCustomizer;
01099 strCaption += " version";
01100 }
01101
01102 SetWindowText (strCaption);
01103 }
01104
01105 void CMainFrame::OnBuyonline()
01106 {
01107 fsOpenBuyPage ();
01108 }
01109
01110 void CMainFrame::OnMonitorbrowser()
01111 {
01112 BOOL bMonitor = _App.Monitor_IE2 () || _App.Monitor_Firefox () ||
01113 _NOMgr.IsNetscapePluginInstalled () || _NOMgr.IsOperaPluginInstalled () ||
01114 _NOMgr.IsMozillaSuitePluginInstalled ();
01115
01116 BOOL bRR = FALSE;
01117
01118 DWORD dwMUSO = _App.Monitor_UserSwitchedOn ();
01119
01120 DWORD dwMonitorNow = 0;
01121
01122 if (bMonitor || (dwMUSO & MONITOR_USERSWITCHEDON_IE))
01123 {
01124 if (_IECatchMgr.ActivateIE2 (!bMonitor)) {
01125 _App.Monitor_IE2 (!bMonitor);
01126 if (!bMonitor)
01127 dwMonitorNow |= MONITOR_USERSWITCHEDON_IE;
01128 }
01129 else
01130 MessageBox (LS (L_ERRIE), LS (L_ERR), MB_ICONERROR);
01131 }
01132
01133 if (bMonitor || (dwMUSO & MONITOR_USERSWITCHEDON_FIREFOX))
01134 {
01135 if (bMonitor && false == vmsFirefoxMonitoring::IsInstalled ())
01136 vmsFirefoxMonitoring::Install (true);
01137 _App.Monitor_Firefox (!bMonitor);
01138 if (!bMonitor && vmsFirefoxMonitoring::IsInstalled ())
01139 dwMonitorNow |= MONITOR_USERSWITCHEDON_FIREFOX;
01140 }
01141
01142 if (bMonitor)
01143 {
01144 if (_NOMgr.IsNetscapePluginInstalled ())
01145 {
01146 _NOMgr.DeinstallNetscapePlugin ();
01147 bRR = TRUE;
01148 }
01149
01150 if (_NOMgr.IsOperaPluginInstalled ())
01151 {
01152 _NOMgr.DeinstallOperaPlugin ();
01153 bRR = TRUE;
01154 }
01155
01156 if (_NOMgr.IsMozillaSuitePluginInstalled ())
01157 {
01158 _NOMgr.DeinstallMozillaSuitePlugin ();
01159 bRR = TRUE;
01160 }
01161 }
01162 else
01163 {
01164 if ((dwMUSO & MONITOR_USERSWITCHEDON_OPERA) &&
01165 _NOMgr.IsOperaPluginInstalled () == FALSE)
01166 {
01167 if (_NOMgr.InstallOperaPlugin ()) {
01168 bRR = TRUE;
01169 dwMonitorNow |= MONITOR_USERSWITCHEDON_OPERA;
01170 }
01171 }
01172
01173 if ((dwMUSO & MONITOR_USERSWITCHEDON_NETSCAPE) &&
01174 _NOMgr.IsNetscapePluginInstalled () == FALSE)
01175 {
01176 if (_NOMgr.InstallNetscapePlugin ()) {
01177 bRR = TRUE;
01178 dwMonitorNow |= MONITOR_USERSWITCHEDON_NETSCAPE;
01179 }
01180 }
01181
01182 if ((dwMUSO & MONITOR_USERSWITCHEDON_SEAMONKEY) &&
01183 _NOMgr.IsMozillaSuitePluginInstalled () == FALSE)
01184 {
01185 if (_NOMgr.InstallMozillaSuitePlugin ()) {
01186 bRR = TRUE;
01187 dwMonitorNow |= MONITOR_USERSWITCHEDON_SEAMONKEY;
01188 }
01189 }
01190 }
01191
01192 if (dwMonitorNow) {
01193 CString str;
01194 if (dwMonitorNow & MONITOR_USERSWITCHEDON_IE)
01195 str = "Internet Explorer";
01196 if (dwMonitorNow & MONITOR_USERSWITCHEDON_FIREFOX)
01197 str += str == "" ? "Firefox" : ", Firefox";
01198 if (dwMonitorNow & MONITOR_USERSWITCHEDON_OPERA)
01199 str += str == "" ? "Opera" : ", Opera";
01200 if (dwMonitorNow & MONITOR_USERSWITCHEDON_NETSCAPE)
01201 str += str == "" ? "Netscape" : ", Netscape";
01202 if (dwMonitorNow & MONITOR_USERSWITCHEDON_SEAMONKEY)
01203 str += str == "" ? "SeaMonkey" : ", SeaMonkey";
01204
01205 CString str2;
01206 str2.Format (LS (L_MONITORING_TURNEDON_IN), str);
01207 if (bRR) {
01208 str2 += "\n\n";
01209 str2 += LS (L_BROWSERRESTARTREQ);
01210 }
01211 MessageBox (str2);
01212 }
01213 else if (bRR)
01214 MessageBox (LS (L_BROWSERRESTARTREQ));
01215 }
01216
01217 void CMainFrame::OnUpdateMonitorbrowser(CCmdUI* pCmdUI)
01218 {
01219 BOOL bMonitor = _App.Monitor_IE2 () || _App.Monitor_Firefox () ||
01220 _NOMgr.IsNetscapePluginInstalled () || _NOMgr.IsOperaPluginInstalled () ||
01221 _NOMgr.IsMozillaSuitePluginInstalled ();
01222 pCmdUI->SetCheck (bMonitor ? 1 : 0);
01223 }
01224
01225 void CMainFrame::OnMonitorclipboard()
01226 {
01227 BOOL b = _App.Monitor_Clipboard () == FALSE;
01228 _App.Monitor_Clipboard (b);
01229 _pwndDownloads->m_ClpbrdCatch.Enable (b);
01230 }
01231
01232 void CMainFrame::OnUpdateMonitorclipboard(CCmdUI* pCmdUI)
01233 {
01234 pCmdUI->SetCheck (_App.Monitor_Clipboard () ? 1 : 0);
01235 }
01236
01237 void CMainFrame::OnAddsite()
01238 {
01239 _pwndSites->OnSitesAdd ();
01240 }
01241
01242 void CMainFrame::BuildSwitchToMenu()
01243 {
01244 CMenu *pMenu = GetMenu ()->GetSubMenu (1)->GetSubMenu (6);
01245 m_odmenu.RemoveMenuItem (pMenu, 0, TRUE);
01246 for (int i = 0; i < _PluginMgr.GetPluginCount (); i++)
01247 {
01248 fsPluginInfo *plug = &_PluginMgr.Plugin (i);
01249 CString str;
01250 str.Format ("%s\tAlt+%d", plug->strName, i+1);
01251 fsODMenuItemData *pData = m_odmenu.AddItem (pMenu, ID_SWITCH_TO_START+i, str);
01252 if (pData)
01253 pData->iCheckImage = ODMENU_CHECKIMAGE_RADIO;
01254 }
01255 }
01256
01257 void CMainFrame::OnSwitchTo(UINT nID)
01258 {
01259 SetActivePlugin (nID - ID_SWITCH_TO_START);
01260 }
01261
01262 void CMainFrame::OnUpdateSwitchTo(CCmdUI *pCmdUI)
01263 {
01264 pCmdUI->SetCheck (pCmdUI->m_nID - ID_SWITCH_TO_START == (UINT)m_wndView.m_wndClient.m_plugs2.GetActivePlugin () ? 1 : 0);
01265 }
01266
01267 void CMainFrame::OnViewSwbar()
01268 {
01269 }
01270
01271 void CMainFrame::OnUpdateViewSwbar(CCmdUI* pCmdUI)
01272 {
01273 pCmdUI->SetCheck (m_wndView.m_wndClient.m_bShowSWBar ? 1 : 0);
01274 }
01275
01276 void CMainFrame::RemovePluginMenuView()
01277 {
01278
01279 RemovePluginMenuView2 ();
01280
01281 if (m_cPluginMenuViewInserted == 0)
01282 return;
01283
01284 CMenu *pMenu = GetMenu ()->GetSubMenu (1);
01285
01286 while (m_cPluginMenuViewInserted--)
01287 {
01288 m_odmenu.RemoveMenuItem (pMenu, 8, TRUE);
01289 }
01290
01291 m_cPluginMenuViewInserted = 0;
01292
01293 DrawMenuBar ();
01294 }
01295
01296 void CMainFrame::AddPluginMenuView(HMENU hMenuView, fsSetImage* pImages, int cImages, wgMenuViewItem *pItems, int cItems)
01297 {
01298 m_pPluginMenuViewItems = pItems;
01299 if (pItems)
01300 {
01301
01302 m_cPluginMenuViewItems = cItems;
01303
01304 CMenu *pMenu = GetMenu ()->GetSubMenu (1);
01305 int iStartPos = 8;
01306
01307 for (int i = 0; i < cItems; i++)
01308 m_odmenu.InsertMenuItem (pMenu, pItems [i].pszName, WGP_MENU_VIEWSMPLITEM_CMDSTART+i, iStartPos++, TRUE);
01309
01310 m_cPluginMenuViewInserted = cItems;
01311 }
01312
01313
01314 AddPluginMenuView (hMenuView, pImages, cImages);
01315
01316 DrawMenuBar ();
01317 }
01318
01319 void CMainFrame::OnAltPlusDigit(UINT nID)
01320 {
01321 int iPlug = nID - ID_ALT1;
01322 if (iPlug < _PluginMgr.GetPluginCount ())
01323 m_wndView.m_wndClient.m_plugs2.SetActivePlugin (iPlug);
01324 }
01325
01326 void CMainFrame::OnUpdatePluginMenuView(CCmdUI *pCmdUI)
01327 {
01328 int iItem = pCmdUI->m_nID - WGP_MENU_VIEWSMPLITEM_CMDSTART;
01329 if (iItem >= m_cPluginMenuViewItems)
01330 return;
01331
01332 pCmdUI->SetCheck (*m_pPluginMenuViewItems [iItem].pbView ? 1 : 0);
01333 }
01334
01335 void CMainFrame::OnViewToolbar()
01336 {
01337 CFrameWnd::OnBarCheck (AFX_IDW_TOOLBAR);
01338
01339 CControlBar* pBar = GetControlBar(AFX_IDW_TOOLBAR);
01340 if (pBar != NULL)
01341 _App.View_Toolbar ((pBar->GetStyle() & WS_VISIBLE) != 0);
01342 }
01343
01344 void CMainFrame::OnViewStatusbar()
01345 {
01346 CFrameWnd::OnBarCheck (AFX_IDW_STATUS_BAR);
01347
01348 CControlBar* pBar = GetControlBar(AFX_IDW_STATUS_BAR);
01349 if (pBar != NULL)
01350 _App.View_Statusbar ((pBar->GetStyle() & WS_VISIBLE) != 0);
01351 }
01352
01353 void CMainFrame::SaveState()
01354 {
01355 m_wndView.m_wndClient.SaveState ();
01356 _App.View_SaveWndPlacement (this, "MainFrm");
01357 if (m_pFloatWndsThread)
01358 {
01359 m_pFloatWndsThread->m_wndFloating.SaveState ();
01360 m_pFloatWndsThread->m_wndFloatingInfo.SaveState ();
01361 }
01362
01363 m_nTrafficUsedThisMonth += fsInternetDownloader::get_TotalTraffic ();
01364 vmsBtSession *pS = _BT.is_Initialized () ? _BT.get_Session () : NULL;
01365 UINT64 u = pS ? pS->get_TotalDownloadedByteCount () : 0;
01366 fsInternetDownloader::ResetTotalTrafficInfo ();
01367 _App.TotalTraffic (m_nTrafficUsedThisMonth + u);
01368
01369 u = pS ? pS->get_TotalUploadedByteCount () : 0;
01370 _App.TotalUpldTraffic (m_nTrafficUpldThisMonth + u);
01371 }
01372
01373 void CMainFrame::BuildLngMenu()
01374 {
01375 CMenu *menu = GetMenu ()->GetSubMenu (1);
01376 menu = menu->GetSubMenu (menu->GetMenuItemCount () - 1);
01377
01378 m_odmenu.RemoveMenuItem (menu, 0, TRUE);
01379
01380 if (_LngMgr.GetLngCount ())
01381 {
01382 for (int i = 0; i < _LngMgr.GetLngCount (); i++)
01383 m_odmenu.InsertMenuItem (menu, _LngMgr.GetLngName (i), ID_LNGMENU_START+i, i, TRUE);
01384 }
01385 else
01386 {
01387 m_odmenu.InsertMenuItem (menu, LS (L_EMPTY), ID_LNGMENU_START, 0, TRUE);
01388 }
01389 }
01390
01391 void CMainFrame::OnLngMenu(UINT id)
01392 {
01393 int iCurLng = _LngMgr.GetCurLng ();
01394
01395 BOOL bIEMenus = _IECMM.IsIEMenusPresent ();
01396 if (bIEMenus)
01397 _IECMM.DeleteIEMenus ();
01398 if (FALSE == _LngMgr.LoadLng (id - ID_LNGMENU_START))
01399 {
01400 _LngMgr.LoadLng (iCurLng);
01401 if (bIEMenus)
01402 _IECMM.AddIEMenus ();
01403 MessageBox ("Sorry, can't load this language", "Error", MB_ICONERROR);
01404 return;
01405 }
01406
01407 _App.View_Language (_LngMgr.GetLngName (id - ID_LNGMENU_START));
01408 if (bIEMenus)
01409 _IECMM.AddIEMenus ();
01410 ApplyLanguage ();
01411 }
01412
01413 void CMainFrame::OnUpdateLngMenu(CCmdUI *pCmdUI)
01414 {
01415 if (_LngMgr.GetLngCount ())
01416 pCmdUI->SetCheck (pCmdUI->m_nID - ID_LNGMENU_START == (UINT)_LngMgr.GetCurLng () ? 1 : 0);
01417 else
01418 pCmdUI->Enable (FALSE);
01419 }
01420
01421 void CMainFrame::ApplyLanguage()
01422 {
01423 ApplyLanguageToMenu ();
01424
01425 LPCSTR ppszToolTips [] = {
01426 "", LS (L_LIGHT), LS (L_MEDIUM),
01427 LS (L_HEAVY), "", LS (L_STARTALLDLDS), LS (L_STOPALLDLDS),
01428 LS (L_PAUSEALLDOWNLOADS), "", LS (L_DLDR_OPTIONS), LS (L_DIALUP),
01429 LS (L_HELP), LS (L_ABOUT), "", "Make a donation",
01430 LS (L_SAVEALL), "", LS (L_CUT), LS (L_COPY), LS (L_PASTE), "",
01431 };
01432
01433 _TBMgr.UpdateGroupToolTips (0, ppszToolTips, sizeof (ppszToolTips) / sizeof (LPCSTR));
01434
01435 m_wndStatusBar.SetToolTipText (ID_SB_TOTALSPEED, LS (L_TOTAL_SPEED_SBTEXT));
01436
01437 UpdateTitle ();
01438 }
01439
01440 void CMainFrame::ApplyLanguageToMenu()
01441 {
01442 RemovePluginMenu ();
01443 RemovePluginMenuView ();
01444
01445 m_odmenu.Detach ();
01446 SetMenu (NULL);
01447
01448 SetMenu (CMenu::FromHandle (LoadMenu (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDR_MAINFRAME))));
01449
01450 if (_pwndUploads == NULL || _pwndUploads->m_pwndUploads == NULL || IS_PORTABLE_MODE)
01451 GetMenu ()->GetSubMenu (2)->RemoveMenu (ID_UPLDROPTIONS, MF_BYCOMMAND);
01452
01453 m_odmenu.Attach (GetMenu (), TRUE);
01454
01455
01456 _PluginMgr.OnNewLng (_LngMgr.GetLngName (_LngMgr.GetCurLng ()));
01457
01458 SetMenuImages ();
01459 BuildSwitchToMenu ();
01460 BuildSkinsMenu ();
01461 BuildLngMenu ();
01462
01463 fsSetText aMenuBarTexts [] = {
01464 fsSetText (0, LS (L_FILE)),
01465 fsSetText (1, LS (L_VIEW)),
01466 fsSetText (2, LS (L_OPTIONS)),
01467 fsSetText (3, LS (L_TOOLS)),
01468 fsSetText (4, LS (L_HELP)),
01469 };
01470 m_odmenu.SetMenuItemsText (GetMenu (), aMenuBarTexts, sizeof (aMenuBarTexts) / sizeof (fsSetText), TRUE);
01471
01472 CString strCut = LS (L_CUT), strCopy = LS (L_COPY), strPaste = LS (L_PASTE),
01473 strDldOpt = LS (L_DLDR_OPTIONS), strDldDef = LS (L_DLDDEFOPT),
01474 strPrgGen = LS (L_PRGGENSET), strLight = LS (L_LIGHT), strMedium = LS (L_MEDIUM),
01475 strHeavy = LS (L_HEAVY), strDial = LS (L_DIAL), strDoc = LS (L_DOCUMENTATION),
01476 strSpiderDefs = LS (L_SPIDERDEFSETTINGS), strExit = LS (L_EXIT),
01477 strExport = LS (L_EXPORTSETTINGS), strSaveAll = LS (L_SAVEALL),
01478 strImpFromClip = LS (L_IMPORTURLSFROMCLIPBOARD);
01479
01480 strCut += "\tCtrl+X"; strCopy += "\tCtrl+C"; strPaste += "\tCtrl+V";
01481 strDldOpt += "\tCtrl+O"; strDldDef += "\tCtrl+E";
01482 strPrgGen += "\tCtrl+P"; strLight += "\tCtrl+1"; strMedium += "\tCtrl+2"; strHeavy += "\tCtrl+3";
01483 strDial += "\tCtrl+D"; strDoc += "\tF1";
01484 strSpiderDefs += "\tCtrl+Q"; strExit += "\tAlt+X";
01485 strExport += '\t'; strSaveAll += "\tCtrl+S";
01486 strImpFromClip += "\tCtrl+Shift+V";
01487
01488 fsSetText aMenu0Texts [] = {
01489 fsSetText (0, LS (L_EXPORT)),
01490 fsSetText (1, LS (L_IMPORT)),
01491 };
01492 m_odmenu.SetMenuItemsText (GetMenu ()->GetSubMenu (0), aMenu0Texts,
01493 sizeof (aMenu0Texts) / sizeof (fsSetText), TRUE);
01494
01495 fsSetText aTexts [] = {
01496 fsSetText (ID_EXPORTSETTINGS, strExport),
01497 fsSetText (ID_IMPORTSETTINGS, LS (L_IMPORTSETTINGS)),
01498 fsSetText (ID_FILE_EXPORT_EXPORTLISTOFDOWNLOADS, LS (L_EXPORTLISTOFDLDS)),
01499 fsSetText (ID_EXPORTDLHIST, LS (L_EXPORTDLHIST)),
01500 fsSetText (ID_FILE_IMPORT_IMPORTLISTOFDOWNLOADS, LS (L_IMPORTLISTOFDLDS)),
01501 fsSetText (ID_FILE_IMPORT_IMPORTLISTOFDOWNLOADSFROMCLIPBOARD, strImpFromClip),
01502 fsSetText (ID_PORTABLE_FDM, LS (L_MAKE_PORTABLE_VER)),
01503 fsSetText (ID_APP_EXIT, strExit),
01504 fsSetText (ID_VIEW_TOOLBAR, LS (L_TOOLBAR)),
01505 fsSetText (ID_VIEW_STATUS_BAR, LS (L_STATUSBAR)),
01506 fsSetText (ID_DLINFOBOX, LS (L_DLSINFO)),
01507 fsSetText (ID_DROPBOX, LS (L_DROPBOX)),
01508 fsSetText (ID_SKIN_0, LS (L_NEWSTYLE)),
01509 fsSetText (ID_DLDROPTIONS, strDldOpt),
01510 fsSetText (ID_UPLDROPTIONS, LS (L_UPLMGRINTEGRSTGS)),
01511 fsSetText (ID_OPTIONS_SM, LS (L_OPTIONS_SM)),
01512 fsSetText (ID_OPTMASTER, LS (L_OPTMASTER)),
01513 fsSetText (ID_DLDDEFOPTIONS, strDldDef),
01514 fsSetText (ID_SPIDERDEFSETTINGS, strSpiderDefs),
01515 fsSetText (ID_PROGGENERALSETTINGS, strPrgGen),
01516 fsSetText (ID_TUM_LIGHT, strLight),
01517 fsSetText (ID_TUM_MEDIUM, strMedium),
01518 fsSetText (ID_TUM_HEAVY, strHeavy),
01519 fsSetText (ID_DIAL, strDial),
01520 fsSetText (ID_HANGUPWHENDONE, LS (L_HANGUPWD)),
01521 fsSetText (ID_TURNOFFWHENDONE, LS (L_TURNOFFWD)),
01522 fsSetText (ID_EXITWHENDONE, LS (L_EXITWHENDONE)),
01523 fsSetText (ID_HELP, strDoc),
01524 fsSetText (ID_HOMEPAGE, LS (L_HOMEPAGE)),
01525 fsSetText (ID_RECOMMEND, LS (L_RECOMMEND)),
01526 fsSetText (ID_SUPPORT, LS (L_TOSUPPORT)),
01527 fsSetText (ID_UPDATE, LS (L_UPDATENOW)),
01528 fsSetText (ID_SPREADHELP, LS (L_PLACELINKTOFDM)),
01529 fsSetText (ID_APP_ABOUT, LS (L_ABOUT)),
01530 };
01531 m_odmenu.SetMenuItemsText (GetMenu (), aTexts, sizeof (aTexts) / sizeof (fsSetText), FALSE);
01532
01533 m_odmenu.SetMenuItemText (GetMenu ()->GetSubMenu (1), LS (L_SWITCHTO), 6, TRUE);
01534 m_odmenu.SetMenuItemText (GetMenu ()->GetSubMenu (1), LS (L_SKIN), get_SkinsMenuPos (), TRUE);
01535 m_odmenu.SetMenuItemText (GetMenu ()->GetSubMenu (2), LS (L_TUM), GetTumMenuPosition (), TRUE);
01536
01537 m_wndView.m_wndClient.m_plugs2.OnNewLng ();
01538
01539 DrawMenuBar ();
01540 }
01541
01542 void CMainFrame::SetMenuImages()
01543 {
01544 fsSetImage images [] =
01545 {
01546
01547 fsSetImage (ID_DLDROPTIONS, 6),
01548 fsSetImage (ID_DLDDEFOPTIONS, 9),
01549
01550 fsSetImage (ID_TUM_LIGHT, 0),
01551 fsSetImage (ID_TUM_MEDIUM, 1),
01552 fsSetImage (ID_TUM_HEAVY, 2),
01553
01554 fsSetImage (ID_DIAL, 7),
01555
01556 fsSetImage (ID_HELP, 8),
01557 fsSetImage (ID_APP_ABOUT, 10),
01558 fsSetImage (ID_HOMEPAGE, 11),
01559 fsSetImage (ID_SUPPORT, 12)
01560 };
01561
01562 m_odmenu.SetImages (images, sizeof (images) / sizeof (fsSetImage));
01563 }
01564
01565 DWORD WINAPI CMainFrame::_threadUpdate(LPVOID lp)
01566 {
01567 CMainFrame *pThis = (CMainFrame*) lp;
01568 DWORD dw;
01569
01570 while (InternetGetConnectedState (&dw, 0) == FALSE)
01571 Sleep (10*60*1000);
01572
01573 SYSTEMTIME cur, last;
01574 GetLocalTime (&cur);
01575
01576 if (_App.Update_LastCheck (&last) == FALSE)
01577 {
01578 _App.Update_LastCheck (cur);
01579 return 0;
01580 }
01581
01582 if (_App.NewVerExists () || fsGetTimeDelta (&cur, &last) >= 5*24*60*60)
01583 {
01584 if (_UpdateMgr.IsRunning () == FALSE)
01585
01586 pThis->PostMessage (WM_COMMAND, ID_THREAD_UPDATE);
01587 }
01588
01589 return 0;
01590 }
01591
01592 void CMainFrame::OnSpiderDefSettings()
01593 {
01594 _pwndSpider->SetupDefSettings ();
01595 }
01596
01597 void CMainFrame::OnSpiderDLWebPage()
01598 {
01599 _pwndSpider->OnSpiderDl ();
01600 }
01601
01602 void CMainFrame::OnExportSettings()
01603 {
01604 CString strFilter;
01605 strFilter.Format ("%s (*.reg)|*.reg||", LS (L_REGFILES));
01606 CFileDialog dlg (FALSE, "reg", NULL, OFN_OVERWRITEPROMPT|OFN_NOCHANGEDIR, strFilter, this);
01607
01608 if (_DlgMgr.DoModal (&dlg) == IDCANCEL)
01609 return;
01610
01611 STARTUPINFO si;
01612 PROCESS_INFORMATION pi;
01613
01614 ZeroMemory (&si, sizeof (si));
01615 si.cb = sizeof (si);
01616 ZeroMemory (&pi, sizeof (pi));
01617
01618 CString strEx;
01619 strEx.Format ("regedit.exe /ea \"%s\" \"HKEY_CURRENT_USER\\Software\\OpenDownloadManager.ORG\\Open Download Manager\\Settings\"", dlg.GetPathName ());
01620
01621 if (FALSE == CreateProcess (NULL, (LPSTR)(LPCSTR)strEx, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
01622 {
01623 MessageBox (LS (L_REGEDITRUNFAILED), LS (L_ERR), MB_ICONERROR);
01624 return;
01625 }
01626
01627 WaitForSingleObject (pi.hProcess, INFINITE);
01628
01629 DWORD dwCode;
01630 GetExitCodeProcess (pi.hProcess, &dwCode);
01631 if (dwCode)
01632 MessageBox (LS (L_FAILEDTOEXPORT), LS (L_ERR), MB_ICONERROR);
01633 }
01634
01635 void CMainFrame::OnImportSettings()
01636 {
01637 CString strFilter;
01638 strFilter.Format ("%s (*.reg)|*.reg||", LS (L_REGFILES));
01639 CFileDialog dlg (TRUE, "reg", NULL, OFN_HIDEREADONLY|OFN_NOCHANGEDIR, strFilter, this);
01640
01641 if (dlg.DoModal () == IDCANCEL)
01642 return;
01643
01644 STARTUPINFO si;
01645 PROCESS_INFORMATION pi;
01646
01647 ZeroMemory (&si, sizeof (si));
01648 si.cb = sizeof (si);
01649 ZeroMemory (&pi, sizeof (pi));
01650
01651 CString strEx;
01652 strEx.Format ("regedit.exe /s \"%s\"", dlg.GetPathName ());
01653
01654 if (FALSE == CreateProcess (NULL, (LPSTR)(LPCSTR)strEx, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
01655 {
01656 MessageBox (LS (L_REGEDITRUNFAILED), LS (L_ERR), MB_ICONERROR);
01657 return;
01658 }
01659
01660 WaitForSingleObject (pi.hProcess, INFINITE);
01661
01662 DWORD dwCode;
01663 GetExitCodeProcess (pi.hProcess, &dwCode);
01664 if (dwCode)
01665 MessageBox (LS (L_FAILEDTOIMPORT), LS (L_ERR), MB_ICONERROR);
01666 else
01667 UpdateSettings ();
01668 }
01669
01670 void CMainFrame::UpdateSettings()
01671 {
01672 _DldsMgr.ReadSettings ();
01673 _DldsMgr.ApplyTrafficLimit ();
01674 _pwndHFE->GetMgr ()->ReadSettings ();
01675 _UpdateMgr.ReadSettings ();
01676 _IECatchMgr.ReadSettings ();
01677
01678 _pwndDownloads->m_ClpbrdCatch.Enable (_App.Monitor_Clipboard ());
01679 _IECatchMgr.ActivateIE2 (_App.Monitor_IE2 ());
01680 }
01681
01682 void CMainFrame::OnDropBox()
01683 {
01684 m_pFloatWndsThread->m_wndFloating.Show (!_App.View_FloatingWindow ());
01685 }
01686
01687 void CMainFrame::OnUpdateDropBox(CCmdUI *pCmdUI)
01688 {
01689 pCmdUI->SetCheck (_App.View_FloatingWindow () ? 1 : 0);
01690 }
01691
01692 UINT CMainFrame::m_umsgTaskBarCreated = 0;
01693
01694 LRESULT CMainFrame::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
01695 {
01696 if (msg == m_umsgTaskBarCreated)
01697 _TrayMgr.TestIcon ();
01698
01699 else if (msg == m_nShutdownMsg)
01700 PostMessage (WM_COMMAND, ID_APP_EXIT_2);
01701
01702 else if (msg == m_nUploadsMsg1 && _pwndUploads && _pwndUploads->m_pwndUploads)
01703 _pwndUploads->m_pwndUploads->get_Wnd ()->SendMessage (msg, wp, lp);
01704
01705 return CFrameWnd::WindowProc (msg, wp, lp);
01706 }
01707
01708 void CMainFrame::OnNcRButtonUp(UINT nHitTest, CPoint point)
01709 {
01710 CFrameWnd::OnNcRButtonUp(nHitTest, point);
01711 }
01712
01713 void CMainFrame::OnTBQueryDelete(NMHDR *, LRESULT *res)
01714 {
01715
01716 *res = FALSE;
01717 }
01718
01719 void CMainFrame::OnTBQueryInsert(NMHDR *, LRESULT *res)
01720 {
01721
01722 *res = FALSE;
01723 }
01724
01725 void CMainFrame::OnTBBeginDrag(NMHDR *, LRESULT *res)
01726 {
01727
01728 *res = FALSE;
01729 }
01730
01731 void CMainFrame::OnTBEndDrag(NMHDR *, LRESULT *res)
01732 {
01733
01734 *res = FALSE;
01735 }
01736
01737 void CMainFrame::OnTBBeginAdjust(NMHDR *, LRESULT *res)
01738 {
01739
01740 *res = FALSE;
01741 }
01742
01743 void CMainFrame::OnTBEndAdjust(NMHDR *, LRESULT *res)
01744 {
01745
01746 *res = FALSE;
01747 }
01748
01749 void CMainFrame::OnTBCustHelp(NMHDR *, LRESULT *res)
01750 {
01751
01752 *res = FALSE;
01753 }
01754
01755 void CMainFrame::OnTBReset(NMHDR *, LRESULT *res)
01756 {
01757
01758 *res = FALSE;
01759 }
01760
01761 void CMainFrame::OnTBGetButtonInfo(NMHDR *nm, LRESULT *res)
01762 {
01763 *res = _TBMgr.OnTBGetButtonInfo (nm);
01764 }
01765
01766 void CMainFrame::OnTBChange(NMHDR *, LRESULT *res)
01767 {
01768
01769 *res = FALSE;
01770 }
01771
01772 BOOL CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
01773 {
01774
01775 LPNMHDR nm = (LPNMHDR) lParam;
01776
01777 if (_TBMgr.OnNotify (nm) == FALSE && nm->code != TBN_GETINFOTIPW)
01778 {
01779 if (nm->idFrom == AFX_IDW_TOOLBAR)
01780 {
01781 switch (nm->code)
01782 {
01783 case TBN_QUERYDELETE:
01784 OnTBQueryDelete (nm, pResult);
01785 break;
01786
01787 case TBN_QUERYINSERT:
01788 OnTBQueryInsert (nm, pResult);
01789 break;
01790
01791 case TBN_BEGINADJUST:
01792 OnTBBeginAdjust (nm, pResult);
01793 break;
01794
01795 case TBN_ENDADJUST:
01796 OnTBEndAdjust (nm, pResult);
01797 break;
01798
01799 case TBN_BEGINDRAG:
01800 OnTBBeginDrag (nm, pResult);
01801 break;
01802
01803 case TBN_ENDDRAG:
01804 OnTBEndDrag (nm, pResult);
01805 break;
01806
01807 case TBN_CUSTHELP:
01808 OnTBCustHelp (nm, pResult);
01809 break;
01810
01811 case TBN_RESET:
01812 OnTBReset (nm, pResult);
01813 break;
01814
01815 case TBN_GETBUTTONINFO:
01816 OnTBGetButtonInfo (nm, pResult);
01817 break;
01818
01819 case TBN_TOOLBARCHANGE:
01820 OnTBChange (nm, pResult);
01821 break;
01822
01823 default:
01824 return DefWindowProc (WM_NOTIFY, wParam, lParam);
01825 }
01826
01827 return TRUE;
01828 }
01829 }
01830
01831 *pResult = FALSE;
01832 return FALSE;
01833 }
01834
01835 void CMainFrame::OnTimer(UINT nIDEvent)
01836 {
01837
01838 switch (nIDEvent)
01839 {
01840
01841 case 1:
01842 KillTimer (1);
01843
01844 break;
01845
01846 case 2:
01847 if (FALSE == is_MouseInTray ())
01848 {
01849 KillTimer (2);
01850 HideBalloon ();
01851 }
01852 break;
01853
01854 case 3:
01855 KillTimer (3);
01856 HideBalloon ();
01857 m_strTimeoutBallon_Msgs = "";
01858 break;
01859
01860 case 4:
01861 if (m_bBalloonShowing == FALSE)
01862 {
01863 if (is_MouseInTray ())
01864 {
01865 Balloon_ShowDLInfo (FALSE);
01866 SetTimer (2, 200, NULL);
01867 }
01868 }
01869 KillTimer (4);
01870 break;
01871
01872 case 5:
01873 DisplayBanner (0);
01874 KillTimer (5);
01875 break;
01876
01877 case 6:
01878 TotalTraffic_CheckMonthChange ();
01879 break;
01880 }
01881 }
01882
01883 void CMainFrame::AddPluginMenuView(HMENU hMenu, fsSetImage* pImages, int cImages)
01884 {
01885 if (hMenu == NULL)
01886 return;
01887
01888 if (m_cMenuViewItemsAdded)
01889 return;
01890
01891 m_cMenuViewItemsAdded = m_odmenu.InsertMenu (CMenu::FromHandle (hMenu), 8, GetMenu ()->GetSubMenu (1));
01892
01893 if (pImages) m_odmenu.SetImages (pImages, cImages);
01894 }
01895
01896 void CMainFrame::RemovePluginMenuView2()
01897 {
01898 if (m_cMenuViewItemsAdded)
01899 {
01900 m_odmenu.RemoveMenu (8 + m_cMenuViewItemsAdded - 1, m_cMenuViewItemsAdded, GetMenu ()->GetSubMenu (1));
01901 m_cMenuViewItemsAdded = 0;
01902 }
01903 }
01904
01905 BOOL CMainFrame::OnQueryEndSession()
01906 {
01907 if (!CFrameWnd::OnQueryEndSession())
01908 return FALSE;
01909
01910 return _PluginMgr.QueryExit ();
01911 }
01912
01913 void CMainFrame::OnIdUpdate()
01914 {
01915 StartUpdate (FALSE);
01916 }
01917
01918 void CMainFrame::OnInsert()
01919 {
01920 fsPluginInfo& plug = _PluginMgr.Plugin (
01921 m_wndView.m_wndClient.m_plugs2.GetActivePlugin ());
01922 ::PostMessage (plug.hWnd, WM_WGP_INSERT, 0, 0);
01923 }
01924
01925 void CMainFrame::HideBalloon()
01926 {
01927 if (m_bBalloonShowing)
01928 {
01929 _TrayMgr.ShowBalloon ("", "");
01930 m_bBalloonShowing = FALSE;
01931 }
01932 }
01933
01934 void CMainFrame::ShowBalloon(LPCSTR pszInfo, LPCSTR pszTitle, BOOL bCheckSettings, DWORD dwIcon)
01935 {
01936 if (bCheckSettings && _App.Notif_UseBalloon () == FALSE)
01937 return;
01938
01939 if (m_bTrayMenuShowing == FALSE)
01940 {
01941 _TrayMgr.ShowBalloon (pszInfo, pszTitle, dwIcon);
01942 m_bBalloonShowing = TRUE;
01943 }
01944 }
01945
01946 void CMainFrame::Balloon_ShowDLInfo(BOOL bCheckSettings)
01947 {
01948 CString str;
01949
01950 if (bCheckSettings && _App.Notif_UseBalloon () == FALSE)
01951 return;
01952
01953 for (size_t i = 0; i < _DldsMgr.GetCount (); i++)
01954 {
01955 vmsDownloadSmartPtr dld = _DldsMgr.GetDownload (i);
01956
01957 if (dld->pMgr->IsRunning ())
01958 {
01959
01960 if (i) str += '\n';
01961
01962 CString strtmp;
01963 char szFile [MY_MAX_PATH];
01964
01965 CDownloads_Tasks::GetFileName (dld, szFile);
01966
01967 if (dld->pMgr->GetDownloadingSectionCount ())
01968 {
01969 strtmp.Format ("%s - %d%%", szFile,
01970 (int) dld->pMgr->GetPercentDone ());
01971 }
01972 else if (dld->pMgr->IsCantStart () == FALSE)
01973 strtmp.Format ("%s - %s...", szFile, LS (L_STARTING));
01974 else
01975 strtmp.Format ("%s - %s", szFile, LS (L_ERR));
01976
01977 str += strtmp;
01978 }
01979 }
01980
01981 fsWebPageDownloadsMgr *pages = _pwndSpider->GetMgr ();
01982
01983 BOOL bAdded = FALSE;
01984
01985 for (i = 0; (int)i < pages->GetWPDCount (); i++)
01986 {
01987 fsWebPageDownloader* wpd = pages->GetWPD (i);
01988 if (wpd->IsRunning ())
01989 {
01990 if (bAdded == FALSE)
01991 {
01992 bAdded = TRUE;
01993 if (str != "")
01994 str += "\n\n";
01995 str += LS (L_WEBSITES);
01996 str += ':';
01997 }
01998
01999 CString strtmp;
02000
02001 char szUrl [10000];
02002
02003 wpd->GetDownloadingSiteName (szUrl);
02004
02005 strtmp.Format ("%s - %d%%", szUrl, (int) wpd->GetPercentDone ());
02006
02007 if (str != "")
02008 str += '\n';
02009
02010 str += strtmp;
02011 }
02012 }
02013
02014 if (str != "")
02015 {
02016 CString s = LS (L_ACTIVEDLDS);
02017 s += ':';
02018 ShowBalloon (str, s, FALSE);
02019 }
02020 else
02021 ShowBalloon (LS (L_THEREARENOACTDLDS), PRG_NAME, FALSE);
02022 }
02023
02024 void CMainFrame::ShowTimeoutBalloon(LPCSTR pszInfo, LPCSTR pszTitle, DWORD dwIcon, BOOL bClear)
02025 {
02026 CMainFrame *pThis = (CMainFrame*) AfxGetApp ()->m_pMainWnd;
02027
02028 if (bClear)
02029 pThis->m_strTimeoutBallon_Msgs = "";
02030
02031 CString str = pThis->m_strTimeoutBallon_Msgs;
02032
02033 pThis->ShowBalloon ("", "");
02034
02035 pThis->m_strTimeoutBallon_Msgs = pszInfo;
02036
02037 if (str != "")
02038 {
02039 pThis->m_strTimeoutBallon_Msgs += '\n';
02040 pThis->m_strTimeoutBallon_Msgs += str;
02041 }
02042
02043 pThis->ShowBalloon (pThis->m_strTimeoutBallon_Msgs, pszTitle, dwIcon);
02044
02045 pThis->SetTimer (3, _App.Notif_BalloonTimeout ()*1000, NULL);
02046 }
02047
02048 void CMainFrame::OnDlinfobox()
02049 {
02050 if (_App.View_FloatingInfoWindow ())
02051 {
02052 m_pFloatWndsThread->m_wndFloatingInfo.TurnOffWindow ();
02053 }
02054 else
02055 {
02056 _App.View_FloatingInfoWindow (TRUE);
02057 _pwndDownloads->UpdateTrayIconPlusOthers ();
02058 }
02059 }
02060
02061 void CMainFrame::RebuidDownloadsList()
02062 {
02063 if (m_pFloatWndsThread)
02064 m_pFloatWndsThread->m_wndFloatingInfo.RebuildList ();
02065 }
02066
02067 void CMainFrame::OnDllangfiles()
02068 {
02069 fsOpenUrlInBrowser ("http://www.opendownloadmanager.org/");
02070 }
02071
02072 void CMainFrame::RecalcLayout(BOOL bNotify)
02073 {
02074 CFrameWnd::RecalcLayout(bNotify);
02075
02076 if (IsWindow (_TBMgr) == FALSE ||
02077 IsWindow (m_wndView) == FALSE )
02078 return;
02079
02080 _TBMgr.AutoSize ();
02081
02082 REBARBANDINFO rbbi;
02083 rbbi.cbSize = sizeof (rbbi);
02084 rbbi.fMask = RBBIM_IDEALSIZE | RBBIM_SIZE;
02085 int nIndex = m_wndReBar.GetReBarCtrl ().IDToIndex (1);
02086 CRect rc; _TBMgr.GetWindowRect (&rc);
02087 rbbi.cx = rbbi.cxIdeal = rc.Width ();
02088 VERIFY (m_wndReBar.GetReBarCtrl ().SetBandInfo (nIndex, &rbbi));
02089
02090 if (::IsWindow (m_btnFDC))
02091 m_btnFDC.Invalidate (FALSE);
02092 }
02093
02094 void CMainFrame::OnFDC()
02095 {
02096 fsOpenUrlInBrowser (m_Customizations.get_ButtonInfo ()->pszLinksTo);
02097 }
02098
02099 void CMainFrame::OnProceedFurherInitialization()
02100 {
02101 m_bInited = TRUE;
02102
02103 _IECatchMgr.Initialize ();
02104
02105 _pwndDownloads->m_ClpbrdCatch.Initialize (&_IECatchMgr);
02106 _pwndDownloads->m_ClpbrdCatch.Create (_pwndDownloads);
02107 _pwndDownloads->m_ClpbrdCatch.Enable (_App.Monitor_Clipboard ());
02108
02109 CFdmApp* app = (CFdmApp*) AfxGetApp ();
02110 for (int i = 0; i < app->m_vUrlsToAdd.size (); i++)
02111 {
02112 BOOL bSilent = app->m_vUrlsToAdd [i].bForceSilent ? TRUE : _App.Monitor_Silent ();
02113 BOOL bAdded = _pwndDownloads->CreateDownload (app->m_vUrlsToAdd [i].strUrl, FALSE, NULL,
02114 NULL, bSilent);
02115
02116 if (bAdded && bSilent)
02117 ShowTimeoutBalloon (app->m_vUrlsToAdd [i].strUrl, LS (L_DOWNLOADADDED), NIIF_INFO, TRUE);
02118 }
02119
02120 for (i = 0; i < app->m_vTorrentFilesToAdd.size (); i++)
02121 {
02122 BOOL bSilent = app->m_vTorrentFilesToAdd [i].bForceSilent ? TRUE : _App.Monitor_Silent ();
02123 CString str = "file://"; str += app->m_vTorrentFilesToAdd [i].strUrl;
02124 BOOL bAdded = _pwndDownloads->CreateBtDownloadFromFile (app->m_vTorrentFilesToAdd [i].strUrl, str, bSilent);
02125
02126 if (bAdded && bSilent)
02127 ShowTimeoutBalloon (app->m_vTorrentFilesToAdd [i].strUrl, LS (L_DOWNLOADADDED), NIIF_INFO, TRUE);
02128 }
02129
02130 fsUrlsToDownloadRegKeyMgr mgr;
02131 mgr.CheckKey ();
02132
02133 _pwndScheduler->GetMgr ()->ExciteEvent (EV_STARTUP);
02134
02135 _DldsMgr.ProcessDownloads ();
02136
02137 switch (_pwndDownloads->Get_DWWN ())
02138 {
02139 case DWWN_LISTOFDOWNLOADS:
02140 _pwndDownloads->ApplyCurrentFilter ();
02141 break;
02142
02143 case DWWN_HISTORY:
02144 _pwndDownloads->ApplyHistoryCurrentFilter ();
02145 break;
02146 }
02147
02148 if (SHR_NEXTSTART == _App.View_SpreadHelpDialog ())
02149 m_bNeedSpreadHelpDialog = true;
02150
02151 if (_App.View_NOMShown () == FALSE)
02152 {
02153 _App.View_NOMShown (TRUE);
02154 PostMessage (WM_COMMAND, ID_OPTMASTER);
02155 }
02156
02157 ShowSpreadHelpDialogIfRequired ();
02158 }
02159
02160 void CMainFrame::OnAppAbout()
02161 {
02162 if (_DldsMgr.IsDeletingNow ())
02163 return;
02164 ((CFdmApp*) AfxGetApp ())->OnAppAbout ();
02165 }
02166
02167 void CMainFrame::OnExportlistofdownloads()
02168 {
02169 CDlgExportDownloads dlg;
02170 _DlgMgr.DoModal (&dlg);
02171 }
02172
02173 void CMainFrame::OnImportlistofdownloads()
02174 {
02175 CString strFilter;
02176 strFilter.Format ("%s (*.txt)|*.txt|%s (*.xml)|*.xml||", LS (L_URLLISTFILES), LS (L_DLINFOLISTFILES));
02177 CFileDialog dlg (TRUE, "txt", NULL, OFN_NOCHANGEDIR|OFN_HIDEREADONLY, strFilter, this);
02178
02179 if (_DlgMgr.DoModal (&dlg) == IDCANCEL)
02180 return;
02181
02182 if (dlg.GetFileExt ().CompareNoCase ("txt") == 0)
02183 ImportListOfDownloads_FromURLListFile (dlg.GetPathName ());
02184 else
02185 ImportListOfDownloads_FromDLInfoListFile (dlg.GetPathName ());
02186 }
02187
02188 void CMainFrame::OnExitwhendone()
02189 {
02190 _pwndScheduler->ExitWhenDone (_pwndScheduler->ExitWhenDone () == FALSE);
02191 }
02192
02193 void CMainFrame::OnUpdateExitwhendone(CCmdUI* pCmdUI)
02194 {
02195 pCmdUI->SetCheck (_pwndScheduler->ExitWhenDone () ? 1 : 0);
02196 }
02197
02198 void CMainFrame::OnFind()
02199 {
02200 CDlgFind dlg;
02201 if (IDOK == _DlgMgr.DoModal (&dlg))
02202 {
02203 _pwndDownloads->FindDownloads_Start ();
02204 m_wndView.m_wndClient.m_plugs2.SetActivePlugin (0);
02205 }
02206 }
02207
02208 void CMainFrame::OnFindnext()
02209 {
02210 m_wndView.m_wndClient.m_plugs2.SetActivePlugin (0);
02211
02212 _pwndDownloads->FindDownloads_FindNext ();
02213 }
02214
02215 void CMainFrame::OnUpdateFindnext(CCmdUI* pCmdUI)
02216 {
02217 pCmdUI->Enable (_pwndDownloads->IsFindNextAvail () ? 1 : 0);
02218 }
02219
02220 BOOL CMainFrame::OnEraseBkgnd(CDC* pDC)
02221 {
02222
02223 if (_pwndDownloads->m_wndDownloads.m_info.m_video.m_wndVideo.m_player.Get_State () != VFPS_CLOSED)
02224 {
02225 CRect rc;
02226
02227 _pwndDownloads->m_wndDownloads.m_info.m_video.GetWindowRect(&rc);
02228 ScreenToClient(&rc);
02229
02230 pDC->ExcludeClipRect(&rc);
02231 }
02232
02233 return CFrameWnd::OnEraseBkgnd(pDC);
02234 }
02235
02236 void CMainFrame::LoadToolImages()
02237 {
02238 if (!m_imgsTool.Create (_TB_SIZE_X, _TB_SIZE_Y, ILC_COLOR32 | ILC_MASK, 10, 5))
02239 return;
02240
02241 if (!m_dimgsTool.Create (_TB_SIZE_X, _TB_SIZE_Y, ILC_COLOR32 | ILC_MASK, 10, 5))
02242 return;
02243
02244 CBitmap bmp, bmpd;
02245
02246 bmp.Attach (SBMP (IDB_TOOL0));
02247 bmpd.Attach (SBMP (IDB_TOOL0_D));
02248
02249 if (_TB_USE_ALPHA)
02250 {
02251 ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmp, GetSysColor (COLOR_3DFACE));
02252 ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmpd, GetSysColor (COLOR_3DFACE));
02253 }
02254
02255 m_imgsTool.Add (&bmp, RGB (255, 0, 255));
02256 m_dimgsTool.Add (&bmpd, RGB (255, 0, 255));
02257 }
02258
02259 void CMainFrame::OnDonate()
02260 {
02261 fsOpenUrlInBrowser ("http://www.opendownloadmanager.org/donate/");
02262 }
02263
02264 LRESULT CMainFrame::OnShowTrayMenu(WPARAM, LPARAM)
02265 {
02266 ShowTrayMenu (FALSE);
02267 return 0;
02268 }
02269
02270 BOOL CMainFrame::ReadCusomizationInfo()
02271 {
02272 CString str = ((CFdmApp*)AfxGetApp ())->m_strAppPath;
02273 str += "fdmcs.dat";
02274
02275 HANDLE hFile = CreateFile (str, GENERIC_READ, FILE_SHARE_READ,
02276 NULL, OPEN_EXISTING, 0, NULL);
02277
02278 if (hFile == INVALID_HANDLE_VALUE)
02279 return FALSE;
02280
02281 if (GetFileSize (hFile, NULL) == 8)
02282 return TRUE;
02283
02284 try {
02285 m_Customizations.Load (hFile);
02286 }catch (LPCSTR){
02287 return FALSE;
02288 }
02289
02290 CloseHandle (hFile);
02291
02292 return TRUE;
02293 }
02294
02295 void CMainFrame::DisplayBanner(int iIndex)
02296 {
02297 LOG ("CMF:DB: enter" << nl);
02298
02299 vmsFDMBanner* banner = m_Customizations.get_Banner (iIndex);
02300 CString str = "fdmcsbr.";
02301 str += banner->szType;
02302 CString strFile = fsGetDataFilePath (str);
02303
02304 LOG ("CMF:DB: file" << nl);
02305
02306 HANDLE hFile = CreateFile (strFile, GENERIC_WRITE, 0, NULL,
02307 CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL);
02308 if (hFile == INVALID_HANDLE_VALUE)
02309 return;
02310 DWORD dw;
02311 WriteFile (hFile, banner->pbImage, banner->dwSize, &dw, NULL);
02312 CloseHandle (hFile);
02313
02314 LOG ("CMF:DB: set" << nl);
02315
02316 m_wndBanner.SetBanner (strFile, banner->pszLinksTo);
02317 DeleteFile (strFile);
02318
02319 LOG ("CMF:DB: done." << nl);
02320 }
02321
02322 void CMainFrame::SetupButton()
02323 {
02324 m_btnFDC.Create (this);
02325 m_wndReBar.AddBar (&m_btnFDC, NULL, NULL, RBBS_FIXEDBMP|RBBS_NOGRIPPER);
02326
02327 REBARBANDINFO rbbi;
02328 rbbi.cbSize = sizeof (rbbi);
02329 rbbi.fMask = RBBIM_IDEALSIZE | RBBIM_SIZE | RBBIM_CHILDSIZE;
02330 int nIndex = m_wndReBar.GetReBarCtrl ().GetBandCount ()-1;
02331 CRect rc; m_btnFDC.GetWindowRect (&rc);
02332
02333 m_wndReBar.GetReBarCtrl ().GetBandInfo (nIndex, &rbbi);
02334 rbbi.cx = rbbi.cxIdeal = rbbi.cyMaxChild = rc.Width () + 4;
02335 m_wndReBar.GetReBarCtrl ().SetBandInfo (nIndex, &rbbi);
02336 }
02337
02338 void CMainFrame::OnDldCreatebatch()
02339 {
02340 _pwndDownloads->OnDldcreatebatch ();
02341 }
02342
02343 vmsFDMCustomizations* CMainFrame::get_Customizations()
02344 {
02345 return &m_Customizations;
02346 }
02347
02348 void CMainFrame::ShowFloatingInfoWindow(BOOL bShow)
02349 {
02350 m_pFloatWndsThread->m_wndFloatingInfo.NeedToShow (bShow);
02351 }
02352
02353 BOOL CMainFrame::IsFloatingInfoWindowVisible()
02354 {
02355 return ::IsWindowVisible (m_pFloatWndsThread->m_wndFloatingInfo.m_hWnd);
02356 }
02357
02358 bool mainfrm__is_separator (char c)
02359 {
02360 return c == ' ' || c == '\t' || c == '\n' || c == '\r';
02361 }
02362
02363 void CMainFrame::OnFileImportImportlistofdownloadsfromclipboard()
02364 {
02365 vmsDWCD_AdditionalParameters ap;
02366 ap.dwMask = DWCDAP_GROUP;
02367
02368 CString strURLs = _ClipbrdMgr.Text ();
02369 LPCSTR pszURLs = strURLs;
02370
02371 DLDS_LIST v;
02372 vmsDownloadsGroupSmartPtr pGrp;
02373
02374 while (*pszURLs)
02375 {
02376
02377 while (mainfrm__is_separator (*pszURLs))
02378 *pszURLs++;
02379
02380 CString strURL;
02381
02382 while (*pszURLs)
02383 {
02384 if (mainfrm__is_separator (*pszURLs))
02385 {
02386 LPCSTR psz = pszURLs+1;
02387 while (mainfrm__is_separator (*psz))
02388 psz++;
02389 if (*psz == 0)
02390 break;
02391 if (_strnicmp (psz, "http://", 7) == 0 ||
02392 _strnicmp (psz, "https://", 8) == 0 ||
02393 _strnicmp (psz, "ftp://", 6) == 0)
02394 {
02395
02396 pszURLs = psz;
02397 break;
02398 }
02399 }
02400
02401 strURL += *pszURLs++;
02402 }
02403
02404
02405 if (strURL != "")
02406 {
02407 if (pGrp == NULL)
02408 {
02409 CDlg_ChooseGroup dlg;
02410 if (IDOK != _DlgMgr.DoModal (&dlg))
02411 return;
02412 pGrp = dlg.m_pGroup;
02413 }
02414
02415 vmsDownloadSmartPtr dld;
02416 Download_CreateInstance (dld);
02417
02418 if (FALSE == _pwndDownloads->CreateDownloadWithDefSettings (dld, strURL))
02419 continue;
02420
02421 dld->pGroup = pGrp;
02422
02423 v.push_back (dld);
02424 }
02425 }
02426
02427 if (v.size () != 0)
02428 _pwndDownloads->CreateDownloads (v, NULL);
02429 }
02430
02431 void CMainFrame::OnOptionsSm()
02432 {
02433 CSiteManagerSheet sheet (LS (L_OPTIONS_SM), this);
02434 _DlgMgr.DoModal (&sheet);
02435 }
02436
02437 int CMainFrame::get_SkinsMenuPos()
02438 {
02439 return GetMenu ()->GetSubMenu (1)->GetMenuItemCount () - 2;
02440 }
02441
02442 void CMainFrame::BuildSkinsMenu()
02443 {
02444 CMenu *menu = GetMenu ()->GetSubMenu (1);
02445 menu = menu->GetSubMenu (get_SkinsMenuPos ());
02446
02447 for (int i = 0; i < _SkinMgr.get_Count (); i++)
02448 {
02449 CString str = _SkinMgr.get_Skin (i)->strName;
02450 if (str.CompareNoCase ("Old Style") == 0)
02451 str = LS (L_OLDSTYLE);
02452 m_odmenu.InsertMenuItem (menu, str, ID_SKIN_0+1+i, i+2, TRUE);
02453 }
02454 }
02455
02456 void CMainFrame::OnSkin(UINT nID)
02457 {
02458 int nSkin = nID - ID_SKIN_0 - 1;
02459
02460 CString str = nSkin == -1 ? "" : _SkinMgr.get_Skin (nSkin)->strName;
02461 if (str == LS (L_OLDSTYLE))
02462 str = "Old Style";
02463 _App.Skin_Current (str);
02464
02465 if (nSkin != _SkinMgr.get_Current ())
02466 MessageBox (LS (L_RESTARTISREQ));
02467 }
02468
02469 void CMainFrame::OnUpdateSkin(CCmdUI *pCmdUI)
02470 {
02471 pCmdUI->SetCheck (_SkinMgr.get_Current () == (int)pCmdUI->m_nID - ID_SKIN_0 - 1);
02472 }
02473
02474 BOOL CMainFrame::is_MouseInTray()
02475 {
02476 POINT pt;
02477 return GetCursorPos (&pt) && abs (pt.x-m_balloonX) < 3 && abs (pt.y-m_balloonY) < 3;
02478 }
02479
02480 void CMainFrame::OnSpreadhelp()
02481 {
02482 m_bDontShowSHD = true;
02483
02484 CDlg_SpreadHelp2 dlg (this);
02485 _DlgMgr.DoModal (&dlg);
02486
02487 FILETIME ft; SYSTEMTIME st;
02488 GetLocalTime (&st);
02489 SystemTimeToFileTime (&st, &ft);
02490 _App.View_SpreadHelpDialog_LastTimeShown_save (ft);
02491
02492 m_bDontShowSHD = false;
02493 }
02494
02495 void CMainFrame::OnTUMChanged()
02496 {
02497 CDlg_TUMChanged dlg;
02498 _DlgMgr.DoModal (&dlg);
02499 }
02500
02501 BOOL CMainFrame::ImportListOfDownloads_FromURLListFile(LPCSTR pszFile)
02502 {
02503 CStdioFile file;
02504
02505 if (FALSE == file.Open (pszFile, CFile::modeRead))
02506 {
02507 MessageBox (LS (L_CANTOPENFILE), LS (L_ERR), MB_ICONERROR);
02508 return FALSE;
02509 }
02510
02511 DLDS_LIST v;
02512 vmsDownloadsGroupSmartPtr pGrp;
02513
02514 CString strUrl;
02515 do
02516 {
02517 file.ReadString (strUrl);
02518
02519 if (strUrl != "")
02520 {
02521 if (pGrp == NULL)
02522 {
02523 CDlg_ChooseGroup dlg;
02524 if (IDOK != _DlgMgr.DoModal (&dlg))
02525 return FALSE;
02526 pGrp = dlg.m_pGroup;
02527 }
02528
02529 vmsDownloadSmartPtr dld;
02530 Download_CreateInstance (dld);
02531
02532 if (FALSE == _pwndDownloads->CreateDownloadWithDefSettings (dld, strUrl))
02533 continue;
02534
02535 if (dld->pGroup != pGrp)
02536 {
02537 dld->pGroup = pGrp;
02538 LPSTR psz = new char [pGrp->strOutFolder.Length () + 1];
02539 lstrcpy (psz, pGrp->strOutFolder);
02540 delete [] dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName;
02541 dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName = psz;
02542 }
02543
02544 v.push_back (dld);
02545 }
02546 }
02547 while (strUrl != "");
02548
02549 if (v.size () != 0)
02550 _pwndDownloads->CreateDownloads (v, NULL);
02551
02552 return TRUE;
02553 }
02554
02555 BOOL CMainFrame::ImportListOfDownloads_FromDLInfoListFile(LPCSTR pszFile)
02556 {
02557 IXMLDOMDocumentPtr spXML;
02558 IXMLDOMNodePtr spNode;
02559
02560 spXML.CreateInstance (__uuidof (DOMDocument));
02561
02562 if (spXML == NULL)
02563 return FALSE;
02564
02565 spXML->put_async (FALSE);
02566
02567 VARIANT_BOOL bRes;
02568 spXML->load (COleVariant (pszFile), &bRes);
02569 if (bRes == FALSE)
02570 return FALSE;
02571
02572 spXML->selectSingleNode (L"FDM_Downloads_Info_List", &spNode);
02573 if (spNode == NULL)
02574 return FALSE;
02575
02576 IXMLDOMNodeListPtr spNodeList;
02577 spNode->get_childNodes (&spNodeList);
02578
02579 if (spNodeList == NULL)
02580 return FALSE;
02581
02582 IXMLDOMNodePtr spItem;
02583
02584 DLDS_LIST v;
02585
02586 while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
02587 {
02588 CComBSTR bstrName;
02589 spItem->get_nodeName (&bstrName);
02590
02591 if (bstrName == L"download")
02592 ImportDownload (spItem, v);
02593
02594 spItem = NULL;
02595 }
02596
02597 if (v.size () != 0)
02598 _pwndDownloads->CreateDownloads (v, NULL);
02599
02600 return TRUE;
02601 }
02602
02603 BOOL CMainFrame::ImportDownload(IXMLDOMNode *pNode, DLDS_LIST_REF v)
02604 {
02605 IXMLDOMNodeListPtr spNodeList;
02606 pNode->get_childNodes (&spNodeList);
02607
02608 if (spNodeList == NULL)
02609 return FALSE;
02610
02611 IXMLDOMNodePtr spItem;
02612
02613 vmsDWCD_AdditionalParameters params;
02614 params.dwMask = 0;
02615 CString strUrl;
02616 CString strComment;
02617
02618 while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
02619 {
02620 CComBSTR bstrName;
02621 spItem->get_nodeName (&bstrName);
02622
02623 if (bstrName == L"url")
02624 {
02625 COleVariant vtUrl;
02626 spItem->get_nodeTypedValue (&vtUrl);
02627 if (vtUrl.vt == VT_BSTR)
02628 strUrl = vtUrl.bstrVal;
02629 }
02630 else if (bstrName == L"comment")
02631 {
02632 COleVariant vt;
02633 spItem->get_nodeTypedValue (&vt);
02634 if (vt.vt == VT_BSTR)
02635 strComment = vt.bstrVal;
02636 }
02637 else if (bstrName == L"group")
02638 {
02639 COleVariant vt;
02640 spItem->get_nodeTypedValue (&vt);
02641 if (vt.vt == VT_BSTR)
02642 {
02643 CString str = vt.bstrVal;
02644 params.pGroup = _DldsGrps.FindGroupByName (str);
02645 if (params.pGroup == NULL)
02646 params.pGroup = _DldsGrps.FindGroup (GRP_OTHER_ID);
02647 params.dwMask |= DWCDAP_GROUP;
02648 }
02649 }
02650
02651 spItem = NULL;
02652 }
02653
02654 if (strUrl == "")
02655 return FALSE;
02656
02657 vmsDownloadSmartPtr dld;
02658 Download_CreateInstance (dld);
02659
02660 if (FALSE == _pwndDownloads->CreateDownloadWithDefSettings (dld, strUrl))
02661 return FALSE;
02662
02663 if (params.dwMask & DWCDAP_GROUP)
02664 {
02665 if (dld->pGroup != params.pGroup)
02666 {
02667 dld->pGroup = params.pGroup;
02668 LPSTR psz = new char [params.pGroup->strOutFolder.Length () + 1];
02669 lstrcpy (psz, params.pGroup->strOutFolder);
02670 delete [] dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName;
02671 dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName = psz;
02672 }
02673 }
02674
02675 dld->strComment = strComment;
02676
02677 v.push_back (dld);
02678
02679 return TRUE;
02680 }
02681
02682 void CMainFrame::OnExportdlhist()
02683 {
02684 CDlgExportHistory dlg;
02685 _DlgMgr.DoModal (&dlg);
02686 }
02687
02688 void CMainFrame::OnUpdateExportdlhist(CCmdUI* pCmdUI)
02689 {
02690 pCmdUI->Enable (_DldsMgr.m_histmgr.GetRecordCount () != 0);
02691 }
02692
02693 bool CMainFrame::ShowSpreadHelpDialogIfRequired()
02694 {
02695 if (m_bDontShowSHD)
02696 return false;
02697
02698 if (FALSE == IsWindowVisible ())
02699 return false;
02700
02701 bool bShow = false;
02702
02703 if (m_bNeedSpreadHelpDialog)
02704 {
02705 m_bNeedSpreadHelpDialog = false;
02706 bShow = true;
02707 }
02708
02709 if (bShow == false)
02710 {
02711 vmsSpreadHelpRemind en = _App.View_SpreadHelpDialog ();
02712 if (en != SHR_IN3DAYS && en != SHR_WAIT1STTIME)
02713 return false;
02714
02715 if (en == SHR_WAIT1STTIME)
02716 {
02717
02718 if (10 > _App.NumberOfDlCreatesByUser ())
02719 return false;
02720 }
02721
02722 FILETIME ft1, ft2;
02723
02724 if (_App.View_SpreadHelpDialog_LastTimeShown (ft1))
02725 {
02726 SYSTEMTIME st;
02727 GetLocalTime (&st);
02728 SystemTimeToFileTime (&st, &ft2);
02729
02730 UINT cDays = en == SHR_WAIT1STTIME ? 5 : 3;
02731
02732 if (fsGetTimeDelta (&ft2, &ft1) >= cDays*24*3600)
02733 bShow = true;
02734 }
02735 else
02736 {
02737 SYSTEMTIME st;
02738 FILETIME ft;
02739 GetLocalTime (&st);
02740 SystemTimeToFileTime (&st, &ft);
02741 _App.View_SpreadHelpDialog_LastTimeShown_save (ft);
02742 }
02743 }
02744
02745 if (bShow)
02746 {
02747 m_bDontShowSHD = true;
02748 PostMessage (WM_COMMAND, ID_SPREADHELP);
02749 }
02750
02751 return bShow;
02752 }
02753
02754 void CMainFrame::OnUpdateLdf0(CCmdUI* pCmdUI)
02755 {
02756 pCmdUI->Enable (_DldsMgr.get_LastFilesDownloaded ()->get_Count () != 0);
02757 }
02758
02759 void CMainFrame::OnLDF(UINT nID)
02760 {
02761 ShellExecute (NULL, "open", _DldsMgr.get_LastFilesDownloaded ()->get_FilePathName (nID - ID_LDF_0),
02762 NULL, NULL, SW_SHOW);
02763 }
02764
02765 void CMainFrame::OnLdfClear()
02766 {
02767 _DldsMgr.LastFilesDownloaded_Clear ();
02768 }
02769
02770 void CMainFrame::OnUpdateLdfClear(CCmdUI* pCmdUI)
02771 {
02772 pCmdUI->Enable (_DldsMgr.get_LastFilesDownloaded ()->get_Count () != 0);
02773 }
02774
02775 void CMainFrame::OnPausealldlds()
02776 {
02777 fsInternetDownloader::set_PauseMode (!fsInternetDownloader::is_PauseMode ());
02778 _BT.ApplyRestrainAllDownloadsMode ();
02779 }
02780
02781 void CMainFrame::OnUpdatePausealldlds(CCmdUI* pCmdUI)
02782 {
02783 pCmdUI->SetCheck (fsInternetDownloader::is_PauseMode ());
02784 }
02785
02786 void CMainFrame::OnUpdateTrafficThisMonth(CCmdUI *pCmdUI)
02787 {
02788 try {
02789 vmsBtSession *pS = _BT.is_Initialized () ? _BT.get_Session () : NULL;
02790 UINT64 u = pS ? pS->get_TotalDownloadedByteCount () : 0;
02791 UINT64 u2 = pS ? pS->get_TotalUploadedByteCount () : 0;
02792 CString str;
02793 str.Format ("%s; %s",
02794 BytesToString (m_nTrafficUsedThisMonth + fsInternetDownloader::get_TotalTraffic () + u),
02795 BytesToString (m_nTrafficUpldThisMonth + u2));
02796 pCmdUI->SetText (str);
02797
02798 CString str2;
02799 str2.Format ("%s; %s", BytesToString (m_nTrafficUsedPrevMonth), BytesToString (m_nTrafficUpldPrevMonth));
02800 str.Format (LS (L_TRAFF_USED_SBTEXT), str2);
02801 m_wndStatusBar.SetToolTipText (ID_SB_TRAFFIC_THISMONTH, str);
02802 }
02803 catch (...) {}
02804 }
02805
02806 void CMainFrame::OnUpdateTotalSpeed(CCmdUI *pCmdUI)
02807 {
02808 vmsBtSession *pS = _BT.is_Initialized () ? _BT.get_Session () : NULL;
02809 UINT64 u = pS ? pS->get_TotalUploadSpeed () : 0;
02810
02811 CString str;
02812 str.Format ("%s/%s; %s/%s", BytesToString (_pwndDownloads->get_TotalSpeed ()),
02813 LS (L_S), BytesToString (u), LS (L_S));
02814 pCmdUI->SetText (str);
02815 }
02816
02817 void CMainFrame::ReadTotalTrafficInfo()
02818 {
02819 m_nTrafficUsedThisMonth = _App.TotalTraffic ();
02820 m_nTrafficUsedPrevMonth = _App.TotalTraffic_PrevMonth ();
02821 m_nTrafficUpldThisMonth = _App.TotalUpldTraffic ();
02822 m_nTrafficUpldPrevMonth = _App.TotalUpldTraffic_PrevMonth ();
02823 m_nTotalTraffic_CurrMonth = _App.TotalTraffic_CurrMonth ();
02824
02825 TotalTraffic_CheckMonthChange ();
02826
02827
02828 SetTimer (6, 1000, NULL);
02829 }
02830
02831 void CMainFrame::TotalTraffic_CheckMonthChange()
02832 {
02833 SYSTEMTIME time;
02834 GetLocalTime (&time);
02835
02836 if (m_nTotalTraffic_CurrMonth == -1)
02837 _App.TotalTraffic_CurrMonth (m_nTotalTraffic_CurrMonth = time.wMonth);
02838
02839 if (m_nTotalTraffic_CurrMonth != time.wMonth)
02840 {
02841 m_nTrafficUsedPrevMonth = m_nTrafficUsedThisMonth;
02842 m_nTrafficUpldPrevMonth = m_nTrafficUpldThisMonth;
02843
02844 _App.TotalTraffic (m_nTrafficUsedThisMonth = 0);
02845 _App.TotalUpldTraffic (m_nTrafficUpldThisMonth = 0);
02846 _App.TotalTraffic_PrevMonth (m_nTrafficUsedPrevMonth);
02847 _App.TotalUpldTraffic_PrevMonth (m_nTrafficUpldPrevMonth);
02848 _App.TotalTraffic_CurrMonth (m_nTotalTraffic_CurrMonth = time.wMonth);
02849 }
02850 }
02851
02852 void CMainFrame::OnUpdateDlinfobox(CCmdUI* pCmdUI)
02853 {
02854 pCmdUI->SetCheck (_App.View_FloatingInfoWindow () ? 1 : 0);
02855 }
02856
02857 void CMainFrame::OnAppExit2()
02858 {
02859 _DlgMgr.EndAllDialogs ();
02860 PostMessage (WM_CLOSE);
02861 }
02862
02863 void CMainFrame::OnPortableFdm()
02864 {
02865 CDlg_MakePortableVer dlg;
02866 _DlgMgr.DoModal (&dlg);
02867 }
02868
02869 void CMainFrame::SetActivePlugin(int nIndex)
02870 {
02871 m_wndView.m_wndClient.m_plugs2.SetActivePlugin (nIndex);
02872 }
02873
02874 LRESULT CMainFrame::OnPowerBroadCast(WPARAM wParam, LPARAM)
02875 {
02876 if (wParam == PBT_APMRESUMESUSPEND)
02877 {
02878 _pwndScheduler->GetMgr ()->RepairTasksNextTimes ();
02879 _pwndScheduler->m_wndTasks.Invalidate ();
02880 }
02881 return TRUE;
02882 }
02883
02884 void CMainFrame::OnUpldroptions()
02885 {
02886 if (_pwndUploads && _pwndUploads->m_pwndUploads)
02887 _pwndUploads->m_pwndUploads->ShowProperties ();
02888 }
02889
02890 void CMainFrame::OnLoadatstartup()
02891 {
02892 _AutorunMgr.SetAutoStart (!_AutorunMgr.IsAutoStart ());
02893 }
02894
02895 void CMainFrame::OnUpdateLoadatstartup(CCmdUI* pCmdUI)
02896 {
02897 pCmdUI->SetCheck (_AutorunMgr.IsAutoStart ());
02898 }
02899
02900 int CMainFrame::GetTumMenuPosition()
02901 {
02902 return _pwndUploads && _pwndUploads->m_pwndUploads && (IS_PORTABLE_MODE == FALSE) ? 10 : 9;
02903 }