Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r8dc649003961dad64b92da67426814fb5dd862e0 -rc17c4aa7bb4c96219af4191623abe40d18e02713 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 8dc649003961dad64b92da67426814fb5dd862e0) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision c17c4aa7bb4c96219af4191623abe40d18e02713) @@ -667,200 +667,215 @@ case WM_GETCONFIG: { - chcore::TConfig& rConfig = GetConfig(); - ictranslate::CResourceManager& rResManager = GetResManager(); + try + { + chcore::TConfig& rConfig = GetConfig(); + ictranslate::CResourceManager& rResManager = GetResManager(); - TShellExtMenuConfig cfgShellExt; + TShellExtMenuConfig cfgShellExt; - // experimental - doesn't work on all systems - cfgShellExt.SetShowShortcutIcons(GetPropValue(rConfig)); + // experimental - doesn't work on all systems + cfgShellExt.SetShowShortcutIcons(GetPropValue(rConfig)); - cfgShellExt.SetInterceptDragAndDrop(GetPropValue(rConfig)); - cfgShellExt.SetInterceptKeyboardActions(GetPropValue(rConfig)); - cfgShellExt.SetInterceptCtxMenuActions(GetPropValue(rConfig)); + cfgShellExt.SetInterceptDragAndDrop(GetPropValue(rConfig)); + cfgShellExt.SetInterceptKeyboardActions(GetPropValue(rConfig)); + cfgShellExt.SetInterceptCtxMenuActions(GetPropValue(rConfig)); - TShellMenuItemPtr spRootItem = cfgShellExt.GetCommandRoot(); + TShellMenuItemPtr spRootItem = cfgShellExt.GetCommandRoot(); - // what kind of menu ? - switch (wParam) - { - case eLocation_DragAndDropMenu: + // what kind of menu ? + switch(wParam) { - bool bAddedAnyOption = false; - if(GetPropValue(rConfig)) + case eLocation_DragAndDropMenu: { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUCOPY_STRING), rResManager.LoadString(IDS_MENUTIPCOPY_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Copy)); - bAddedAnyOption = true; - } + bool bAddedAnyOption = false; + if(GetPropValue(rConfig)) + { + spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUCOPY_STRING), rResManager.LoadString(IDS_MENUTIPCOPY_STRING), + TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), + TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Copy)); + bAddedAnyOption = true; + } - if(GetPropValue(rConfig)) - { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUMOVE_STRING), rResManager.LoadString(IDS_MENUTIPMOVE_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Move)); - bAddedAnyOption = true; - } + if(GetPropValue(rConfig)) + { + spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUMOVE_STRING), rResManager.LoadString(IDS_MENUTIPMOVE_STRING), + TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), + TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Move)); + bAddedAnyOption = true; + } - if(GetPropValue(rConfig)) - { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVESPECIAL_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), true)); - bAddedAnyOption = true; - } + if(GetPropValue(rConfig)) + { + spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVESPECIAL_STRING), + TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), + TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), true)); + bAddedAnyOption = true; + } - if(bAddedAnyOption) - { - // insert separator as an addition to other items - spRootItem->AddChild(boost::make_shared()); + if(bAddedAnyOption) + { + // insert separator as an addition to other items + spRootItem->AddChild(boost::make_shared()); + } + break; } - } - break; - case eLocation_ContextMenu: - { - if(GetPropValue(rConfig)) - { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUPASTE_STRING), rResManager.LoadString(IDS_MENUTIPPASTE_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), false)); - } - if(GetPropValue(rConfig)) + case eLocation_ContextMenu: { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUPASTESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPPASTESPECIAL_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), true)); - } + if(GetPropValue(rConfig)) + { + spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUPASTE_STRING), rResManager.LoadString(IDS_MENUTIPPASTE_STRING), + TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), + TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), false)); + } - if(GetPropValue(rConfig) || GetPropValue(rConfig) || GetPropValue(rConfig)) - { - // prepare shortcuts for all menu options - std::vector vShortcutStrings; - GetPropValue(rConfig, vShortcutStrings); + if(GetPropValue(rConfig)) + { + spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUPASTESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPPASTESPECIAL_STRING), + TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), + TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), true)); + } - bool bRetrieveFreeSpace = GetPropValue(rConfig); + if(GetPropValue(rConfig) || GetPropValue(rConfig) || GetPropValue(rConfig)) + { + // prepare shortcuts for all menu options + std::vector vShortcutStrings; + GetPropValue(rConfig, vShortcutStrings); - std::vector vShortcuts; + bool bRetrieveFreeSpace = GetPropValue(rConfig); - BOOST_FOREACH(const CString& strShortcutString, vShortcutStrings) - { - CShortcut tShortcut; - if(tShortcut.FromString(strShortcutString)) - { - unsigned long long ullSize = 0; + std::vector vShortcuts; - // retrieving free space might fail, but it's not critical - we just won't show the free space - if(bRetrieveFreeSpace && GetDynamicFreeSpace(tShortcut.m_strPath, &ullSize, NULL)) + BOOST_FOREACH(const CString& strShortcutString, vShortcutStrings) + { + CShortcut tShortcut; + if(tShortcut.FromString(strShortcutString)) { - CString strNameFormat; - strNameFormat.Format(_T("%s (%s)"), tShortcut.m_strName, GetSizeString(ullSize)); + unsigned long long ullSize = 0; - tShortcut.m_strName = strNameFormat; - } + // retrieving free space might fail, but it's not critical - we just won't show the free space + if(bRetrieveFreeSpace && GetDynamicFreeSpace(tShortcut.m_strPath, &ullSize, NULL)) + { + CString strNameFormat; + strNameFormat.Format(_T("%s (%s)"), tShortcut.m_strName, GetSizeString(ullSize)); - vShortcuts.push_back(tShortcut); + tShortcut.m_strName = strNameFormat; + } + + vShortcuts.push_back(tShortcut); + } + else + BOOST_ASSERT(false); // non-critical, but not very nice } - else - BOOST_ASSERT(false); // non-critical, but not very nice - } - if(GetPropValue(rConfig)) - { - boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYTO_STRING), rResManager.LoadString(IDS_MENUTIPCOPYTO_STRING))); - BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) + if(GetPropValue(rConfig)) { - menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYTO_STRING), rResManager.LoadString(IDS_MENUTIPCOPYTO_STRING))); + BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) + { + menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), + TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); + } + + spRootItem->AddChild(menuItem); + + // optionally separator + if(!vShortcuts.empty()) + menuItem->AddChild(boost::make_shared()); + + // "Choose" menu option + menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); + TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); } - spRootItem->AddChild(menuItem); + if(GetPropValue(rConfig)) + { + boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUMOVETO_STRING), rResManager.LoadString(IDS_MENUTIPMOVETO_STRING))); + BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) + { + menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), + TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); + } - // optionally separator - if(!vShortcuts.empty()) - menuItem->AddChild(boost::make_shared()); + spRootItem->AddChild(menuItem); - // "Choose" menu option - menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); - } + // optionally separator + if(!vShortcuts.empty()) + menuItem->AddChild(boost::make_shared()); - if(GetPropValue(rConfig)) - { - boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUMOVETO_STRING), rResManager.LoadString(IDS_MENUTIPMOVETO_STRING))); - BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) - { - menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + // "Choose" menu option + menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); + TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); } - spRootItem->AddChild(menuItem); + if(GetPropValue(rConfig)) + { + boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVETOSPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING))); + BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) + { + menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), + TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), + TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), true)); + } - // optionally separator - if(!vShortcuts.empty()) - menuItem->AddChild(boost::make_shared()); + spRootItem->AddChild(menuItem); - // "Choose" menu option - menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); - } + // optionally separator + if(!vShortcuts.empty()) + menuItem->AddChild(boost::make_shared()); - if(GetPropValue(rConfig)) - { - boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVETOSPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING))); - BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) - { - menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + // "Choose" menu option + menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), true)); + TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), true)); } - - spRootItem->AddChild(menuItem); - - // optionally separator - if(!vShortcuts.empty()) - menuItem->AddChild(boost::make_shared()); - - // "Choose" menu option - menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), true)); } + + break; } + + default: + ASSERT(false); // unhandled case } - break; - default: - ASSERT(false); // unhandled case - } + chcore::TConfig cfgStorage; + chcore::TString wstrData; - chcore::TConfig cfgStorage; - chcore::TString wstrData; + cfgShellExt.StoreInConfig(cfgStorage, _T("ShellExtCfg")); + cfgStorage.WriteToString(wstrData); - cfgShellExt.StoreInConfig(cfgStorage, _T("ShellExtCfg")); - cfgStorage.WriteToString(wstrData); + std::wstring strSHMName = IPCSupport::GenerateSHMName((unsigned long)lParam); - std::wstring strSHMName = IPCSupport::GenerateSHMName((unsigned long)lParam); + m_tCHExtharedMemory.Create(strSHMName.c_str(), wstrData); + } + catch(const std::exception& e) + { + _ASSERTE(FALSE); + CString strMsg; + strMsg.Format(L"Encountered problem trying to retrieve shell ext configuration.\nReason: %S", e.what()); + LOG_ERROR(strMsg); - m_tCHExtharedMemory.Create(strSHMName.c_str(), wstrData); + return FALSE; + } + + return TRUE; } - break; case WM_IDENTIFY: {