00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "FlashVideoDownloadsWnd.h"
00009 #include "plugincmds.h"
00010 #include "Dlg_CreateFVDownload.h"
00011
00012 #ifdef _DEBUG
00013 #define new DEBUG_NEW
00014 #undef THIS_FILE
00015 static char THIS_FILE[] = __FILE__;
00016 #endif
00017
00018 CFlashVideoDownloadsWnd *_pwndFVDownloads = NULL;
00019
00020 CFlashVideoDownloadsWnd::CFlashVideoDownloadsWnd()
00021 {
00022 m_wndPreview.set_InFVDownloads (TRUE);
00023 }
00024
00025 CFlashVideoDownloadsWnd::~CFlashVideoDownloadsWnd()
00026 {
00027 }
00028
00029 BEGIN_MESSAGE_MAP(CFlashVideoDownloadsWnd, CWnd)
00030
00031 ON_WM_CREATE()
00032 ON_WM_SIZE()
00033 ON_COMMAND(ID_FVDLD_CREATE, OnFvdldCreate)
00034 ON_COMMAND(ID_FVDLD_AUTOSTART, OnFvdldAutostart)
00035 ON_COMMAND(ID_FVDLD_DELETE, OnFvdldDelete)
00036 ON_COMMAND(ID_FVDLD_LAUNCH, OnFvdldLaunch)
00037 ON_COMMAND(ID_FVDLD_OPENFOLDER, OnFvdldOpenfolder)
00038 ON_COMMAND(ID_FVDLD_PASSTODLDS, OnFvdldPasstodlds)
00039 ON_COMMAND(ID_FVDLD_PROPERTIES, OnFvdldProperties)
00040 ON_COMMAND(ID_FVDLD_START, OnFvdldStart)
00041 ON_COMMAND(ID_FVDLD_STOP, OnFvdldStop)
00042 ON_COMMAND(ID_FVDLD_CONVERT, OnFvdldConvert)
00043
00044
00045 ON_MESSAGE (WM_WGP_SHUTDOWN, OnAppExit)
00046 ON_MESSAGE (WM_WGP_READYTOSHUTDOWN, OnAppQueryExit)
00047 ON_MESSAGE (WM_WGP_UPDATE_MENUMAIN, OnUpdateMenu)
00048 ON_MESSAGE (WM_WGP_UPDATE_MENUVIEW, OnUpdateMenuView)
00049 ON_MESSAGE (WM_WGP_UPDATE_CMDITEM, OnUpdateToolBar)
00050 ON_MESSAGE (WM_WGP_INSERT, OnInsert)
00051
00052 ON_COMMAND_RANGE(ID_DLLIST_1, ID_DLLIST_8, OnDLListShowCol)
00053
00054 END_MESSAGE_MAP()
00055
00056 BOOL CFlashVideoDownloadsWnd::Create(CWnd *pwndParent)
00057 {
00058 CRect rc (0, 0, 50, 50);
00059
00060 if (FALSE == CWnd::Create (AfxRegisterWndClass (0, NULL,
00061 NULL, NULL), NULL, WS_CHILD | WS_VISIBLE, rc, pwndParent, 0x1af))
00062 return FALSE;
00063
00064 return TRUE;
00065 }
00066
00067 HWND CFlashVideoDownloadsWnd::Plugin_CreateMainWindow(HWND hWndParent)
00068 {
00069 fsnew1 (_pwndFVDownloads, CFlashVideoDownloadsWnd);
00070
00071 _pwndFVDownloads->Create (CWnd::FromHandle (hWndParent));
00072
00073 return _pwndFVDownloads->m_hWnd;
00074 }
00075
00076 void CFlashVideoDownloadsWnd::Plugin_GetToolBarInfo(wgTButtonInfo **ppButtons, int *pcButtons)
00077 {
00078 static wgTButtonInfo btns [] =
00079 {
00080 wgTButtonInfo (ID_FVDLD_CREATE, TBSTYLE_BUTTON, ""),
00081 wgTButtonInfo (ID_FVDLD_START, TBSTYLE_BUTTON, ""),
00082 wgTButtonInfo (ID_FVDLD_STOP, TBSTYLE_BUTTON, ""),
00083 };
00084
00085 btns [0].pszToolTip = LS (L_NEWDLD);
00086 btns [1].pszToolTip = LS (L_STARTDLDS);
00087 btns [2].pszToolTip = LS (L_STOPDLDS);
00088
00089 *ppButtons = btns;
00090 *pcButtons = sizeof (btns) / sizeof (wgTButtonInfo);
00091 }
00092
00093 void CFlashVideoDownloadsWnd::Plugin_GetMenuImages(fsSetImage **ppImages, int *pcImages)
00094 {
00095 static fsSetImage images [] =
00096 {
00097 fsSetImage (ID_FVDLD_CREATE, 0),
00098 fsSetImage (ID_FVDLD_START, 1),
00099 fsSetImage (ID_FVDLD_STOP, 2),
00100 fsSetImage (ID_FVDLD_PROPERTIES, 6),
00101 fsSetImage (ID_FVDLD_DELETE, 7),
00102 };
00103
00104 *ppImages = images;
00105 *pcImages = sizeof (images) / sizeof (fsSetImage);
00106 }
00107
00108 void CFlashVideoDownloadsWnd::Plugin_GetMenuViewItems(wgMenuViewItem **ppItems, int* )
00109 {
00110 *ppItems = NULL;
00111 }
00112
00113 void CFlashVideoDownloadsWnd::Plugin_GetPluginNames(LPCSTR *ppszLong, LPCSTR *ppszShort)
00114 {
00115 static CString strName;
00116 strName = LSNP (L_FVDOWNLOADS);
00117 *ppszLong = *ppszShort = strName;
00118 }
00119
00120 void CFlashVideoDownloadsWnd::Plugin_SetLanguage(wgLanguage, HMENU hMenuMain, HMENU hMenuView)
00121 {
00122 CMenu *menu = CMenu::FromHandle (hMenuMain);
00123 _pwndFVDownloads->m_wndTasks.ApplyLanguageToMenu (menu);
00124 _pwndFVDownloads->m_wndTasks.ApplyLanguage ();
00125 _pwndFVDownloads->m_wndPreview.ApplyLanguage ();
00126 _pwndFVDownloads->ApplyLanguageToMenuView (CMenu::FromHandle (hMenuView));
00127 }
00128
00129 int CFlashVideoDownloadsWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
00130 {
00131 if (CWnd::OnCreate(lpCreateStruct) == -1)
00132 return -1;
00133
00134 m_wndTasks.Create (this);
00135 m_wndPreview.Create (this);
00136
00137 m_splitter.Create (AfxGetInstanceHandle (), m_hWnd, WST_HORIZONTAL);
00138 m_splitter.SetWnd1 (m_wndTasks.m_hWnd);
00139 m_splitter.SetWnd2 (m_wndPreview.m_hWnd);
00140 m_splitter.SetMinDimensions (50, 50);
00141 float fRatio = _App.View_SplitterRatio ("FVDownloads_DL_PREVIEW");
00142 if (fRatio < 0.1f)
00143 fRatio = 0.1f;
00144 m_splitter.SetRatio (fRatio);
00145
00146 m_wndPreview.ShowWindow (SW_SHOW);
00147
00148 for (size_t i = 0; i < _DldsMgr.GetCount (); i++)
00149 {
00150 if (_DldsMgr.GetDownload (i)->dwFlags & DLD_FLASH_VIDEO)
00151 m_wndTasks.AddDownload (_DldsMgr.GetDownload (i));
00152 }
00153
00154 return 0;
00155 }
00156
00157 void CFlashVideoDownloadsWnd::OnSize(UINT nType, int cx, int cy)
00158 {
00159 CWnd::OnSize(nType, cx, cy);
00160
00161 m_splitter.ApplyRatio ();
00162 }
00163
00164 void CFlashVideoDownloadsWnd::AddDownload(vmsDownloadSmartPtr dld)
00165 {
00166 ASSERT (dld->dwFlags & DLD_FLASH_VIDEO);
00167 m_wndTasks.AddDownload (dld);
00168 }
00169
00170 void CFlashVideoDownloadsWnd::OnFvdldCreate()
00171 {
00172 m_wndTasks.OnFvdldCreate ();
00173 }
00174
00175 void CFlashVideoDownloadsWnd::OnDownloadDone(vmsDownloadSmartPtr dld)
00176 {
00177
00178 }
00179
00180 LRESULT CFlashVideoDownloadsWnd::OnInsert(WPARAM, LPARAM)
00181 {
00182 m_wndTasks.OnFvdldCreate ();
00183 return 0;
00184 }
00185
00186 LRESULT CFlashVideoDownloadsWnd::OnAppExit(WPARAM, LPARAM)
00187 {
00188 SaveAll ();
00189 return 0;
00190 }
00191
00192 LRESULT CFlashVideoDownloadsWnd::OnAppQueryExit(WPARAM, LPARAM)
00193 {
00194 return 0;
00195 }
00196
00197 LRESULT CFlashVideoDownloadsWnd::OnUpdateMenu(WPARAM, LPARAM lp)
00198 {
00199 m_wndTasks.UpdateMenu (CMenu::FromHandle (*((HMENU*)lp)));
00200 return 0;
00201 }
00202
00203 LRESULT CFlashVideoDownloadsWnd::OnUpdateMenuView(WPARAM, LPARAM lp)
00204 {
00205 HMENU* pMenus = (HMENU*) lp;
00206 CMenu* menu = CMenu::FromHandle (pMenus [0]);
00207
00208 BOOL bEn = m_wndTasks.GetHeaderCtrl ()->GetItemCount () > 1;
00209 for (int i = 0; i < 8; i++)
00210 {
00211 if (m_wndTasks.IsColumnShown (i))
00212 {
00213 menu->CheckMenuItem (ID_DLLIST_1+i, MF_CHECKED);
00214 if (bEn == FALSE)
00215 menu->EnableMenuItem (ID_DLLIST_1+i, MF_GRAYED);
00216 }
00217 }
00218
00219 return 0;
00220 }
00221
00222 LRESULT CFlashVideoDownloadsWnd::OnUpdateToolBar(WPARAM wp, LPARAM)
00223 {
00224 return m_wndTasks.OnUpdateToolBar (wp);
00225 }
00226
00227 void CFlashVideoDownloadsWnd::ApplyLanguageToMenuView(CMenu *menu)
00228 {
00229 menu->ModifyMenu (0, MF_BYPOSITION | MF_STRING, 0, LS (L_LISTOFDLDS));
00230
00231 UINT aCmds [] = {ID_DLLIST_1, ID_DLLIST_2, ID_DLLIST_3, ID_DLLIST_4, ID_DLLIST_5,
00232 ID_DLLIST_6, ID_DLLIST_7, ID_DLLIST_8 };
00233 LPCSTR apszCmds [] = {LS (L_FILENAME), LS (L_SIZE), LS (L_DOWNLOADED),
00234 LS (L_TIMELEFT), LS (L_SECTIONS), LS (L_SPEED), LS (L_COMMENT), LS (L_ADDED) };
00235
00236 for (int i = 0; i < sizeof (aCmds) / sizeof (UINT); i++)
00237 menu->ModifyMenu (aCmds [i], MF_BYCOMMAND|MF_STRING, aCmds [i], apszCmds [i]);
00238 }
00239
00240 void CFlashVideoDownloadsWnd::OnDLListShowCol(UINT nCmd)
00241 {
00242 int iCol = nCmd - ID_DLLIST_1;
00243 m_wndTasks.ChangeColumnVisibility (iCol);
00244 }
00245
00246 void CFlashVideoDownloadsWnd::OnFvdldAutostart()
00247 {
00248 m_wndTasks.OnFvdldAutostart ();
00249 }
00250
00251 void CFlashVideoDownloadsWnd::OnFvdldDelete()
00252 {
00253 m_wndTasks.OnFvdldDelete ();
00254 }
00255
00256 void CFlashVideoDownloadsWnd::OnFvdldLaunch()
00257 {
00258 m_wndTasks.OnFvdldLaunch ();
00259 }
00260
00261 void CFlashVideoDownloadsWnd::OnFvdldOpenfolder()
00262 {
00263 m_wndTasks.OnFvdldOpenfolder ();
00264 }
00265
00266 void CFlashVideoDownloadsWnd::OnFvdldPasstodlds()
00267 {
00268 m_wndTasks.OnFvdldPasstodlds ();
00269 }
00270
00271 void CFlashVideoDownloadsWnd::OnFvdldProperties()
00272 {
00273 m_wndTasks.OnFvdldProperties ();
00274 }
00275
00276 void CFlashVideoDownloadsWnd::OnFvdldStart()
00277 {
00278 m_wndTasks.OnFvdldStart ();
00279 }
00280
00281 void CFlashVideoDownloadsWnd::OnFvdldStop()
00282 {
00283 m_wndTasks.OnFvdldStop ();
00284 }
00285
00286 void CFlashVideoDownloadsWnd::SaveAll()
00287 {
00288 ASSERT (::IsWindow (m_hWnd));
00289
00290 m_wndTasks.SaveState ();
00291 _App.View_SplitterRatio ("FVDownloads_DL_PREVIEW", m_splitter.GetRatio ());
00292 }
00293
00294 void CFlashVideoDownloadsWnd::SetActiveDownload(vmsDownloadSmartPtr dld)
00295 {
00296 m_wndPreview.Set_ActiveDownload (dld);
00297 }
00298
00299 void CFlashVideoDownloadsWnd::OnFvdldConvert()
00300 {
00301 m_wndTasks.OnFvdldConvert ();
00302 }
00303
00304 HMENU CFlashVideoDownloadsWnd::Plugin_GetMainMenu()
00305 {
00306 return LoadMenu (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDM_FVDOWNLOADS));
00307 }
00308
00309 HMENU CFlashVideoDownloadsWnd::Plugin_GetViewMenu()
00310 {
00311 return LoadMenu (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDM_FVDOWNLOADS_VIEW));
00312 }
00313
00314 BOOL CFlashVideoDownloadsWnd::CreateDownload(LPCSTR pszUrl)
00315 {
00316 CDlg_CreateFVDownload dlg;
00317 if (pszUrl)
00318 dlg.m_strUrl = pszUrl;
00319 if (IDOK != _DlgMgr.DoModal (&dlg))
00320 return FALSE;
00321
00322 vmsDWCD_AdditionalParameters ap;
00323 ap.dwMask = DWCDAP_FLAGS;
00324 ap.dwFlags = DWDCDAP_F_FLASHVIDEODOWNLOAD;
00325
00326 if (dlg.m_bAutoConvert)
00327 {
00328 ap.dwMask |= DWCDAP_MEDIA_CONVERT_SETTINGS;
00329 ap.stgsMediaConvert = dlg.m_stgsAutoConvert;
00330 }
00331
00332 return _pwndDownloads->CreateDownload (dlg.m_strUrl, FALSE, NULL, NULL,
00333 dlg.m_bSetupAdvStgs == FALSE, DWCD_NOFORCEAUTOLAUNCH, NULL, &ap);
00334 }