Index: ch.vc90.sln =================================================================== diff -u -N -r154fc06f40ba8d9b53e6a4fb9014eb4de53e50a8 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- ch.vc90.sln (.../ch.vc90.sln) (revision 154fc06f40ba8d9b53e6a4fb9014eb4de53e50a8) +++ ch.vc90.sln (.../ch.vc90.sln) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -11,6 +11,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chext", "src\chext\chext.vc90.vcproj", "{7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}" ProjectSection(ProjectDependencies) = postProject + {CBBF380B-7B16-4A1E-8194-758DAD7D8011} = {CBBF380B-7B16-4A1E-8194-758DAD7D8011} {5510B933-046F-4F75-8B46-5E8279C8CCDE} = {5510B933-046F-4F75-8B46-5E8279C8CCDE} EndProjectSection EndProject Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -N -r0c09e62b3e90352413f389fdfe4b9bc49a1bcc89 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 0c09e62b3e90352413f389fdfe4b9bc49a1bcc89) +++ src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -38,30 +38,25 @@ // CCustomCopyDlg dialog -CCustomCopyDlg::CCustomCopyDlg() :ictranslate::CLanguageDialog(CCustomCopyDlg::IDD) +CCustomCopyDlg::CCustomCopyDlg() : + ictranslate::CLanguageDialog(CCustomCopyDlg::IDD) { - //{{AFX_DATA_INIT(CCustomCopyDlg) m_bOnlyCreate = FALSE; m_bIgnoreFolders = FALSE; m_bFilters = FALSE; m_bAdvanced = FALSE; m_bForceDirectories = FALSE; - //}}AFX_DATA_INIT -// m_ccData.m_astrPaths.RemoveAll(); // unneeded -// m_ccData.m_strDestPath.Empty(); - - m_ccData.m_iOperation=0; - m_ccData.m_iPriority=THREAD_PRIORITY_NORMAL; + GetConfig().ExtractSubConfig(BRANCH_TASK_SETTINGS, m_tTaskDefinition.GetConfiguration()); - // m_ccData.m_bsSizes stays uninitialized - // m_ccData.m_afFilters - this too - - m_ccData.m_bIgnoreFolders=false; - m_ccData.m_bForceDirectories=false; - m_ccData.m_bCreateStructure=false; + m_bActualisation = false; +} - m_bActualisation=false; +CCustomCopyDlg::CCustomCopyDlg(const chcore::TTaskDefinition& rTaskDefinition) : + ictranslate::CLanguageDialog(CCustomCopyDlg::IDD), + m_tTaskDefinition(rTaskDefinition) +{ + } void CCustomCopyDlg::DoDataExchange(CDataExchange* pDX) @@ -184,8 +179,10 @@ m_ctlFiles.InsertColumn(1, &lvc); // fill paths' listbox - for (int i=0;i(m_tTaskDefinition.GetConfiguration()))); // fill buffer sizes listbox SetBuffersizesString(); @@ -279,14 +276,17 @@ lvc.cchTextMax=lstrlen(lvc.pszText); lvc.cx=static_cast(0.1*rc.Width()); m_ctlFilters.InsertColumn(6, &lvc); - - m_bFilters = !m_ccData.m_afFilters.IsEmpty(); + CFiltersArray afFilters; + GetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); + + m_bFilters = !afFilters.IsEmpty(); + // other custom flags - m_bAdvanced=(m_ccData.m_bIgnoreFolders | m_ccData.m_bCreateStructure); - m_bIgnoreFolders=m_ccData.m_bIgnoreFolders; - m_bForceDirectories=m_ccData.m_bForceDirectories; - m_bOnlyCreate=m_ccData.m_bCreateStructure; + m_bIgnoreFolders = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + m_bForceDirectories = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + m_bOnlyCreate = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + m_bAdvanced = (m_bIgnoreFolders | m_bForceDirectories | m_bOnlyCreate); UpdateData(FALSE); @@ -378,10 +378,11 @@ m_ctlFilters.InsertColumn(6, &lvc); // refresh the entries in filters' list + CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); m_ctlFilters.DeleteAllItems(); - for (size_t stIndex = 0; stIndex < m_ccData.m_afFilters.GetSize(); ++stIndex) + for(size_t stIndex = 0; stIndex < afFilters.GetSize(); ++stIndex) { - const CFileFilter* pFilter = m_ccData.m_afFilters.GetAt(stIndex); + const CFileFilter* pFilter = afFilters.GetAt(stIndex); if(pFilter) AddFilter(*pFilter, boost::numeric_cast(stIndex)); } @@ -461,34 +462,37 @@ { UpdateData(TRUE); - // copy files from listctrl to an array - m_ccData.m_astrPaths.RemoveAll(); CString strPath; + m_ctlDstPath.GetWindowText(strPath); - for (int i=0;i(m_tTaskDefinition.GetConfiguration(), m_ctlPriority.GetCurSel()); - // buffersize is being changed realtime - // so as filter + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bIgnoreFolders != 0)); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bForceDirectories != 0)); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bOnlyCreate != 0)); - m_ccData.m_bIgnoreFolders=(m_bIgnoreFolders != 0); - m_ccData.m_bForceDirectories=(m_bForceDirectories != 0); - m_ccData.m_bCreateStructure=(m_bOnlyCreate != 0); - - if (m_ccData.m_strDestPath.IsEmpty() || m_ccData.m_astrPaths.GetSize() == 0) - MsgBox(IDS_MISSINGDATA_STRING); - else - CLanguageDialog::OnOK(); + CLanguageDialog::OnOK(); } void CCustomCopyDlg::SetBuffersizesString() @@ -506,37 +510,58 @@ TCHAR szSize[64]; ictranslate::CFormat fmt; + BUFFERSIZES bsSizes; + bsSizes.m_bOnlyDefault = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + bsSizes.m_uiDefaultSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + bsSizes.m_uiOneDiskSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + bsSizes.m_uiTwoDisksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + bsSizes.m_uiCDSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + bsSizes.m_uiLANSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + fmt.SetFormat(GetResManager().LoadString(IDS_BSEDEFAULT_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(m_ccData.m_bsSizes.m_uiDefaultSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiDefaultSize, szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); - if (!m_ccData.m_bsSizes.m_bOnlyDefault) + if (!bsSizes.m_bOnlyDefault) { fmt.SetFormat(GetResManager().LoadString(IDS_BSEONEDISK_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(m_ccData.m_bsSizes.m_uiOneDiskSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiOneDiskSize, szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSETWODISKS_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(m_ccData.m_bsSizes.m_uiTwoDisksSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiTwoDisksSize, szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSECD_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(m_ccData.m_bsSizes.m_uiCDSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiCDSize, szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSELAN_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(m_ccData.m_bsSizes.m_uiLANSize, szSize, 64, true)); + fmt.SetParam(_t("%size"), GetSizeString(bsSizes.m_uiLANSize, szSize, 64, true)); m_ctlBufferSizes.AddString(fmt); } } void CCustomCopyDlg::OnChangebufferButton() { CBufferSizeDlg dlg; - dlg.m_bsSizes=m_ccData.m_bsSizes; - if (dlg.DoModal() == IDOK) + + dlg.m_bsSizes.m_bOnlyDefault = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiDefaultSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiOneDiskSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiTwoDisksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiCDSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiLANSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + + if(dlg.DoModal() == IDOK) { - m_ccData.m_bsSizes=dlg.m_bsSizes; + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_bOnlyDefault); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiDefaultSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiOneDiskSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiTwoDisksSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiCDSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiLANSize); + SetBuffersizesString(); } } @@ -566,9 +591,11 @@ { CFilterDlg dlg; CString strData; - for (size_t i=0;i(m_tTaskDefinition.GetConfiguration()); + for (size_t i = 0; i < afFilters.GetSize(); i++) { - const CFileFilter* pFilter = m_ccData.m_afFilters.GetAt(i); + const CFileFilter* pFilter = afFilters.GetAt(i); BOOST_ASSERT(pFilter); if(pFilter) { @@ -579,12 +606,12 @@ } } - if (dlg.DoModal() == IDOK) + if(dlg.DoModal() == IDOK) { - if (dlg.m_ffFilter.m_bUseMask || dlg.m_ffFilter.m_bUseExcludeMask || dlg.m_ffFilter.m_bUseSize - || dlg.m_ffFilter.m_bUseDate || dlg.m_ffFilter.m_bUseAttributes) + if(dlg.m_ffFilter.m_bUseMask || dlg.m_ffFilter.m_bUseExcludeMask || dlg.m_ffFilter.m_bUseSize || dlg.m_ffFilter.m_bUseDate || dlg.m_ffFilter.m_bUseAttributes) { - m_ccData.m_afFilters.Add(dlg.m_ffFilter); + afFilters.Add(dlg.m_ffFilter); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); AddFilter(dlg.m_ffFilter); } else @@ -735,9 +762,11 @@ void CCustomCopyDlg::OnRemovefilterButton() { + CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + POSITION pos; int iItem; - while (true) + while(true) { pos=m_ctlFilters.GetFirstSelectedItemPosition(); if (pos == NULL) @@ -746,7 +775,9 @@ { iItem=m_ctlFilters.GetNextSelectedItem(pos); m_ctlFilters.DeleteItem(iItem); - m_ccData.m_afFilters.RemoveAt(iItem); + afFilters.RemoveAt(iItem); + + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); } } } @@ -789,20 +820,22 @@ void CCustomCopyDlg::OnDblclkFiltersList(NMHDR* /*pNMHDR*/, LRESULT* pResult) { - POSITION pos=m_ctlFilters.GetFirstSelectedItemPosition(); - if (pos != NULL) + POSITION pos = m_ctlFilters.GetFirstSelectedItemPosition(); + if(pos != NULL) { - int iItem=m_ctlFilters.GetNextSelectedItem(pos); + CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + + int iItem = m_ctlFilters.GetNextSelectedItem(pos); CFilterDlg dlg; - const CFileFilter* pFilter = m_ccData.m_afFilters.GetAt(iItem); + const CFileFilter* pFilter = afFilters.GetAt(iItem); BOOST_ASSERT(pFilter); if(pFilter) - dlg.m_ffFilter = *pFilter; + dlg.m_ffFilter = *pFilter; CString strData; - for (size_t stIndex = 0; stIndex < m_ccData.m_afFilters.GetSize(); ++stIndex) + for(size_t stIndex = 0; stIndex < afFilters.GetSize(); ++stIndex) { - pFilter = m_ccData.m_afFilters.GetAt(stIndex); + pFilter = afFilters.GetAt(stIndex); BOOST_ASSERT(pFilter); if(pFilter) { @@ -823,7 +856,8 @@ if (dlg.m_ffFilter.m_bUseMask || dlg.m_ffFilter.m_bUseExcludeMask || dlg.m_ffFilter.m_bUseSize || dlg.m_ffFilter.m_bUseDate || dlg.m_ffFilter.m_bUseAttributes) { - m_ccData.m_afFilters.SetAt(iItem, dlg.m_ffFilter); + afFilters.SetAt(iItem, dlg.m_ffFilter); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); AddFilter(dlg.m_ffFilter, iItem); } } @@ -834,15 +868,28 @@ void CCustomCopyDlg::OnDblclkBuffersizesList() { - int iItem=m_ctlBufferSizes.GetCurSel(); - if (iItem != LB_ERR) + int iItem = m_ctlBufferSizes.GetCurSel(); + if(iItem != LB_ERR) { CBufferSizeDlg dlg; - dlg.m_bsSizes=m_ccData.m_bsSizes; - dlg.m_iActiveIndex=iItem; - if (dlg.DoModal() == IDOK) + + dlg.m_bsSizes.m_bOnlyDefault = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiDefaultSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiOneDiskSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiTwoDisksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiCDSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + dlg.m_bsSizes.m_uiLANSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + + dlg.m_iActiveIndex = iItem; + if(dlg.DoModal() == IDOK) { - m_ccData.m_bsSizes=dlg.m_bsSizes; + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_bOnlyDefault); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiDefaultSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiOneDiskSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiTwoDisksSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiCDSize); + SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.m_uiLANSize); + SetBuffersizesString(); } } Index: src/ch/CustomCopyDlg.h =================================================================== diff -u -N -r9ea1e103b5fa4ddfebf8028f121ce16e917eec04 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/ch/CustomCopyDlg.h (.../CustomCopyDlg.h) (revision 9ea1e103b5fa4ddfebf8028f121ce16e917eec04) +++ src/ch/CustomCopyDlg.h (.../CustomCopyDlg.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -21,6 +21,7 @@ #include "DataBuffer.h" #include "FileFilter.h" +#include "../libchcore/TTaskDefinition.h" ///////////////////////////////////////////////////////////////////////////// // CCustomCopyDlg dialog @@ -30,48 +31,14 @@ // Construction public: CCustomCopyDlg(); // standard constructor + CCustomCopyDlg(const chcore::TTaskDefinition& rTaskDefinition); - void SetBuffersizesString(); - - struct _CCDATA - { - CStringArray m_astrPaths; // source paths to copy/move - CString m_strDestPath; // currently selected destination path - std::vector m_vRecent; // recently selected paths - int m_iOperation; // copy || move - int m_iPriority; // operation priority - BUFFERSIZES m_bsSizes; // buffer sizes selected for this task - - CFiltersArray m_afFilters; // list of filters to select from combos - - bool m_bIgnoreFolders; - bool m_bForceDirectories; - bool m_bCreateStructure; - } m_ccData; - - bool m_bActualisation; // is this dialog processing the combo text changing ? // Dialog Data - //{{AFX_DATA(CCustomCopyDlg) enum { IDD = IDD_CUSTOM_COPY_DIALOG }; - CComboBoxEx m_ctlDstPath; - CListCtrl m_ctlFilters; - CListBox m_ctlBufferSizes; - CComboBox m_ctlOperation; - CComboBox m_ctlPriority; - CListCtrl m_ctlFiles; - BOOL m_bOnlyCreate; - BOOL m_bIgnoreFolders; - BOOL m_bForceDirectories; - BOOL m_bFilters; - BOOL m_bAdvanced; - //}}AFX_DATA // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CCustomCopyDlg) - protected: +protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL // Implementation protected: @@ -82,10 +49,10 @@ void EnableControls(); void AddFilter(const CFileFilter& rFilter, int iPos=-1); void AddPath(CString strPath); - CImageList m_ilImages; + void SetBuffersizesString(); + // Generated message map functions - //{{AFX_MSG(CCustomCopyDlg) virtual BOOL OnInitDialog(); afx_msg void OnAddDirectoryButton(); afx_msg void OnAddFilesButton(); @@ -105,11 +72,26 @@ afx_msg void OnImportButton(); afx_msg void OnIgnorefoldersCheck(); afx_msg void OnForcedirectoriesCheck(); - //}}AFX_MSG + DECLARE_MESSAGE_MAP() -}; -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. +public: + chcore::TTaskDefinition m_tTaskDefinition; + std::vector m_vRecent; // recently selected paths + bool m_bActualisation; // is this dialog processing the combo text changing ? + CComboBoxEx m_ctlDstPath; + CListCtrl m_ctlFilters; + CListBox m_ctlBufferSizes; + CComboBox m_ctlOperation; + CComboBox m_ctlPriority; + CListCtrl m_ctlFiles; + BOOL m_bOnlyCreate; + BOOL m_bIgnoreFolders; + BOOL m_bForceDirectories; + BOOL m_bFilters; + BOOL m_bAdvanced; + CImageList m_ilImages; +}; + #endif Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r6dc950d4d76107421ff6eb62069b70f20bcc450e -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -34,6 +34,7 @@ #include "ClipboardMonitor.h" #include #include +#include "../libchcore/TWStringData.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -459,134 +460,53 @@ pDlg->Create(); } -BOOL CMainWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) +BOOL CMainWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { - // copying or moving ? - bool bMove=false; - switch(pCopyDataStruct->dwData & CSharedConfigStruct::OPERATION_MASK) - { - case CSharedConfigStruct::DD_MOVE_FLAG: - case CSharedConfigStruct::EC_MOVETO_FLAG: - bMove=true; - break; - case CSharedConfigStruct::EC_PASTE_FLAG: - case CSharedConfigStruct::EC_PASTESPECIAL_FLAG: - bMove=(pCopyDataStruct->dwData & ~CSharedConfigStruct::OPERATION_MASK) != 0; - break; - } + // load task from buffer + wchar_t* pszBuffer = static_cast(pCopyDataStruct->lpData); + unsigned long ulLen = pCopyDataStruct->cbData / sizeof(wchar_t); - // buffer with: dst path and src paths separated by single '\0' - TCHAR *pBuffer=static_cast(pCopyDataStruct->lpData); - unsigned long ulLen=pCopyDataStruct->cbData / sizeof(TCHAR); + // check if the string ends with '\0', so we can safely use it without length checks + if(!pszBuffer || ulLen == 0 || pszBuffer[ulLen - 1] != L'\0') + return FALSE; - CString str, strDstPath; - CStringArray astrFiles; - UINT iOffset=0; + chcore::TWStringData wstrData(pszBuffer); + //AfxMessageBox(wstrData.GetData()); // TEMP = to remove before commit - do - { - str=pBuffer+iOffset; - if (iOffset == 0) - strDstPath=str; - else - astrFiles.Add(str); + chcore::TTaskDefinition tTaskDefinition; + tTaskDefinition.LoadFromString(wstrData); - iOffset+=str.GetLength()+1; - } - while (iOffset < ulLen); - + // apply current options from global config; in the future we might want to merge the incoming options with global ones instead of overwriting... chcore::TConfig& rConfig = GetConfig(); + rConfig.ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); // special operation - modify stuff - CFiltersArray ffFilters; - int iPriority = boost::numeric_cast(GetPropValue(GetConfig())); - BUFFERSIZES bsSizes; - bsSizes.m_bOnlyDefault=GetPropValue(GetConfig()); - bsSizes.m_uiDefaultSize=GetPropValue(GetConfig()); - bsSizes.m_uiOneDiskSize=GetPropValue(GetConfig()); - bsSizes.m_uiTwoDisksSize=GetPropValue(GetConfig()); - bsSizes.m_uiCDSize=GetPropValue(GetConfig()); - bsSizes.m_uiLANSize=GetPropValue(GetConfig()); - - BOOL bOnlyCreate=FALSE; - BOOL bIgnoreDirs=FALSE; - BOOL bForceDirectories=FALSE; switch(pCopyDataStruct->dwData & CSharedConfigStruct::OPERATION_MASK) { case CSharedConfigStruct::DD_COPYMOVESPECIAL_FLAG: case CSharedConfigStruct::EC_PASTESPECIAL_FLAG: case CSharedConfigStruct::EC_COPYMOVETOSPECIAL_FLAG: - CCustomCopyDlg dlg; - dlg.m_ccData.m_astrPaths.Copy(astrFiles); - dlg.m_ccData.m_iOperation=bMove ? 1 : 0; - dlg.m_ccData.m_iPriority=iPriority; - dlg.m_ccData.m_strDestPath=strDstPath; - dlg.m_ccData.m_bsSizes=bsSizes; - dlg.m_ccData.m_bIgnoreFolders=(bIgnoreDirs != 0); - dlg.m_ccData.m_bForceDirectories=(bForceDirectories != 0); - dlg.m_ccData.m_bCreateStructure=(bOnlyCreate != 0); + CCustomCopyDlg dlg(tTaskDefinition); - dlg.m_ccData.m_vRecent.clear(); + GetPropValue(rConfig, dlg.m_vRecent); - GetPropValue(rConfig, dlg.m_ccData.m_vRecent); - INT_PTR iModalResult; - if ( (iModalResult=dlg.DoModal()) == IDCANCEL) + if((iModalResult = dlg.DoModal()) == IDCANCEL) return CWnd::OnCopyData(pWnd, pCopyDataStruct); - else if (iModalResult == -1) // windows has been closed by a parent + else if(iModalResult == -1) // windows has been closed by a parent return TRUE; - astrFiles.Copy(dlg.m_ccData.m_astrPaths); - bMove=(dlg.m_ccData.m_iOperation != 0); - iPriority=dlg.m_ccData.m_iPriority; - strDstPath=dlg.m_ccData.m_strDestPath; - bsSizes=dlg.m_ccData.m_bsSizes; - ffFilters = dlg.m_ccData.m_afFilters; - bIgnoreDirs=dlg.m_ccData.m_bIgnoreFolders; - bForceDirectories=dlg.m_ccData.m_bForceDirectories; - bOnlyCreate=dlg.m_ccData.m_bCreateStructure; - dlg.m_ccData.m_vRecent.insert(dlg.m_ccData.m_vRecent.begin(), strDstPath); + dlg.m_vRecent.push_back(dlg.m_tTaskDefinition.GetDestinationPath().ToString()); - SetPropValue(rConfig, dlg.m_ccData.m_vRecent); - } + SetPropValue(rConfig, dlg.m_vRecent); - // create new task - chcore::TTaskDefinition tTaskDefinition; - tTaskDefinition.SetDestinationPath(chcore::PathFromString(strDstPath)); - - // files - for(int i = 0; i < astrFiles.GetSize(); i++) - { - tTaskDefinition.AddSourcePath(chcore::PathFromString(astrFiles.GetAt(i))); + tTaskDefinition = dlg.m_tTaskDefinition; } - tTaskDefinition.SetOperationType(bMove ? chcore::eOperation_Move : chcore::eOperation_Copy); - - // set the default options for task - GetConfig().ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); - - // and override them with manual settings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bOnlyCreate != FALSE); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bForceDirectories != FALSE); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bIgnoreDirs != FALSE); - - // buffer sizes - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bsSizes.m_uiDefaultSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bsSizes.m_uiOneDiskSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bsSizes.m_uiTwoDisksSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bsSizes.m_uiCDSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bsSizes.m_uiLANSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), bsSizes.m_bOnlyDefault); - - // Task priority - SetTaskPropValue(tTaskDefinition.GetConfiguration(), iPriority); - // load resource strings SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), ffFilters); - // create task with the above definition CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); @@ -609,66 +529,21 @@ chcore::TConfig& rConfig = GetConfig(); CCustomCopyDlg dlg; - dlg.m_ccData.m_iOperation=0; - dlg.m_ccData.m_iPriority = boost::numeric_cast(GetPropValue(rConfig)); - dlg.m_ccData.m_bsSizes.m_bOnlyDefault=GetPropValue(rConfig); - dlg.m_ccData.m_bsSizes.m_uiDefaultSize=GetPropValue(rConfig); - dlg.m_ccData.m_bsSizes.m_uiOneDiskSize=GetPropValue(rConfig); - dlg.m_ccData.m_bsSizes.m_uiTwoDisksSize=GetPropValue(rConfig); - dlg.m_ccData.m_bsSizes.m_uiCDSize=GetPropValue(rConfig); - dlg.m_ccData.m_bsSizes.m_uiLANSize=GetPropValue(rConfig); - dlg.m_ccData.m_bCreateStructure=false; - dlg.m_ccData.m_bForceDirectories=false; - dlg.m_ccData.m_bIgnoreFolders=false; + GetPropValue(rConfig, dlg.m_vRecent); - dlg.m_ccData.m_vRecent.clear(); - - GetPropValue(rConfig, dlg.m_ccData.m_vRecent); - - if (dlg.DoModal() == IDOK) + if(dlg.DoModal() == IDOK) { - SetPropValue(rConfig, dlg.m_ccData.m_vRecent); + dlg.m_vRecent.push_back(dlg.m_tTaskDefinition.GetDestinationPath().ToString()); - // save recent paths - dlg.m_ccData.m_vRecent.push_back((PCTSTR)dlg.m_ccData.m_strDestPath); + SetPropValue(rConfig, dlg.m_vRecent); - chcore::TTaskDefinition tTaskDefinition; + chcore::TTaskDefinition tTaskDefinition = dlg.m_tTaskDefinition; - for (int iIndex = 0; iIndex < dlg.m_ccData.m_astrPaths.GetSize(); iIndex++) - { - tTaskDefinition.AddSourcePath(chcore::PathFromString(dlg.m_ccData.m_astrPaths.GetAt(iIndex))); - } - - tTaskDefinition.SetDestinationPath(chcore::PathFromString(dlg.m_ccData.m_strDestPath)); - - tTaskDefinition.SetOperationType((dlg.m_ccData.m_iOperation == 1) ? chcore::eOperation_Move : chcore::eOperation_Copy); - - // set the default options for task - GetConfig().ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); - - // and override them with manual settings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bCreateStructure); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bForceDirectories); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bIgnoreFolders); - - // Buffer settings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bsSizes.m_uiDefaultSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bsSizes.m_uiOneDiskSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bsSizes.m_uiTwoDisksSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bsSizes.m_uiCDSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bsSizes.m_uiLANSize); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_bsSizes.m_bOnlyDefault); - - // Task priority - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_iPriority); - // load resource strings SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), dlg.m_ccData.m_afFilters); - // new task CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); @@ -737,14 +612,17 @@ | (GetPropValue(rConfig) ? CSharedConfigStruct::DD_COPYMOVESPECIAL_FLAG : 0); pCommand[0].uiCommandID=CSharedConfigStruct::DD_COPY_FLAG; + pCommand[0].eOperationType = chcore::eOperation_Copy; GetResManager().LoadStringCopy(IDS_MENUCOPY_STRING, pCommand[0].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPCOPY_STRING, pCommand[0].szDesc, 128); pCommand[1].uiCommandID=CSharedConfigStruct::DD_MOVE_FLAG; + pCommand[1].eOperationType = chcore::eOperation_Move; GetResManager().LoadStringCopy(IDS_MENUMOVE_STRING, pCommand[1].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPMOVE_STRING, pCommand[1].szDesc, 128); pCommand[2].uiCommandID=CSharedConfigStruct::DD_COPYMOVESPECIAL_FLAG; + pCommand[2].eOperationType = chcore::eOperation_Copy; GetResManager().LoadStringCopy(IDS_MENUCOPYMOVESPECIAL_STRING, pCommand[2].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPCOPYMOVESPECIAL_STRING, pCommand[2].szDesc, 128); } @@ -759,18 +637,23 @@ | (GetPropValue(rConfig) ? CSharedConfigStruct::EC_COPYMOVETOSPECIAL_FLAG : 0); pCommand[0].uiCommandID=CSharedConfigStruct::EC_PASTE_FLAG; + pCommand[0].eOperationType = chcore::eOperation_Copy; GetResManager().LoadStringCopy(IDS_MENUPASTE_STRING, pCommand[0].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPPASTE_STRING, pCommand[0].szDesc, 128); pCommand[1].uiCommandID=CSharedConfigStruct::EC_PASTESPECIAL_FLAG; + pCommand[1].eOperationType = chcore::eOperation_Copy; GetResManager().LoadStringCopy(IDS_MENUPASTESPECIAL_STRING, pCommand[1].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPPASTESPECIAL_STRING, pCommand[1].szDesc, 128); pCommand[2].uiCommandID=CSharedConfigStruct::EC_COPYTO_FLAG; + pCommand[2].eOperationType = chcore::eOperation_Copy; GetResManager().LoadStringCopy(IDS_MENUCOPYTO_STRING, pCommand[2].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPCOPYTO_STRING, pCommand[2].szDesc, 128); pCommand[3].uiCommandID=CSharedConfigStruct::EC_MOVETO_FLAG; + pCommand[3].eOperationType = chcore::eOperation_Move; GetResManager().LoadStringCopy(IDS_MENUMOVETO_STRING, pCommand[3].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPMOVETO_STRING, pCommand[3].szDesc, 128); pCommand[4].uiCommandID=CSharedConfigStruct::EC_COPYMOVETOSPECIAL_FLAG; + pCommand[4].eOperationType = chcore::eOperation_Copy; GetResManager().LoadStringCopy(IDS_MENUCOPYMOVETOSPECIAL_STRING, pCommand[4].szCommand, 128); GetResManager().LoadStringCopy(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING, pCommand[4].szDesc, 128); Index: src/chext/DropMenuExt.cpp =================================================================== diff -u -N -rc435ab507c8b8280264188b49e9ada56d46c0261 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision c435ab507c8b8280264188b49e9ada56d46c0261) +++ src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -19,9 +19,12 @@ #include "stdafx.h" #include "chext.h" #include "DropMenuExt.h" -#include "clipboard.h" #include "chext-utils.h" -#include "..\Common\ipcstructs.h" +#include "../Common/ipcstructs.h" +#include "../libchcore/TTaskDefinition.h" +#include +#include "ShellPathsHelpers.h" +#include "../libchcore/TWStringData.h" ///////////////////////////////////////////////////////////////////////////// // CDropMenuExt @@ -31,7 +34,6 @@ CDropMenuExt::CDropMenuExt() : m_piShellExtControl(NULL) { - m_szDstPath[0] = _T('\0'); CoCreateInstance(CLSID_CShellExtControl, NULL, CLSCTX_ALL, IID_IShellExtControl, (void**)&m_piShellExtControl); } @@ -44,32 +46,19 @@ } } -HRESULT CDropMenuExt::ReadFileData(IDataObject* piDataObject) +STDMETHODIMP CDropMenuExt::Initialize(LPCITEMIDLIST pidlFolder, IDataObject* piDataObject, HKEY /*hkeyProgID*/) { - _ASSERTE(piDataObject); - if(!piDataObject) - return E_INVALIDARG; + if(!pidlFolder && !piDataObject) + return E_FAIL; - // retrieve some informations from the data object - STGMEDIUM medium; - FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + if(!pidlFolder || !piDataObject) + _ASSERTE(!_T("Missing at least one parameter - it's unexpected.")); - // retrieve the CF_HDROP-type data from data object - HRESULT hResult = piDataObject->QueryGetData(&fe); - if(hResult != S_OK) - return hResult; - hResult = piDataObject->GetData(&fe, &medium); - if(SUCCEEDED(hResult)) - GetDataFromClipboard(static_cast(medium.hGlobal), m_szDstPath, &m_bBuffer.m_pszFiles, &m_bBuffer.m_iDataSize); - - ReleaseStgMedium(&medium); - - return hResult; -} - -STDMETHODIMP CDropMenuExt::Initialize(LPCITEMIDLIST pidlFolder, IDataObject* piDataObject, HKEY /*hkeyProgID*/) -{ - ATLTRACE(_T("CDropMenuExt::Initialize()\n")); + // When called: + // 1. R-click on a directory + // 2. R-click on a directory background + // 3. Pressed Ctrl+C, Ctrl+X on a specified file/directory + ATLTRACE(_T("[CDropMenuExt::Initialize] CDropMenuExt::Initialize()\n")); if(!piDataObject) return E_FAIL; @@ -90,19 +79,65 @@ // retrieve config from CH ::SendMessage(hWnd, WM_GETCONFIG, GC_DRAGDROP, 0); - // get dest folder - m_szDstPath[0]=_T('\0'); - if(!SHGetPathFromIDList(pidlFolder, m_szDstPath)) - return E_FAIL; + m_vPaths.Clear(); + m_pathPidl.Clear(); + // get dest folder + if(pidlFolder) + hResult = ShellPathsHelpers::GetPathFromITEMIDLIST(pidlFolder, m_pathPidl); // now retrieve the preferred drop effect from IDataObject - hResult = m_asSelector.ReadStateFromDataObject(piDataObject, m_szDstPath); if(SUCCEEDED(hResult)) - hResult = ReadFileData(piDataObject); + hResult = m_asSelector.ReadStateFromDataObject(piDataObject, m_pathPidl.ToString()); + if(SUCCEEDED(hResult)) + hResult = ShellPathsHelpers::GetPathsFromIDataObject(piDataObject, m_vPaths); + + ATLTRACE(_T("[CDropMenuExt::Initialize] Exit hResult == 0x%lx\n"), hResult); + return hResult; } +STDMETHODIMP CDropMenuExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) +{ + ATLTRACE(_T("CDropMenuExt::InvokeCommand()\n")); + HRESULT hResult = IsShellExtEnabled(m_piShellExtControl); + if(FAILED(hResult) || hResult == S_FALSE) + return E_FAIL; // required to process other InvokeCommand handlers. + + // find window + HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if(hWnd == NULL) + return E_FAIL; + + // commands + _COMMAND* pCommand = g_pscsShared->GetCommandsPtr(); + if(!pCommand) + return E_FAIL; + + // set the operation type + chcore::TTaskDefinition tTaskDefinition; + tTaskDefinition.SetSourcePaths(m_vPaths); + tTaskDefinition.SetDestinationPath(m_pathPidl); + tTaskDefinition.SetOperationType(pCommand[LOWORD(lpici->lpVerb)].eOperationType); + + // get the gathered data as XML + chcore::TWStringData wstrXML; + tTaskDefinition.StoreInString(wstrXML); + +// ::MessageBox(NULL, wstrXML.GetData(), _T("DropMenuExt.cpp / Copy/Move to [special]"), MB_OK); // TEMP - to be removed before commit + + // IPC struct + COPYDATASTRUCT cds; + cds.dwData = pCommand[LOWORD(lpici->lpVerb)].uiCommandID; // based on command's number (0-copy, 1-move, 2-special (copy), 3-special (move)) + cds.cbData = (DWORD)wstrXML.GetBytesCount(); + cds.lpData = (void*)wstrXML.GetData(); + + // send a message to ch + ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); + + return S_OK; +} + STDMETHODIMP CDropMenuExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) { ATLTRACE(_T("CDropMenuExt::QueryContextMenu()\n")); @@ -240,35 +275,6 @@ return S_OK; } -STDMETHODIMP CDropMenuExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) -{ - ATLTRACE(_T("CDropMenuExt::InvokeCommand()\n")); - HRESULT hResult = IsShellExtEnabled(m_piShellExtControl); - if(FAILED(hResult) || hResult == S_FALSE) - return E_FAIL; // required to process other InvokeCommand handlers. - - // find window - HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if(hWnd == NULL) - return E_FAIL; - - // commands - _COMMAND* pCommand = g_pscsShared->GetCommandsPtr(); - - // IPC struct - COPYDATASTRUCT cds; - cds.dwData=pCommand[LOWORD(lpici->lpVerb)].uiCommandID; // based on command's number (0-copy, 1-move, 2-special (copy), 3-special (move)) - cds.cbData=m_bBuffer.m_iDataSize * sizeof(TCHAR); - cds.lpData=m_bBuffer.m_pszFiles; - - // send a message to ch - ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); - - m_bBuffer.Destroy(); - - return S_OK; -} - STDMETHODIMP CDropMenuExt::HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) { return HandleMenuMsg2(uMsg, wParam, lParam, NULL); Index: src/chext/DropMenuExt.h =================================================================== diff -u -N -r0373359eff650e8cf04a5992711ef9f20347536f -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/chext/DropMenuExt.h (.../DropMenuExt.h) (revision 0373359eff650e8cf04a5992711ef9f20347536f) +++ src/chext/DropMenuExt.h (.../DropMenuExt.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -22,6 +22,8 @@ #include "resource.h" // main symbols #include "ActionSelector.h" +#include "../libchcore/TTaskDefinition.h" + ///////////////////////////////////////////////////////////////////////////// // CDropMenuExt class ATL_NO_VTABLE CDropMenuExt : @@ -54,25 +56,11 @@ STDMETHOD(HandleMenuMsg2)(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plResult); protected: - HRESULT ReadFileData(IDataObject* piDataObject); - -protected: - TCHAR m_szDstPath[_MAX_PATH]; - IShellExtControl* m_piShellExtControl; TActionSelector m_asSelector; - class CBuffer - { - public: - CBuffer() { m_pszFiles=NULL; m_iDataSize=0; }; - void Destroy() { delete [] m_pszFiles; m_pszFiles=NULL; m_iDataSize=0; }; - ~CBuffer() { Destroy(); }; - - public: - TCHAR *m_pszFiles; - UINT m_iDataSize; - } m_bBuffer; + chcore::TPathContainer m_vPaths; + chcore::TSmartPath m_pathPidl; }; #endif //__DROPMENUEXT_H_ Index: src/chext/MenuExt.cpp =================================================================== diff -u -N -r68739164e349c34dcd0bcb36c6eb381f23cb8b77 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/chext/MenuExt.cpp (.../MenuExt.cpp) (revision 68739164e349c34dcd0bcb36c6eb381f23cb8b77) +++ src/chext/MenuExt.cpp (.../MenuExt.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -1,5 +1,5 @@ /*************************************************************************** -* Copyright (C) 2001-2008 by J�zef Starosczyk * +* Copyright (C) 2001-2011 by J�zef Starosczyk * * ixen@copyhandler.com * * * * This program is free software; you can redistribute it and/or modify * @@ -19,13 +19,15 @@ #include "stdafx.h" #include "chext.h" #include "MenuExt.h" -#include "clipboard.h" #include "..\common\ipcstructs.h" #include "..\common\FileSupport.h" #include "stdio.h" #include "memory.h" #include "StringHelpers.h" #include "chext-utils.h" +#include +#include "ShellPathsHelpers.h" +#include "../libchcore/TWStringData.h" extern CSharedConfigStruct* g_pscsShared; @@ -62,146 +64,136 @@ } } -STDMETHODIMP CMenuExt::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/) +STDMETHODIMP CMenuExt::Initialize(LPCITEMIDLIST pidlFolder, IDataObject* piDataObject, HKEY /*hkeyProgID*/) { - ATLTRACE(_T("CMenuExt::Initialize()\n")); + ATLTRACE(_T("[CMenuExt::Initialize] CMenuExt::Initialize(pidlFolder = 0x%p, piDataObject=0x%p)\n"), pidlFolder, piDataObject); + + if(!pidlFolder && !piDataObject) + return E_INVALIDARG; + // check options HRESULT hResult = IsShellExtEnabled(m_piShellExtControl); if(FAILED(hResult) || hResult == S_FALSE) return hResult; // find ch window - HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (hWnd == NULL) + HWND hWnd = ::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if(hWnd == NULL) return E_FAIL; // get cfg from ch ::SendMessage(hWnd, WM_GETCONFIG, GC_EXPLORER, 0); - // read dest folder - m_szDstPath[0]=_T('\0'); + // background or folder ? + m_bBackground = (piDataObject == NULL) && (pidlFolder != NULL); // get data from IDataObject - files to copy/move - bool bPathFound=false; - m_bGroupFiles=false; - if (lpdobj) - { - STGMEDIUM medium; - FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + m_bShowPasteOption = true; - HRESULT hr = lpdobj->GetData(&fe, &medium); - if (FAILED(hr)) - return E_FAIL; + m_vPaths.Clear(); - // copy all filenames to a table - GetDataFromClipboard(static_cast(medium.hGlobal), NULL, &m_bBuffer.m_pszFiles, &m_bBuffer.m_iDataSize); - - // find the first non-empty entry - UINT fileCount = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF, NULL, 0); - TCHAR szPath[_MAX_PATH]; - UINT uiRes; - for (UINT i=0;iGetCommandsPtr(); - // OTF("Invoke Command\r\n"); // command type - switch (LOWORD(lpici->lpVerb)) + switch(LOWORD(lpici->lpVerb)) { // paste & paste special case 0: case 1: { - // search for data in a clipboard - if (IsClipboardFormatAvailable(CF_HDROP)) + // paste and paste special requires a single directory path inside m_vPaths + if((m_vPaths.GetCount() != 1) || !(::GetFileAttributes(m_vPaths.GetAt(0).ToString()) & FILE_ATTRIBUTE_DIRECTORY)) + return E_FAIL; + + // search for source paths in the clipboard + if(IsClipboardFormatAvailable(CF_HDROP)) { - bool bMove=false; // 0-copy, 1-move + bool bMove = false; // 0-copy, 1-move - // get data + // read paths from clipboard OpenClipboard(lpici->hwnd); - HANDLE handle=GetClipboardData(CF_HDROP); - TCHAR *pchBuffer=NULL; - UINT uiSize; + HANDLE hClipboardData = GetClipboardData(CF_HDROP); - GetDataFromClipboard(static_cast(handle), m_szDstPath, &pchBuffer, &uiSize); + chcore::TPathContainer vPaths; + ShellPathsHelpers::GetPathsFromHDROP(static_cast(hClipboardData), vPaths); - // register clipboard format nad if exists in it - UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect")); - if (IsClipboardFormatAvailable(nFormat)) + // check if there is also a hint about operation type + UINT nFormat = RegisterClipboardFormat(_T("Preferred DropEffect")); + if(IsClipboardFormatAvailable(nFormat)) { - handle=GetClipboardData(nFormat); - LPVOID addr=GlobalLock(handle); - if(!addr) + hClipboardData = GetClipboardData(nFormat); + if(!hClipboardData) return E_FAIL; - DWORD dwData=((DWORD*)addr)[0]; - if (dwData & DROPEFFECT_MOVE) - bMove=true; - GlobalUnlock(handle); + LPVOID pClipboardData = GlobalLock(hClipboardData); + if(!pClipboardData) + return E_FAIL; + + DWORD dwData = ((DWORD*)pClipboardData)[0]; + if(dwData & DROPEFFECT_MOVE) + bMove = true; + + GlobalUnlock(hClipboardData); } CloseClipboard(); + chcore::TTaskDefinition tTaskDefinition; + tTaskDefinition.SetSourcePaths(vPaths); + tTaskDefinition.SetDestinationPath(m_vPaths.GetAt(0)); + tTaskDefinition.SetOperationType(bMove ? chcore::eOperation_Move : chcore::eOperation_Copy); + + // get task data as xml + chcore::TWStringData wstrData; + tTaskDefinition.StoreInString(wstrData); + + //::MessageBox(NULL, wstrData.GetData(), _T("MenuExt.cpp / Paste [special]"), MB_OK); // TEMP - to be removed before commit + // fill struct COPYDATASTRUCT cds; - cds.dwData=(((DWORD)bMove) << 31) | pCommand[LOWORD(lpici->lpVerb)].uiCommandID; - cds.lpData=pchBuffer; - cds.cbData=uiSize * sizeof(TCHAR); + cds.dwData = pCommand[LOWORD(lpici->lpVerb)].uiCommandID; + cds.lpData = (void*)wstrData.GetData(); + cds.cbData = (DWORD)wstrData.GetBytesCount(); // send a message ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); - - // delete buffer - delete [] pchBuffer; } } break; @@ -212,35 +204,35 @@ default: { // out of range - may be a shortcut - if (LOWORD(lpici->lpVerb) < g_pscsShared->iCommandCount+(m_bBackground ? 0 : 3*g_pscsShared->iShortcutsCount)) + if(LOWORD(lpici->lpVerb) < g_pscsShared->iCommandCount + (m_bBackground ? 0 : 3 * g_pscsShared->iShortcutsCount)) { - // addr of a table with shortcuts + // pClipboardData of a table with shortcuts _SHORTCUT* stShortcuts = g_pscsShared->GetShortcutsPtr(); // find command for which this command is generated - int iCommandIndex=(int)(((LOWORD(lpici->lpVerb)-5) / g_pscsShared->iShortcutsCount))+2; // command index - int iShortcutIndex=((LOWORD(lpici->lpVerb)-5) % g_pscsShared->iShortcutsCount); // shortcut index + int iCommandIndex = (int)(((LOWORD(lpici->lpVerb)-5) / g_pscsShared->iShortcutsCount))+2; // command index + int iShortcutIndex = ((LOWORD(lpici->lpVerb)-5) % g_pscsShared->iShortcutsCount); // shortcut index - // buffer for data - size_t stSize=_tcslen(stShortcuts[iShortcutIndex].szPath)+1+m_bBuffer.m_iDataSize; - TCHAR *pszBuffer=new TCHAR[stSize]; - _tcscpy(pszBuffer, stShortcuts[iShortcutIndex].szPath); // �cie�ka docelowa + chcore::TTaskDefinition tTaskDefinition; - // buffer with files - memcpy(pszBuffer+_tcslen(stShortcuts[iShortcutIndex].szPath)+1, m_bBuffer.m_pszFiles, m_bBuffer.m_iDataSize*sizeof(TCHAR)); + tTaskDefinition.SetSourcePaths(m_vPaths); + tTaskDefinition.SetDestinationPath(chcore::PathFromString(stShortcuts[iShortcutIndex].szPath)); + tTaskDefinition.SetOperationType(pCommand[iCommandIndex].eOperationType); + // get task data as xml + chcore::TWStringData wstrData; + tTaskDefinition.StoreInString(wstrData); + +// ::MessageBox(NULL, wstrData.GetData(), _T("MenuExt.cpp / Copy/Move to [special]"), MB_OK); // TEMP - to be removed before commit + // fill struct COPYDATASTRUCT cds; - cds.dwData=pCommand[iCommandIndex].uiCommandID; - cds.lpData=pszBuffer; - cds.cbData=(DWORD)(stSize * sizeof(TCHAR)); + cds.dwData = pCommand[iCommandIndex].uiCommandID; + cds.lpData = (void*)wstrData.GetData(); + cds.cbData = (DWORD)wstrData.GetBytesCount(); // send message ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); - - // delete buffer - delete [] pszBuffer; - m_bBuffer.Destroy(); } else return E_FAIL; @@ -314,7 +306,7 @@ // data about commands int iCommandCount=0; - if (!m_bGroupFiles) + if(m_bShowPasteOption) { // paste if (g_pscsShared->uiFlags & CSharedConfigStruct::EC_PASTE_FLAG) Index: src/chext/MenuExt.h =================================================================== diff -u -N -r0373359eff650e8cf04a5992711ef9f20347536f -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/chext/MenuExt.h (.../MenuExt.h) (revision 0373359eff650e8cf04a5992711ef9f20347536f) +++ src/chext/MenuExt.h (.../MenuExt.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -20,6 +20,7 @@ #define __MENUEXT_H_ #include "resource.h" // main symbols +#include "../libchcore/TTaskDefinition.h" /////// // globals @@ -51,7 +52,7 @@ // IMenuExt public: - STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/); + STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, IDataObject* piDataObject, HKEY /*hkeyProgID*/); STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici); STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax); STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/); @@ -63,21 +64,8 @@ void CreateShortcutsMenu(UINT uiIDBase, bool bOwnerDrawn); protected: - // class for making sure memory is freed - class CBuffer - { - public: - CBuffer() { m_pszFiles=NULL; m_iDataSize=0; }; - void Destroy() { delete [] m_pszFiles; m_pszFiles=NULL; m_iDataSize=0; }; - ~CBuffer() { Destroy(); }; + chcore::TPathContainer m_vPaths; - public: - TCHAR *m_pszFiles; - UINT m_iDataSize; - } m_bBuffer; - - TCHAR m_szDstPath[_MAX_PATH]; - // for making sure DestroyMenu would be called class CSubMenus { @@ -90,8 +78,8 @@ HMENU hShortcuts[3]; } m_mMenus; - bool m_bBackground; // folder or folder background - bool m_bGroupFiles; // if the group of files have a files in it + bool m_bBackground; // folder or folder background + bool m_bShowPasteOption; // if the group of files have a files in it UINT m_uiFirstID; // first menu ID bool m_bShown; // have the menu been already shown ? Index: src/chext/ShellPathsHelpers.cpp =================================================================== diff -u -N --- src/chext/ShellPathsHelpers.cpp (revision 0) +++ src/chext/ShellPathsHelpers.cpp (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -0,0 +1,94 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file ShellPathsHelpers.cpp +/// @date 2011/04/10 +/// @brief Contains implementation of functions handling shell paths conversions. +// ============================================================================ +#include "stdafx.h" +#include "ShellPathsHelpers.h" +#include +#include "../libchcore/TPath.h" + +namespace ShellPathsHelpers { + +HRESULT GetPathFromITEMIDLIST(LPCITEMIDLIST pidlFolder, chcore::TSmartPath& pathFolder) +{ + if(!pidlFolder) + return E_INVALIDARG; + + size_t stMaxPathSize = 32768; + boost::shared_array szDstPathBuffer(new wchar_t[stMaxPathSize]); + szDstPathBuffer.get()[0] = _T('\0'); + + if(!SHGetPathFromIDList(pidlFolder, szDstPathBuffer.get())) + return E_FAIL; + + pathFolder = chcore::PathFromString(szDstPathBuffer.get()); + + return S_OK; +} + +void GetPathsFromHDROP(HDROP hDrop, chcore::TPathContainer& tPathContainer) +{ + tPathContainer.Clear(); + + // get clipboard data + UINT uiFilesCount = DragQueryFile(hDrop, 0xffffffff, NULL, 0); + + const size_t stMaxPathLength = 32768; + TCHAR szPath[stMaxPathLength]; + + // get files and put it in a table + UINT uiSize; + for(UINT uiIndex = 0; uiIndex < uiFilesCount; ++uiIndex) + { + uiSize = DragQueryFile(hDrop, uiIndex, szPath, stMaxPathLength); + szPath[uiSize] = _T('\0'); + + tPathContainer.Add(chcore::PathFromString(szPath)); + } +} + +HRESULT GetPathsFromIDataObject(IDataObject* piDataObject, chcore::TPathContainer& tPathContainer) +{ + tPathContainer.Clear(); + + _ASSERTE(piDataObject); + if(!piDataObject) + return E_INVALIDARG; + + // retrieve some informations from the data object + STGMEDIUM medium; + FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + + // retrieve the CF_HDROP-type data from data object + HRESULT hResult = piDataObject->QueryGetData(&fe); + if(hResult != S_OK) + return S_FALSE; + + hResult = piDataObject->GetData(&fe, &medium); + if(SUCCEEDED(hResult)) + GetPathsFromHDROP(static_cast(medium.hGlobal), tPathContainer); + + ReleaseStgMedium(&medium); + + return S_OK; +} + +} Index: src/chext/ShellPathsHelpers.h =================================================================== diff -u -N --- src/chext/ShellPathsHelpers.h (revision 0) +++ src/chext/ShellPathsHelpers.h (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -0,0 +1,36 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file ShellPathsHelpers.h +/// @date 2011/04/10 +/// @brief Contains helper functions for handling shell paths. +// ============================================================================ +#ifndef __SHELLPATHSHELPERS_H__ +#define __SHELLPATHSHELPERS_H__ + +namespace chcore { class TSmartPath; class TPathContainer; } + +namespace ShellPathsHelpers +{ + HRESULT GetPathFromITEMIDLIST(LPCITEMIDLIST pidlFolder, chcore::TSmartPath& pathFolder); + void GetPathsFromHDROP(HDROP hDrop, chcore::TPathContainer& tPathContainer); + HRESULT GetPathsFromIDataObject(IDataObject* piDataObject, chcore::TPathContainer& tPathContainer); + +} + +#endif Index: src/chext/StdAfx.h =================================================================== diff -u -N -rcd5a36f1507a4131ce652879565c0770b36dd953 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/chext/StdAfx.h (.../StdAfx.h) (revision cd5a36f1507a4131ce652879565c0770b36dd953) +++ src/chext/StdAfx.h (.../StdAfx.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -35,6 +35,9 @@ #include #include +#include +#include +#include #include "../libicpf/gen_types.h" #endif Index: src/chext/chext.vc90.vcproj =================================================================== diff -u -N -r541933027e84c7a2acf505547170f5da4d87aa82 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/chext/chext.vc90.vcproj (.../chext.vc90.vcproj) (revision 541933027e84c7a2acf505547170f5da4d87aa82) +++ src/chext/chext.vc90.vcproj (.../chext.vc90.vcproj) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -403,11 +403,11 @@ > #include #include "../libicpf/exception.h" +#include "TWStringData.h" #pragma warning(push) #pragma warning(disable: 4702 4512) @@ -182,6 +183,38 @@ } } +void TConfig::ReadFromString(const TWStringData& strInput) +{ + if(strInput.IsEmpty()) + THROW(_T("Invalid argument"), 0, 0, 0); + + boost::unique_lock lock(m_lock); + + ClearNL(); // also clears m_bModified + + std::wistringstream ifs(strInput.GetData(), std::ios_base::in); + try + { + boost::property_tree::xml_parser::read_xml(ifs, m_propTree); + } + catch(...) + { + m_propTree.clear(); + throw; + } +} + +void TConfig::WriteToString(TWStringData& strOutput) +{ + boost::shared_lock lock(m_lock); + + std::wostringstream ofs(std::ios_base::out); + + boost::property_tree::xml_parser::write_xml(ofs, m_propTree); + + strOutput = ofs.str(); +} + void TConfig::SetFilePath(PCTSTR pszPath) { boost::unique_lock lock(m_lock); Index: src/libchcore/TConfig.h =================================================================== diff -u -N -re30c2b40bd1b533d8740edc88d80b2fb340f3466 -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/libchcore/TConfig.h (.../TConfig.h) (revision e30c2b40bd1b533d8740edc88d80b2fb340f3466) +++ src/libchcore/TConfig.h (.../TConfig.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -31,6 +31,8 @@ BEGIN_CHCORE_NAMESPACE +class TWStringData; + // class defines configuration change notification record; not to be used outside class TConfigNotifier { @@ -65,6 +67,9 @@ void Read(PCTSTR pszFile); void Write(bool bOnlyIfModified = false); + void ReadFromString(const TWStringData& strInput); + void WriteToString(TWStringData& strOutput); + void SetFilePath(PCTSTR pszPath); // Modifications management Index: src/libchcore/TPath.h =================================================================== diff -u -N -r886c32a98f09ae8dc24ceb6b27e5c8a75104954e -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/libchcore/TPath.h (.../TPath.h) (revision 886c32a98f09ae8dc24ceb6b27e5c8a75104954e) +++ src/libchcore/TPath.h (.../TPath.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -42,7 +42,10 @@ static void Delete(TPath* pPath); protected: +#pragma warning(push) +#pragma warning(disable: 4251) std::wstring m_strPath; +#pragma warning(pop) long m_lRefCount; friend class TSmartPath; Index: src/libchcore/TTaskDefinition.cpp =================================================================== diff -u -N -r6dc950d4d76107421ff6eb62069b70f20bcc450e -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/libchcore/TTaskDefinition.cpp (.../TTaskDefinition.cpp) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) +++ src/libchcore/TTaskDefinition.cpp (.../TTaskDefinition.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -103,6 +103,11 @@ m_bModified = true; } +void TTaskDefinition::SetSourcePaths(const chcore::TPathContainer& rvPaths) +{ + m_vSourcePaths = rvPaths; +} + const chcore::TPathContainer& TTaskDefinition::GetSourcePaths() const { return m_vSourcePaths; @@ -139,7 +144,7 @@ } // Task configuration -void TTaskDefinition::SetConfig(const chcore::TConfig& rConfig) +void TTaskDefinition::SetConfiguration(const chcore::TConfig& rConfig) { m_tConfiguration = rConfig; m_bModified = true; @@ -248,4 +253,90 @@ } } +void TTaskDefinition::StoreInString(TWStringData& strOutput) +{ + // read everything + chcore::TConfig tTaskInfo; + + // get information from config file + // task unique id - use if provided, generate otherwise + SetConfigValue(tTaskInfo, _T("TaskDefinition.UniqueID"), m_strTaskUniqueID); + + // basic information + SetConfigValue(tTaskInfo, _T("TaskDefinition.SourcePaths.Path"), m_vSourcePaths); + SetConfigValue(tTaskInfo, _T("TaskDefinition.DestinationPath"), m_pathDestinationPath); + + int iOperation = m_tOperationPlan.GetOperationType(); + SetConfigValue(tTaskInfo, _T("TaskDefinition.OperationType"), iOperation); + + SetConfigValue(tTaskInfo, _T("TaskDefinition.Version"), m_ullTaskVersion); + + tTaskInfo.PutSubConfig(_T("TaskDefinition.TaskSettings"), m_tConfiguration); + + tTaskInfo.WriteToString(strOutput); +} + +void TTaskDefinition::LoadFromString(const TWStringData& strInput) +{ + // read everything + chcore::TConfig tTaskInfo; + tTaskInfo.ReadFromString(strInput); + + // clear everything + m_strTaskUniqueID.clear(); + m_vSourcePaths.Clear(); + m_pathDestinationPath.Clear(); + + m_tConfiguration.Clear(); + + m_bModified = false; + + // get information from config file + // task unique id - use if provided, generate otherwise + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.UniqueID"), m_strTaskUniqueID) || m_strTaskUniqueID.empty()) + { + boost::uuids::random_generator gen; + boost::uuids::uuid u = gen(); + m_strTaskUniqueID = boost::lexical_cast(u).c_str(); + + m_bModified = true; + } + + // basic information + // source paths to be processed + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.SourcePaths"), m_vSourcePaths) || m_vSourcePaths.IsEmpty()) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing source paths")); + + // destination path + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.DestinationPath"), m_pathDestinationPath) || m_pathDestinationPath.IsEmpty()) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing destination path")); + + m_pathDestinationPath.AppendSeparatorIfDoesNotExist(); + + // type of the operation + int iOperation = eOperation_None; + if(!tTaskInfo.GetValue(_T("TaskDefinition.OperationType"), iOperation)) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing operation type")); + + m_tOperationPlan.SetOperationType((EOperationType)iOperation); + + // and version of the task + if(!GetConfigValue(tTaskInfo, _T("TaskDefinition.Version"), m_ullTaskVersion)) + THROW_CORE_EXCEPTION_STR(eMissingData, _T("Missing task definition version")); + + if(m_ullTaskVersion < CURRENT_TASK_VERSION) + { + // migrate the task to the newer version + // (nothing to migrate at this point, since 1.40 is the first release with xml-based tasks). + + // then mark it as a newest version task + m_ullTaskVersion = CURRENT_TASK_VERSION; + m_bModified = true; + } + else if(m_ullTaskVersion > CURRENT_TASK_VERSION) + THROW_CORE_EXCEPTION_STR(eUnsupportedVersion, _T("Unsupported task version")); + + tTaskInfo.ExtractSubConfig(_T("TaskDefinition.TaskSettings"), m_tConfiguration); +} + END_CHCORE_NAMESPACE Index: src/libchcore/TTaskDefinition.h =================================================================== diff -u -N -r6dc950d4d76107421ff6eb62069b70f20bcc450e -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/libchcore/TTaskDefinition.h (.../TTaskDefinition.h) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) +++ src/libchcore/TTaskDefinition.h (.../TTaskDefinition.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -48,6 +48,7 @@ void AddSourcePath(const chcore::TSmartPath& tPath); chcore::TSmartPath GetSourcePathAt(size_t stIndex) const; size_t GetSourcePathCount() const; + void SetSourcePaths(const chcore::TPathContainer& rvPaths); const chcore::TPathContainer& GetSourcePaths() const; void ClearSourcePaths(); @@ -62,16 +63,22 @@ const TOperationPlan& GetOperationPlan() const; // Task configuration - void SetConfig(const chcore::TConfig& rConfig); + void SetConfiguration(const chcore::TConfig& rConfig); chcore::TConfig& GetConfiguration(); const chcore::TConfig& GetConfiguration() const; // Serialization void Load(const std::wstring& strPath); void Store(const std::wstring& strPath, bool bOnlyIfModified = false); + void StoreInString(TWStringData& strInput); + void LoadFromString(const TWStringData& strInput); + private: +#pragma warning(push) +#pragma warning(disable: 4251) std::wstring m_strTaskUniqueID; ///< Unique ID of the task that will process this request (generated automatically) +#pragma warning(pop) // basic information chcore::TPathContainer m_vSourcePaths; Index: src/libchcore/TTaskOperationPlan.h =================================================================== diff -u -N -r6dc950d4d76107421ff6eb62069b70f20bcc450e -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/libchcore/TTaskOperationPlan.h (.../TTaskOperationPlan.h) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) +++ src/libchcore/TTaskOperationPlan.h (.../TTaskOperationPlan.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -23,6 +23,7 @@ #ifndef __TTASKOPERATIONPLAN_H__ #define __TTASKOPERATIONPLAN_H__ +#include "libchcore.h" #include BEGIN_CHCORE_NAMESPACE @@ -98,7 +99,7 @@ template void TOperationPlan::save(Archive& ar, unsigned int /*uiVersion*/) const { - ar << m_eOperation; + ar << GetOperationType(); } END_CHCORE_NAMESPACE Index: src/libchcore/TWStringData.cpp =================================================================== diff -u -N --- src/libchcore/TWStringData.cpp (revision 0) +++ src/libchcore/TWStringData.cpp (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -0,0 +1,92 @@ +// ============================================================================ +// Copyright (C) 2001-2011 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TWString.cpp +/// @date 2011/04/10 +/// @brief Implementation of the basic wrapper over wstring. +// ============================================================================ +#include "stdafx.h" +#include "TWStringData.h" + +BEGIN_CHCORE_NAMESPACE + +TWStringData::TWStringData() +{ + +} + +TWStringData::TWStringData(const TWStringData& rSrc) : + m_wstrData(rSrc.m_wstrData) +{ +} + +TWStringData::TWStringData(const wchar_t* pszSrc) : + m_wstrData(pszSrc) +{ +} + +TWStringData::TWStringData(const std::wstring& strSrc) : + m_wstrData(strSrc.c_str()) +{ +} + +TWStringData::~TWStringData() +{ +} + +TWStringData& TWStringData::operator=(const TWStringData& rSrc) +{ + if(this != &rSrc) + m_wstrData = rSrc.m_wstrData; + + return *this; +} + +TWStringData& TWStringData::operator=(const wchar_t* pszSrc) +{ + m_wstrData = pszSrc; + return *this; +} + +TWStringData& TWStringData::operator=(const std::wstring& strSrc) +{ + m_wstrData = strSrc.c_str(); + return *this; +} + +bool TWStringData::IsEmpty() const +{ + return m_wstrData.empty(); +} + +size_t TWStringData::GetCount() const +{ + return m_wstrData.size(); +} + +size_t TWStringData::GetBytesCount() const +{ + return (m_wstrData.size() + 1) * sizeof(wchar_t); +} + +const wchar_t* TWStringData::GetData() const +{ + return m_wstrData.c_str(); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TWStringData.h =================================================================== diff -u -N --- src/libchcore/TWStringData.h (revision 0) +++ src/libchcore/TWStringData.h (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -0,0 +1,56 @@ +// ============================================================================ +// Copyright (C) 2001-2011 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TWString.h +/// @date 2011/04/10 +/// @brief Basic wrapper over std::wstring. +// ============================================================================ +#ifndef __TWSTRINGDATA_H__ +#define __TWSTRINGDATA_H__ + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TWStringData +{ +public: + TWStringData(); + TWStringData(const TWStringData& rSrc); + TWStringData(const wchar_t* pszSrc); + TWStringData(const std::wstring& strSrc); + + ~TWStringData(); + + TWStringData& operator=(const TWStringData& rSrc); + TWStringData& operator=(const wchar_t* pszSrc); + TWStringData& operator=(const std::wstring& strSrc); + + bool IsEmpty() const; + size_t GetCount() const; + size_t GetBytesCount() const; + const wchar_t* GetData() const; + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + std::wstring m_wstrData; +#pragma warning(pop) +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -r6dc950d4d76107421ff6eb62069b70f20bcc450e -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 6dc950d4d76107421ff6eb62069b70f20bcc450e) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) @@ -487,6 +487,14 @@ RelativePath=".\TTaskOperationPlan.h" > + + + +