Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f -r3d1951f52696fe21e01618e1bbfb9e14745a3827 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 3d1951f52696fe21e01618e1bbfb9e14745a3827) @@ -462,57 +462,64 @@ BOOL CMainWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { - // load task from buffer - wchar_t* pszBuffer = static_cast(pCopyDataStruct->lpData); - unsigned long ulLen = pCopyDataStruct->cbData / sizeof(wchar_t); + if(!pCopyDataStruct) + return CWnd::OnCopyData(pWnd, pCopyDataStruct); - // 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; + switch(pCopyDataStruct->dwData) + { + case eCDType_TaskDefinitionContentSpecial: + case eCDType_TaskDefinitionContent: + { + // load task from buffer + wchar_t* pszBuffer = static_cast(pCopyDataStruct->lpData); + unsigned long ulLen = pCopyDataStruct->cbData / sizeof(wchar_t); - chcore::TWStringData wstrData(pszBuffer); - //AfxMessageBox(wstrData.GetData()); // TEMP = to remove before commit + // 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; - chcore::TTaskDefinition tTaskDefinition; - tTaskDefinition.LoadFromString(wstrData); + chcore::TWStringData wstrData(pszBuffer); + //AfxMessageBox(wstrData.GetData()); // TEMP = to remove before commit - // 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()); + chcore::TTaskDefinition tTaskDefinition; + tTaskDefinition.LoadFromString(wstrData); - // special operation - modify stuff - switch(pCopyDataStruct->dwData & CSharedConfigStruct::OPERATION_MASK) - { - case CSharedConfigStruct::DD_COPYMOVESPECIAL_FLAG: - case CSharedConfigStruct::EC_PASTESPECIAL_FLAG: - case CSharedConfigStruct::EC_COPYMOVETOSPECIAL_FLAG: - CCustomCopyDlg dlg(tTaskDefinition); + // 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()); - GetPropValue(rConfig, dlg.m_vRecent); + // special operation - modify stuff + if(pCopyDataStruct->dwData == eCDType_TaskDefinitionContentSpecial) + { + CCustomCopyDlg dlg(tTaskDefinition); - INT_PTR iModalResult; - if((iModalResult = dlg.DoModal()) == IDCANCEL) - return CWnd::OnCopyData(pWnd, pCopyDataStruct); - else if(iModalResult == -1) // windows has been closed by a parent - return TRUE; + GetPropValue(rConfig, dlg.m_vRecent); - dlg.m_vRecent.push_back(dlg.m_tTaskDefinition.GetDestinationPath().ToString()); + INT_PTR iModalResult; + if((iModalResult = dlg.DoModal()) == IDCANCEL) + return CWnd::OnCopyData(pWnd, pCopyDataStruct); + else if(iModalResult == -1) // windows has been closed by a parent + return TRUE; - SetPropValue(rConfig, dlg.m_vRecent); + dlg.m_vRecent.push_back(dlg.m_tTaskDefinition.GetDestinationPath().ToString()); - tTaskDefinition = dlg.m_tTaskDefinition; - } + SetPropValue(rConfig, dlg.m_vRecent); - // load resource strings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); + tTaskDefinition = dlg.m_tTaskDefinition; + } - // create task with the above definition - CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); + // load resource strings + SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); + SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); - // add to task list and start processing - spTask->BeginProcessing(); + // create task with the above definition + CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); + // add to task list and start processing + spTask->BeginProcessing(); + } + } + return CWnd::OnCopyData(pWnd, pCopyDataStruct); } Index: src/chext/DropMenuExt.cpp =================================================================== diff -u -N -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f -r3d1951f52696fe21e01618e1bbfb9e14745a3827 --- src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) +++ src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision 3d1951f52696fe21e01618e1bbfb9e14745a3827) @@ -128,7 +128,15 @@ // 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)) + switch(pCommand[LOWORD(lpici->lpVerb)].uiCommandID) + { + case CSharedConfigStruct::DD_COPYMOVESPECIAL_FLAG: + cds.dwData = eCDType_TaskDefinitionContentSpecial; + break; + default: + cds.dwData = eCDType_TaskDefinitionContent; + } + cds.cbData = (DWORD)wstrXML.GetBytesCount(); cds.lpData = (void*)wstrXML.GetData(); Index: src/chext/MenuExt.cpp =================================================================== diff -u -N -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f -r3d1951f52696fe21e01618e1bbfb9e14745a3827 --- src/chext/MenuExt.cpp (.../MenuExt.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) +++ src/chext/MenuExt.cpp (.../MenuExt.cpp) (revision 3d1951f52696fe21e01618e1bbfb9e14745a3827) @@ -188,7 +188,15 @@ // fill struct COPYDATASTRUCT cds; - cds.dwData = pCommand[LOWORD(lpici->lpVerb)].uiCommandID; + + switch(pCommand[LOWORD(lpici->lpVerb)].uiCommandID) + { + case CSharedConfigStruct::EC_PASTESPECIAL_FLAG: + cds.dwData = eCDType_TaskDefinitionContentSpecial; + break; + default: + cds.dwData = eCDType_TaskDefinitionContent; + } cds.lpData = (void*)wstrData.GetData(); cds.cbData = (DWORD)wstrData.GetBytesCount(); @@ -227,6 +235,15 @@ // fill struct COPYDATASTRUCT cds; + switch(pCommand[iCommandIndex].uiCommandID) + { + case CSharedConfigStruct::EC_COPYMOVETOSPECIAL_FLAG: + cds.dwData = eCDType_TaskDefinitionContentSpecial; + break; + default: + cds.dwData = eCDType_TaskDefinitionContent; + } + cds.dwData = pCommand[iCommandIndex].uiCommandID; cds.lpData = (void*)wstrData.GetData(); cds.cbData = (DWORD)wstrData.GetBytesCount(); Index: src/common/ipcstructs.h =================================================================== diff -u -N -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f -r3d1951f52696fe21e01618e1bbfb9e14745a3827 --- src/common/ipcstructs.h (.../ipcstructs.h) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) +++ src/common/ipcstructs.h (.../ipcstructs.h) (revision 3d1951f52696fe21e01618e1bbfb9e14745a3827) @@ -47,6 +47,13 @@ }; #pragma pack(pop) +enum ECopyDataType +{ + eCDType_TaskDefinitionContent, + eCDType_TaskDefinitionContentSpecial, + eCDType_CommandLineArguments, +}; + // shared memory size in bytes #define SHARED_BUFFERSIZE 65536