void CGuiFolder::DeleteFolder(int m_iNumFolder, BOOL bUpdate) { if (m_iNumFolder < m_NumFolders) { if (bUpdate && m_iNumFolder == m_NumFolders -1) SelectFolder(0); if (m_iNumFolder == m_iSelected && m_iNumFolder != 0) { SelectFolder(1); m_iSelected = 1; } CFolderBar* pBar = (CFolderBar*)m_ArrayFolder.GetAt(m_iNumFolder); m_ArrayFolder.RemoveAt(m_iNumFolder,1); delete pBar; m_NumFolders--; if (m_iNumFolder == m_NumFolders) m_iSelected = m_iNumFolder - 1; if (m_iNumFolder == 0) m_iSelected = m_NumFolders - 1; else if(m_iNumFolder > 0) m_iSelected = m_iNumFolder - 1; if (bUpdate) { int OldSel = m_iSelected; RecalLayout(); SelectFolder(0); SelectFolder(m_NumFolders - 1); SelectFolder(OldSel); } } }
bool CNPPluginMisc::SelectFolder(NPVariant *result) { char szDir[MAX_PATH] = {0}; if(SelectFolder(szDir,m_hWnd)) SetRetValue(szDir,result); return true; }
void action(const gcn::ActionEvent& actionEvent) { if(actionEvent.getSource() == cmdPath) { char tmp[MAX_PATH]; strncpy(tmp, txtPath->getText().c_str(), MAX_PATH); wndEditFilesysVirtual->releaseModalFocus(); if(SelectFolder("Select folder", tmp)) txtPath->setText(tmp); wndEditFilesysVirtual->requestModalFocus(); cmdPath->requestFocus(); } else { if (actionEvent.getSource() == cmdOK) { if(txtDevice->getText().length() <= 0) { wndEditFilesysVirtual->setCaption("Please enter a device name."); return; } if(txtVolume->getText().length() <= 0) { wndEditFilesysVirtual->setCaption("Please enter a volume name."); return; } dialogResult = true; } dialogFinished = true; } }
// Gets the emails in the folder "INBOX" if SelectFolder() has not been called before. // Fetches only the header of the email (command FETCH HEADER). // s32_Index is zero-based! // IMPORTANT: The returned instance must be freed with delete. // We cannot return ref<cEmailParser> here because this cannot be stored in a Managed C++ class. // returns NULL if index invalid cEmailParser* cImap::FetchEmailAt(int s32_Index) { try { if (!mi_Folder) SelectFolder(L"INBOX"); if (s32_Index < 0 || s32_Index >= mi_Folder->getMessageCount()) return NULL; // Email index on the server is one-based! ref<net::message> i_Msg = mi_Folder->getMessage(s32_Index +1); mi_Folder->fetchMessage(i_Msg, net::folder::FETCH_FULL_HEADER | net::folder::FETCH_FLAGS | net::folder::FETCH_SIZE | net::folder::FETCH_UID); return new cEmailParser(mi_Folder, i_Msg, "IMAP"); } catch (...) { // http://stackoverflow.com/questions/21346400/destructors-not-executed-no-stack-unwinding-when-exception-is-thrown throw; } }
//---------------------------------------------------------------------------- BOOL PX2SceneExport::OnButtonDstRootDir (HWND wnd) { SelectFolder(wnd, mSettings.DstRootDir); SetDlgItemText(wnd, IDC_EDIT_DSTROOTDIR, mSettings.DstRootDir); return TRUE; }
/** * @brief Called when user selects Browse-button. */ void PropBackups::OnBnClickedBackupBrowse() { String path; if (SelectFolder(path, m_sGlobalFolder.c_str(), _T(""), GetSafeHwnd())) { SetDlgItemText(IDC_BACKUP_FOLDER, path); } }
/// Open Folder selection dialog for user to select filter folder. void PropRegistry::OnBrowseFilterPath() { CString path; if (SelectFolder(path, m_strUserFilterPath, IDS_OPEN_TITLE, GetSafeHwnd())) { SetDlgItemText(IDC_FILTER_USER_PATH, path); } }
/// Open Folder selection dialog for user to select filter folder. void PropRegistry::OnBrowseFilterPath() { String path; if (SelectFolder(path, m_strUserFilterPath.c_str(), _("Open"), GetSafeHwnd())) { SetDlgItemText(IDC_FILTER_USER_PATH, path); } }
/// Select temporary files folder. void PropRegistry::OnBrowseTmpFolder() { String path; if (SelectFolder(path, m_tempFolder.c_str(), _T(""), GetSafeHwnd())) { SetDlgItemText(IDC_TMPFOLDER_NAME, path); } }
void MainWindow::SelectOutputFolder() { QFileDialog dialog(this); dialog.setDirectory(m_settings.outputDir.ToChars()); if( SelectFolder(dialog, m_settings.outputDir) ) { ui.lineEdit_Output_Folder->setText(m_settings.outputDir.ToChars()); } }
void CDlgOption::OnBkBtnChangeDir() { CString sFolderPath; m_ctlEdit.GetWindowText( sFolderPath ); if( SelectFolder(sFolderPath) ) { m_ctlEdit.SetWindowText( sFolderPath ); } }
void CSetMainPage::OnBrowseDir() { UpdateData(TRUE); if (!SelectFolder(GetSafeHwnd(), m_sMsysGitPath, m_sMsysGitExtranPath)) return; UpdateData(FALSE); SetModified(TRUE); }
void CWZStep3::OnRefer() { WCHAR szSelectPath[MAX_PATH]; UpdateData(TRUE); if (SelectFolder(m_hWnd,szSelectPath)) { m_SourcePath = szSelectPath; UpdateData(FALSE); } }
void CAddPath::OnButtonRefer() { // TODO: Add your control notification handler code here WCHAR szSourceDir[MAX_PATH]; memset(szSourceDir,0,sizeof(szSourceDir)); if(SelectFolder(m_hWnd,szSourceDir)) { m_Path = szSourceDir; UpdateData(FALSE); } }
LRESULT CPlayerDlg::OnBnClickedButtonDef(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { DoDataExchange(TRUE); TCHAR szFilePath[MAX_PATH + 1]; ::GetCurrentDirectory(MAX_PATH,szFilePath); CString csFolder; if(SelectFolder(m_hWnd, csFolder)) m_def = csFolder; ::SetCurrentDirectory(szFilePath); DoDataExchange(); return 0; }
// Gets the count of emails in the folder "INBOX" if SelectFolder() has not been called before. int cImap::GetEmailCount() { try { if (!mi_Folder) SelectFolder(L"INBOX"); return mi_Folder->getMessageCount(); } catch (...) { // http://stackoverflow.com/questions/21346400/destructors-not-executed-no-stack-unwinding-when-exception-is-thrown throw; } }
BOOL CLibraryFolderCtrl::SelectFolder(CLibraryFolder* pFolder, HTREEITEM hItem) { if ( hItem == NULL ) hItem = GetRootItem(); for ( ; hItem != NULL ; hItem = GetNextItem( hItem, TVGN_NEXT ) ) { if ( pFolder == (CLibraryFolder*)GetItemData( hItem ) ) { SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED ); return TRUE; } HTREEITEM hChild = GetChildItem( hItem ); if ( hChild != NULL && SelectFolder( pFolder, hChild ) ) return TRUE; } return FALSE; }
INT_PTR CDialogPackage::CTabInfo::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDC_PACKAGEINFO_ADDSKIN_BUTTON: { c_Dialog->m_SkinFolder.second = SelectFolder(m_Window, g_Data.skinsPath); if (!c_Dialog->m_SkinFolder.second.empty()) { c_Dialog->m_SkinFolder.first = PathFindFileName(c_Dialog->m_SkinFolder.second.c_str()); c_Dialog->m_SkinFolder.first.pop_back(); // Remove slash HWND item = GetDlgItem(m_Window, IDC_PACKAGEINFO_COMPONENTS_LIST); LVITEM lvi; lvi.mask = LVIF_TEXT | LVIF_GROUPID; lvi.iItem = 1; lvi.iSubItem = 0; lvi.iGroupId = 0; lvi.pszText = (WCHAR*)c_Dialog->m_SkinFolder.first.c_str(); ListView_InsertItem(item, &lvi); EnableWindow((HWND)lParam, FALSE); c_Dialog->SetNextButtonState(); } } break; case IDC_PACKAGEINFO_ADDTHEME_BUTTON: { std::wstring folder = SelectFolder(m_Window, g_Data.settingsPath + L"Layouts\\"); if (!folder.empty()) { std::wstring name = PathFindFileName(folder.c_str()); name.pop_back(); // Remove slash if (c_Dialog->m_LayoutFolders.insert(std::make_pair(name, folder)).second) { HWND item = GetDlgItem(m_Window, IDC_PACKAGEINFO_COMPONENTS_LIST); LVITEM lvi; lvi.mask = LVIF_TEXT | LVIF_GROUPID; lvi.iItem = c_Dialog->m_LayoutFolders.size() + 1; lvi.iSubItem = 0; lvi.iGroupId = 1; lvi.pszText = (WCHAR*)name.c_str(); ListView_InsertItem(item, &lvi); } } } break; case IDC_PACKAGEINFO_ADDPLUGIN_BUTTON: { std::pair<std::wstring, std::wstring> plugins = SelectPlugin(m_Window); std::wstring name = PathFindFileName(plugins.first.c_str()); if (!name.empty() && c_Dialog->m_PluginFolders.insert(std::make_pair(name, plugins)).second) { HWND item = GetDlgItem(m_Window, IDC_PACKAGEINFO_COMPONENTS_LIST); LVITEM lvi; lvi.mask = LVIF_TEXT | LVIF_GROUPID; lvi.iItem = c_Dialog->m_PluginFolders.size() + 1; lvi.iSubItem = 0; lvi.iGroupId = 2; lvi.pszText = (WCHAR*)name.c_str(); ListView_InsertItem(item, &lvi); } } break; case IDC_PACKAGEINFO_REMOVE_BUTTON: { HWND item = GetDlgItem(m_Window, IDC_PACKAGEINFO_COMPONENTS_LIST); int sel = ListView_GetNextItem(item, -1, LVNI_FOCUSED | LVNI_SELECTED); if (sel != -1) { WCHAR buffer[MAX_PATH]; // Remove unchecked items from the component sets LVITEM lvi; lvi.mask = LVIF_GROUPID | LVIF_TEXT; lvi.iSubItem = 0; lvi.iItem = sel; lvi.pszText = buffer; lvi.cchTextMax = _countof(buffer); ListView_GetItem(item, &lvi); ListView_DeleteItem(item, sel); const std::wstring name = buffer; switch (lvi.iGroupId) { case 0: { item = GetDlgItem(m_Window, IDC_PACKAGEINFO_ADDSKIN_BUTTON); EnableWindow(item, TRUE); c_Dialog->m_SkinFolder.first.clear(); c_Dialog->m_SkinFolder.second.clear(); c_Dialog->SetNextButtonState(); } break; case 1: c_Dialog->m_LayoutFolders.erase(c_Dialog->m_LayoutFolders.find(name)); break; case 2: c_Dialog->m_PluginFolders.erase(c_Dialog->m_PluginFolders.find(name)); break; } } } break; case IDC_PACKAGEINFO_NAME_EDIT: case IDC_PACKAGEINFO_AUTHOR_EDIT: case IDC_PACKAGEINFO_VERSION_EDIT: if (HIWORD(wParam) == EN_CHANGE) { WCHAR buffer[64]; int len = GetWindowText((HWND)lParam, buffer, _countof(buffer)); if (LOWORD(wParam) == IDC_PACKAGEINFO_NAME_EDIT) { c_Dialog->m_Name.assign(buffer, len); } else if (LOWORD(wParam) == IDC_PACKAGEINFO_AUTHOR_EDIT) { c_Dialog->m_Author.assign(buffer, len); } else // if (LOWORD(wParam) == IDC_PACKAGEINFO_VERSION_EDIT) { c_Dialog->m_Version.assign(buffer, len); } c_Dialog->SetNextButtonState(); } break; default: return FALSE; } return TRUE; }
INT_PTR CRecreateDlg::OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDC_CHOOSE: { wchar_t *pszFilePath = SelectFile(L"Choose program to run", NULL, NULL, hDlg, L"Executables (*.exe)\0*.exe\0All files (*.*)\0*.*\0\0", sff_AutoQuote); if (pszFilePath) { SetDlgItemText(hDlg, IDC_RESTART_CMD, pszFilePath); SafeFree(pszFilePath); } return TRUE; } // case IDC_CHOOSE: case IDC_CHOOSE_DIR: { wchar_t* pszDefFolder = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR); wchar_t* pszFolder = SelectFolder(L"Choose startup directory", pszDefFolder, hDlg, sff_Default); if (pszFolder) { SetDlgItemText(hDlg, IDC_STARTUP_DIR, pszFolder); SafeFree(pszFolder); } SafeFree(pszDefFolder); return TRUE; } // case IDC_CHOOSE_DIR: case cbRunAsAdmin: { // BCM_SETSHIELD = 5644 BOOL bRunAs = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0); if (gOSVer.dwMajorVersion >= 6) { SendDlgItemMessage(hDlg, IDC_START, 5644/*BCM_SETSHIELD*/, 0, bRunAs && (mp_Args->aRecreate != cra_EditTab)); } if (bRunAs) { CheckRadioButton(hDlg, rbCurrentUser, rbAnotherUser, rbCurrentUser); CheckDlgButton(hDlg, cbRunAsRestricted, BST_UNCHECKED); RecreateDlgProc(hDlg, UM_USER_CONTROLS, 0, 0); } return TRUE; } // case cbRunAsAdmin: case rbCurrentUser: case rbAnotherUser: case cbRunAsRestricted: { RecreateDlgProc(hDlg, UM_USER_CONTROLS, LOWORD(wParam), 0); return TRUE; } case rbRecreateSplitNone: case rbRecreateSplit2Right: case rbRecreateSplit2Bottom: { RConStartArgs* pArgs = mp_Args; switch (LOWORD(wParam)) { case rbRecreateSplitNone: pArgs->eSplit = RConStartArgs::eSplitNone; break; case rbRecreateSplit2Right: pArgs->eSplit = RConStartArgs::eSplitHorz; break; case rbRecreateSplit2Bottom: pArgs->eSplit = RConStartArgs::eSplitVert; break; } EnableWindow(GetDlgItem(hDlg, tRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); EnableWindow(GetDlgItem(hDlg, stRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); if (pArgs->eSplit != pArgs->eSplitNone) SetFocus(GetDlgItem(hDlg, tRecreateSplit)); return TRUE; } // case rbRecreateSplitXXX case IDC_START: { RConStartArgs* pArgs = mp_Args; _ASSERTE(pArgs); SafeFree(pArgs->pszUserName); SafeFree(pArgs->pszDomain); //SafeFree(pArgs->pszUserPassword); if (SendDlgItemMessage(hDlg, rbAnotherUser, BM_GETCHECK, 0, 0)) { pArgs->RunAsRestricted = crb_Off; pArgs->pszUserName = GetDlgItemTextPtr(hDlg, tRunAsUser); if (pArgs->pszUserName) { //pArgs->pszUserPassword = GetDlgItemText(hDlg, tRunAsPassword); // Попытаться проверить правильность введенного пароля и возможность запуска bool bCheckPwd = pArgs->CheckUserToken(GetDlgItem(hDlg, tRunAsPassword)); DWORD nErr = bCheckPwd ? 0 : GetLastError(); if (!bCheckPwd) { DisplayLastError(L"Invalid user name or password was specified!", nErr, MB_ICONSTOP, NULL, hDlg); return 1; } } } else { pArgs->RunAsRestricted = SendDlgItemMessage(hDlg, cbRunAsRestricted, BM_GETCHECK, 0, 0) ? crb_On : crb_Off; } // Vista+ (As Admin...) pArgs->RunAsAdministrator = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0) ? crb_On : crb_Off; // StartupDir (may be specified as argument) wchar_t* pszDir = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR); wchar_t* pszExpand = (pszDir && wcschr(pszDir, L'%')) ? ExpandEnvStr(pszDir) : NULL; LPCWSTR pszDirResult = pszExpand ? pszExpand : pszDir; // Another user? We may fail with access denied. Check only for "current user" account if (!pArgs->pszUserName && pszDirResult && *pszDirResult && !DirectoryExists(pszDirResult)) { wchar_t* pszErrInfo = lstrmerge(L"Specified directory does not exists!\n", pszDirResult, L"\n" L"Do you want to choose another directory?\n\n"); DWORD nErr = GetLastError(); int iDirBtn = DisplayLastError(pszErrInfo, nErr, MB_ICONEXCLAMATION|MB_YESNO, NULL, hDlg); if (iDirBtn == IDYES) { SafeFree(pszDir); SafeFree(pszExpand); SafeFree(pszErrInfo); return 1; } // User want to run "as is". Most likely it will fail, but who knows... } SafeFree(pArgs->pszStartupDir); pArgs->pszStartupDir = pszExpand ? pszExpand : pszDir; if (pszExpand) { SafeFree(pszDir) } // Command // pszSpecialCmd мог быть передан аргументом - умолчание для строки ввода SafeFree(pArgs->pszSpecialCmd); // GetDlgItemText выделяет память через calloc pArgs->pszSpecialCmd = GetDlgItemTextPtr(hDlg, IDC_RESTART_CMD); if (pArgs->pszSpecialCmd) gpSet->HistoryAdd(pArgs->pszSpecialCmd); if ((pArgs->aRecreate != cra_RecreateTab) && (pArgs->aRecreate != cra_EditTab)) { if (SendDlgItemMessage(hDlg, cbRunInNewWindow, BM_GETCHECK, 0, 0)) pArgs->aRecreate = cra_CreateWindow; else pArgs->aRecreate = cra_CreateTab; } if (((pArgs->aRecreate == cra_CreateTab) || (pArgs->aRecreate == cra_EditTab)) && (pArgs->eSplit != RConStartArgs::eSplitNone)) { BOOL bOk = FALSE; int nPercent = GetDlgItemInt(hDlg, tRecreateSplit, &bOk, FALSE); if (bOk && (nPercent >= 1) && (nPercent <= 99)) { pArgs->nSplitValue = (100-nPercent) * 10; } //pArgs->nSplitPane = 0; Сбрасывать не будем? } mn_DlgRc = IDC_START; EndDialog(hDlg, IDC_START); return TRUE; } // case IDC_START: case IDC_TERMINATE: mn_DlgRc = IDC_TERMINATE; EndDialog(hDlg, IDC_TERMINATE); return TRUE; case IDCANCEL: mn_DlgRc = IDCANCEL; EndDialog(hDlg, IDCANCEL); return TRUE; } return FALSE; }
INT_PTR CRecreateDlg::RecreateDlgProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { #define UM_USER_CONTROLS (WM_USER+121) #define UM_FILL_CMDLIST (WM_USER+122) CRecreateDlg* pDlg = NULL; if (messg == WM_INITDIALOG) { pDlg = (CRecreateDlg*)lParam; pDlg->mh_Dlg = hDlg; SetWindowLongPtr(hDlg, DWLP_USER, lParam); } else { pDlg = (CRecreateDlg*)GetWindowLongPtr(hDlg, DWLP_USER); } if (!pDlg) { return FALSE; } PatchMsgBoxIcon(hDlg, messg, wParam, lParam); switch (messg) { case WM_INITDIALOG: { LRESULT lbRc = FALSE; // Visual SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hClassIconSm); // Set password style (avoid "bars" on some OS) SendDlgItemMessage(hDlg, tRunAsPassword, WM_SETFONT, (LPARAM)(HFONT)GetStockObject(DEFAULT_GUI_FONT), 0); // Add menu items HMENU hSysMenu = GetSystemMenu(hDlg, FALSE); InsertMenu(hSysMenu, 0, MF_BYPOSITION, MF_SEPARATOR, 0); InsertMenu(hSysMenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED, ID_RESETCMDHISTORY, L"Clear history..."); InsertMenu(hSysMenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED | (gpSet->isSaveCmdHistory ? MF_CHECKED : 0), ID_STORECMDHISTORY, L"Store history"); //#ifdef _DEBUG //SetWindowPos(ghOpWnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); //#endif RConStartArgs* pArgs = pDlg->mp_Args; _ASSERTE(pArgs); // Fill command and task drop down SendMessage(hDlg, UM_FILL_CMDLIST, TRUE, 0); // Set text in command and folder fields SetDlgItemText(hDlg, IDC_RESTART_CMD, pDlg->mpsz_DefCmd ? pDlg->mpsz_DefCmd : pArgs->pszSpecialCmd ? pArgs->pszSpecialCmd : L""); SetDlgItemText(hDlg, IDC_STARTUP_DIR, pDlg->mpsz_DefDir ? pDlg->mpsz_DefDir : pArgs->pszStartupDir ? pArgs->pszStartupDir : gpConEmu->WorkDir()); // Split controls if (pArgs->aRecreate == cra_RecreateTab) { // Hide Split's ShowWindow(GetDlgItem(hDlg, gbRecreateSplit), SW_HIDE); ShowWindow(GetDlgItem(hDlg, rbRecreateSplitNone), SW_HIDE); ShowWindow(GetDlgItem(hDlg, rbRecreateSplit2Right), SW_HIDE); ShowWindow(GetDlgItem(hDlg, rbRecreateSplit2Bottom), SW_HIDE); ShowWindow(GetDlgItem(hDlg, stRecreateSplit), SW_HIDE); ShowWindow(GetDlgItem(hDlg, tRecreateSplit), SW_HIDE); } else { // Fill splits SetDlgItemInt(hDlg, tRecreateSplit, (1000-pArgs->nSplitValue)/10, FALSE); CheckRadioButton(hDlg, rbRecreateSplitNone, rbRecreateSplit2Bottom, rbRecreateSplitNone+pArgs->eSplit); EnableWindow(GetDlgItem(hDlg, tRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); EnableWindow(GetDlgItem(hDlg, stRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); } // Спрятать флажок "New window" bool bRunInNewWindow_Hidden = (pArgs->aRecreate == cra_EditTab || pArgs->aRecreate == cra_RecreateTab); ShowWindow(GetDlgItem(hDlg, cbRunInNewWindow), bRunInNewWindow_Hidden ? SW_HIDE : SW_SHOWNORMAL); const wchar_t *pszUser = pArgs->pszUserName; const wchar_t *pszDomain = pArgs->pszDomain; bool bResticted = (pArgs->RunAsRestricted == crb_On); int nChecked = rbCurrentUser; DWORD nUserNameLen = countof(pDlg->ms_CurUser); if (!GetUserName(pDlg->ms_CurUser, &nUserNameLen)) pDlg->ms_CurUser[0] = 0; wchar_t szRbCaption[MAX_PATH*3]; lstrcpy(szRbCaption, L"Run as current &user: "******"UPN format" остается в pszUser lstrcpyn(szOtherUser, pszUser, MAX_PATH); wcscat_c(szOtherUser, L"@"); lstrcpyn(szOtherUser+_tcslen(szOtherUser), pszDomain, MAX_PATH); } else { // "Старая" нотация domain\user lstrcpyn(szOtherUser, pszDomain, MAX_PATH); wcscat_c(szOtherUser, L"\\"); lstrcpyn(szOtherUser+_tcslen(szOtherUser), pszUser, MAX_PATH); } } else { lstrcpyn(szOtherUser, pszUser, countof(szOtherUser)); } SetDlgItemText(hDlg, tRunAsPassword, pArgs->szUserPassword); } } SetDlgItemText(hDlg, tRunAsUser, (nChecked == rbAnotherUser) ? szOtherUser : L""); CheckRadioButton(hDlg, rbCurrentUser, rbAnotherUser, nChecked); RecreateDlgProc(hDlg, UM_USER_CONTROLS, 0, 0); if (gOSVer.dwMajorVersion < 6) { // В XP и ниже это просто RunAs - с возможностью ввода имени пользователя и пароля //apiShowWindow(GetDlgItem(hDlg, cbRunAsAdmin), SW_HIDE); SetDlgItemTextA(hDlg, cbRunAsAdmin, "&Run as..."); //GCC hack. иначе не собирается // И уменьшить длину RECT rcBox; GetWindowRect(GetDlgItem(hDlg, cbRunAsAdmin), &rcBox); SetWindowPos(GetDlgItem(hDlg, cbRunAsAdmin), NULL, 0, 0, (rcBox.right-rcBox.left)/2, rcBox.bottom-rcBox.top, SWP_NOMOVE|SWP_NOZORDER); } else if (gpConEmu->mb_IsUacAdmin || (pArgs && (pArgs->RunAsAdministrator == crb_On))) { CheckDlgButton(hDlg, cbRunAsAdmin, BST_CHECKED); if (gpConEmu->mb_IsUacAdmin) // Только в Vista+ если GUI уже запущен под админом { EnableWindow(GetDlgItem(hDlg, cbRunAsAdmin), FALSE); } else if (gOSVer.dwMajorVersion < 6) { RecreateDlgProc(hDlg, WM_COMMAND, cbRunAsAdmin, 0); } } //} SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)hClassIcon); RECT rcBtnBox = {0}; if (pArgs->aRecreate == cra_RecreateTab) { //GCC hack. иначе не собирается SetDlgItemTextA(hDlg, IDC_RESTART_MSG, "About to restart console"); SendDlgItemMessage(hDlg, IDC_RESTART_ICON, STM_SETICON, (WPARAM)LoadIcon(NULL,IDI_EXCLAMATION), 0); // Выровнять флажок по кнопке GetWindowRect(GetDlgItem(hDlg, IDC_START), &rcBtnBox); lbRc = TRUE; } else { //GCC hack. иначе не собирается SetDlgItemTextA(hDlg, IDC_RESTART_MSG, "Create new console"); // Если ВЫКЛЮЧЕН "Multi consoles in one window" // - Check & Disable "New window" checkbox CheckDlgButton(hDlg, cbRunInNewWindow, (pArgs->aRecreate == cra_CreateWindow || !gpSetCls->IsMulti()) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hDlg, cbRunInNewWindow), gpSetCls->IsMulti()); // SendDlgItemMessage(hDlg, IDC_RESTART_ICON, STM_SETICON, (WPARAM)LoadIcon(NULL,IDI_QUESTION), 0); POINT pt = {0,0}; MapWindowPoints(GetDlgItem(hDlg, IDC_TERMINATE), hDlg, &pt, 1); DestroyWindow(GetDlgItem(hDlg, IDC_TERMINATE)); SetWindowPos(GetDlgItem(hDlg, IDC_START), NULL, pt.x, pt.y, 0,0, SWP_NOSIZE|SWP_NOZORDER); SetDlgItemText(hDlg, IDC_START, (pArgs->aRecreate == cra_EditTab) ? L"&Save" : L"&Start"); DestroyWindow(GetDlgItem(hDlg, IDC_WARNING)); // Выровнять флажок по кнопке GetWindowRect(GetDlgItem(hDlg, IDC_START), &rcBtnBox); } if (rcBtnBox.left) { // Выровнять флажок по кнопке MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtnBox, 2); RECT rcBox; GetWindowRect(GetDlgItem(hDlg, cbRunAsAdmin), &rcBox); POINT pt; pt.x = rcBtnBox.left - (rcBox.right - rcBox.left) - 5; pt.y = rcBtnBox.top + ((rcBtnBox.bottom-rcBtnBox.top) - (rcBox.bottom-rcBox.top))/2; SetWindowPos(GetDlgItem(hDlg, cbRunAsAdmin), NULL, pt.x, pt.y, 0,0, SWP_NOSIZE|SWP_NOZORDER); } // Correct cbRunInNewWindow position if (!bRunInNewWindow_Hidden) { POINT pt = {}; MapWindowPoints(GetDlgItem(hDlg, cbRunAsAdmin), hDlg, &pt, 1); RECT rcBox2; GetWindowRect(GetDlgItem(hDlg, cbRunInNewWindow), &rcBox2); SetWindowPos(GetDlgItem(hDlg, cbRunInNewWindow), NULL, pt.x-(rcBox2.right-rcBox2.left), pt.y, 0,0, SWP_NOSIZE); } // Ensure, it will be "on screen" RECT rect; GetWindowRect(hDlg, &rect); RECT rcCenter = CenterInParent(rect, pDlg->mh_Parent); MoveWindow(hDlg, rcCenter.left, rcCenter.top, rect.right - rect.left, rect.bottom - rect.top, false); // Была отключена обработка CConEmuMain::OnFocus (лишние телодвижения) PostMessage(hDlg, (WM_APP+1), 0,0); // Default focus control if (pArgs->aRecreate == cra_RecreateTab) SetFocus(GetDlgItem(hDlg, IDC_START)); // Win+~ (Recreate tab), Focus on "Restart" button" else if ((pArgs->pszUserName && *pArgs->pszUserName) && !*pArgs->szUserPassword) SetFocus(GetDlgItem(hDlg, tRunAsPassword)); // We need password, all other fields are ready else SetFocus(GetDlgItem(hDlg, IDC_RESTART_CMD)); // Set focus in command-line field return lbRc; } case (WM_APP+1): //TODO: Не совсем корректно, не учитывается предыдущее значение флажка gpConEmu->SetSkipOnFocus(false); return FALSE; case WM_CTLCOLORSTATIC: if (GetDlgItem(hDlg, IDC_WARNING) == (HWND)lParam) { SetTextColor((HDC)wParam, 255); HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)hBrush; } break; //case WM_GETICON: // if (wParam==ICON_BIG) // { // /*SetWindowLong(hWnd2, DWL_MSGRESULT, (LRESULT)hClassIcon); // return 1;*/ // } // else // { // SetWindowLongPtr(hDlg, DWLP_MSGRESULT, (LRESULT)hClassIconSm); // return 1; // } // return 0; case UM_FILL_CMDLIST: { RConStartArgs* pArgs = pDlg->mp_Args; _ASSERTE(pArgs); pDlg->AddCommandList(pArgs->pszSpecialCmd); pDlg->AddCommandList(pDlg->mpsz_SysCmd, pArgs->pszSpecialCmd ? -1 : 0); pDlg->AddCommandList(pDlg->mpsz_CurCmd); pDlg->AddCommandList(pDlg->mpsz_DefCmd); // Может быть позван после очистки истории из меню, тогда нет смысла и дергаться if (wParam) { LPCWSTR pszHistory = gpSet->HistoryGet(); if (pszHistory) { while (*pszHistory) { pDlg->AddCommandList(pszHistory); pszHistory += _tcslen(pszHistory)+1; } } } // Tasks int nGroup = 0; const Settings::CommandTasks* pGrp = NULL; while ((pGrp = gpSet->CmdTaskGet(nGroup++))) { pDlg->AddCommandList(pGrp->pszName); } } return 0; case UM_USER_CONTROLS: { if (SendDlgItemMessage(hDlg, rbCurrentUser, BM_GETCHECK, 0, 0)) { EnableWindow(GetDlgItem(hDlg, cbRunAsRestricted), TRUE); //BOOL lbText = SendDlgItemMessage(hDlg, cbRunAsRestricted, BM_GETCHECK, 0, 0) == 0; EnableWindow(GetDlgItem(hDlg, tRunAsUser), FALSE); EnableWindow(GetDlgItem(hDlg, tRunAsPassword), FALSE); } else { if (SendDlgItemMessage(hDlg, tRunAsUser, CB_GETCOUNT, 0, 0) == 0) { DWORD dwLevel = 3, dwEntriesRead = 0, dwTotalEntries = 0, dwResumeHandle = 0; NET_API_STATUS nStatus; USER_INFO_3 *info = NULL; nStatus = ::NetUserEnum(NULL, dwLevel, FILTER_NORMAL_ACCOUNT, (PBYTE*) & info, MAX_PREFERRED_LENGTH, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle); if (nStatus == NERR_Success) { wchar_t *pszAdmin = NULL, *pszLikeAdmin = NULL, *pszOtherUser = NULL; for (DWORD i = 0; i < dwEntriesRead; ++i) { // usri3_logon_server "\\*" wchar_t * if (!(info[i].usri3_flags & UF_ACCOUNTDISABLE) && info[i].usri3_name && *info[i].usri3_name) { SendDlgItemMessage(hDlg, tRunAsUser, CB_ADDSTRING, 0, (LPARAM)info[i].usri3_name); if (info[i].usri3_priv == 2/*USER_PRIV_ADMIN*/) { if (!pszAdmin && (info[i].usri3_user_id == 500)) pszAdmin = lstrdup(info[i].usri3_name); else if (!pszLikeAdmin && (lstrcmpi(pDlg->ms_CurUser, info[i].usri3_name) != 0)) pszLikeAdmin = lstrdup(info[i].usri3_name); } else if (!pszOtherUser && (info[i].usri3_priv == 1/*USER_PRIV_USER*/) && (lstrcmpi(pDlg->ms_CurUser, info[i].usri3_name) != 0)) { pszOtherUser = lstrdup(info[i].usri3_name); } } } if (GetWindowTextLength(GetDlgItem(hDlg, tRunAsUser)) == 0) { // Try to suggest "Administrator" account SetDlgItemText(hDlg, tRunAsUser, pszAdmin ? pszAdmin : pszLikeAdmin ? pszLikeAdmin : pszOtherUser ? pszOtherUser : pDlg->ms_CurUser); } ::NetApiBufferFree(info); SafeFree(pszAdmin); SafeFree(pszLikeAdmin); } else { // Добавить хотя бы текущего SendDlgItemMessage(hDlg, tRunAsUser, CB_ADDSTRING, 0, (LPARAM)pDlg->ms_CurUser); } } EnableWindow(GetDlgItem(hDlg, cbRunAsRestricted), FALSE); EnableWindow(GetDlgItem(hDlg, tRunAsUser), TRUE); EnableWindow(GetDlgItem(hDlg, tRunAsPassword), TRUE); } if (wParam == rbAnotherUser) SetFocus(GetDlgItem(hDlg, tRunAsUser)); } return 0; case WM_SYSCOMMAND: switch (LOWORD(wParam)) { case ID_RESETCMDHISTORY: // Подтверждение спросит ResetCmdHistory if (gpSetCls->ResetCmdHistory(hDlg)) { wchar_t* pszCmd = GetDlgItemText(hDlg, IDC_RESTART_CMD); SendDlgItemMessage(hDlg, IDC_RESTART_CMD, CB_RESETCONTENT, 0,0); SendMessage(hDlg, UM_FILL_CMDLIST, FALSE, 0); if (pszCmd) { SetDlgItemText(hDlg, IDC_RESTART_CMD, pszCmd); free(pszCmd); } } SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 0); return 1; case ID_STORECMDHISTORY: if (MsgBox(gpSet->isSaveCmdHistory ? L"Do you want to disable history?" : L"Do you want to enable history?", MB_YESNO|MB_ICONQUESTION, NULL, hDlg) == IDYES) { gpSetCls->SetSaveCmdHistory(!gpSet->isSaveCmdHistory); HMENU hSysMenu = GetSystemMenu(hDlg, FALSE); CheckMenuItem(hSysMenu, ID_STORECMDHISTORY, MF_BYCOMMAND|(gpSet->isSaveCmdHistory ? MF_CHECKED : 0)); } SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 0); return 1; } break; case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { switch (LOWORD(wParam)) { case IDC_CHOOSE: { wchar_t *pszFilePath = SelectFile(L"Choose program to run", NULL, hDlg, L"Executables (*.exe)\0*.exe\0All files (*.*)\0*.*\0\0", true, false, false); if (pszFilePath) { SetDlgItemText(hDlg, IDC_RESTART_CMD, pszFilePath); SafeFree(pszFilePath); } return 1; } case IDC_CHOOSE_DIR: { wchar_t* pszDefFolder = GetDlgItemText(hDlg, IDC_STARTUP_DIR); wchar_t* pszFolder = SelectFolder(L"Choose startup directory", pszDefFolder, hDlg, false, false); if (pszFolder) { SetDlgItemText(hDlg, IDC_STARTUP_DIR, pszFolder); SafeFree(pszFolder); } SafeFree(pszDefFolder); return 1; } case cbRunAsAdmin: { // BCM_SETSHIELD = 5644 BOOL bRunAs = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0); if (gOSVer.dwMajorVersion >= 6) { SendDlgItemMessage(hDlg, IDC_START, 5644/*BCM_SETSHIELD*/, 0, bRunAs && (pDlg->mp_Args->aRecreate != cra_EditTab)); } if (bRunAs) { CheckRadioButton(hDlg, rbCurrentUser, rbAnotherUser, rbCurrentUser); CheckDlgButton(hDlg, cbRunAsRestricted, BST_UNCHECKED); RecreateDlgProc(hDlg, UM_USER_CONTROLS, 0, 0); } return 1; } case rbCurrentUser: case rbAnotherUser: case cbRunAsRestricted: { RecreateDlgProc(hDlg, UM_USER_CONTROLS, LOWORD(wParam), 0); return 1; } case rbRecreateSplitNone: case rbRecreateSplit2Right: case rbRecreateSplit2Bottom: { RConStartArgs* pArgs = pDlg->mp_Args; switch (LOWORD(wParam)) { case rbRecreateSplitNone: pArgs->eSplit = RConStartArgs::eSplitNone; break; case rbRecreateSplit2Right: pArgs->eSplit = RConStartArgs::eSplitHorz; break; case rbRecreateSplit2Bottom: pArgs->eSplit = RConStartArgs::eSplitVert; break; } EnableWindow(GetDlgItem(hDlg, tRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); EnableWindow(GetDlgItem(hDlg, stRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); if (pArgs->eSplit != pArgs->eSplitNone) SetFocus(GetDlgItem(hDlg, tRecreateSplit)); return 1; } case IDC_START: { RConStartArgs* pArgs = pDlg->mp_Args; _ASSERTE(pArgs); SafeFree(pArgs->pszUserName); SafeFree(pArgs->pszDomain); //SafeFree(pArgs->pszUserPassword); if (SendDlgItemMessage(hDlg, rbAnotherUser, BM_GETCHECK, 0, 0)) { pArgs->RunAsRestricted = crb_Off; pArgs->pszUserName = GetDlgItemText(hDlg, tRunAsUser); if (pArgs->pszUserName) { //pArgs->pszUserPassword = GetDlgItemText(hDlg, tRunAsPassword); // Попытаться проверить правильность введенного пароля и возможность запуска bool bCheckPwd = pArgs->CheckUserToken(GetDlgItem(hDlg, tRunAsPassword)); DWORD nErr = bCheckPwd ? 0 : GetLastError(); if (!bCheckPwd) { DisplayLastError(L"Invalid user name or password was specified!", nErr, MB_ICONSTOP, NULL, hDlg); return 1; } } } else { pArgs->RunAsRestricted = SendDlgItemMessage(hDlg, cbRunAsRestricted, BM_GETCHECK, 0, 0) ? crb_On : crb_Off; } // Vista+ (As Admin...) pArgs->RunAsAdministrator = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0) ? crb_On : crb_Off; // StartupDir (may be specified as argument) wchar_t* pszDir = GetDlgItemText(hDlg, IDC_STARTUP_DIR); wchar_t* pszExpand = (pszDir && wcschr(pszDir, L'%')) ? ExpandEnvStr(pszDir) : NULL; LPCWSTR pszDirResult = pszExpand ? pszExpand : pszDir; // Another user? We may fail with access denied. Check only for "current user" account if (!pArgs->pszUserName && pszDirResult && *pszDirResult && !DirectoryExists(pszDirResult)) { wchar_t* pszErrInfo = lstrmerge(L"Specified directory does not exists!\n", pszDirResult, L"\n" L"Do you want to choose another directory?\n\n"); DWORD nErr = GetLastError(); int iDirBtn = DisplayLastError(pszErrInfo, nErr, MB_ICONEXCLAMATION|MB_YESNO, NULL, hDlg); if (iDirBtn == IDYES) { SafeFree(pszDir); SafeFree(pszExpand); SafeFree(pszErrInfo); return 1; } // User want to run "as is". Most likely it will fail, but who knows... } SafeFree(pArgs->pszStartupDir); pArgs->pszStartupDir = pszExpand ? pszExpand : pszDir; if (pszExpand) { SafeFree(pszDir) } // Command // pszSpecialCmd мог быть передан аргументом - умолчание для строки ввода SafeFree(pArgs->pszSpecialCmd); // GetDlgItemText выделяет память через calloc pArgs->pszSpecialCmd = GetDlgItemText(hDlg, IDC_RESTART_CMD); if (pArgs->pszSpecialCmd) gpSet->HistoryAdd(pArgs->pszSpecialCmd); if ((pArgs->aRecreate != cra_RecreateTab) && (pArgs->aRecreate != cra_EditTab)) { if (SendDlgItemMessage(hDlg, cbRunInNewWindow, BM_GETCHECK, 0, 0)) pArgs->aRecreate = cra_CreateWindow; else pArgs->aRecreate = cra_CreateTab; } if (((pArgs->aRecreate == cra_CreateTab) || (pArgs->aRecreate == cra_EditTab)) && (pArgs->eSplit != RConStartArgs::eSplitNone)) { BOOL bOk = FALSE; int nPercent = GetDlgItemInt(hDlg, tRecreateSplit, &bOk, FALSE); if (bOk && (nPercent >= 1) && (nPercent <= 99)) { pArgs->nSplitValue = (100-nPercent) * 10; } //pArgs->nSplitPane = 0; Сбрасывать не будем? } pDlg->mn_DlgRc = IDC_START; EndDialog(hDlg, IDC_START); return 1; } case IDC_TERMINATE: pDlg->mn_DlgRc = IDC_TERMINATE; EndDialog(hDlg, IDC_TERMINATE); return 1; case IDCANCEL: pDlg->mn_DlgRc = IDCANCEL; EndDialog(hDlg, IDCANCEL); return 1; } } else if ((HIWORD(wParam) == EN_SETFOCUS) && lParam) { switch (LOWORD(wParam)) { case tRecreateSplit: case tRunAsPassword: PostMessage((HWND)lParam, EM_SETSEL, 0, SendMessage((HWND)lParam, WM_GETTEXTLENGTH, 0,0)); break; } } break; default: return 0; }
int main( int argc, char *argv[] ) { cout << "*** ImapLibrary Test ***" << endl; cout << "Connect to imap.gmail.com at port 993..." << endl; imap_server = "imap.gmail.com"; // Nombre servidor IMAP port_n = 993; // 143 || 993 con encriptación SSL cout << "Write your username: "******"Write your pass: "******"********** IMAPLogin **********" << endl; // DEBUG i = IMAPLogin(connection, imap_server, port_n, user, pass, usessl); if (i == BAD_LOGIN) { printf("Bad login: %d\n", i); return -1; } if (i == SERVER_NOT_READY_FOR_CONNECTION) { printf("Server not ready for connection: %d\n", i); return -1; } /** * Get folder list from server * - we need to get a list of folder names */ cout << endl << "********** getIMAPFolders **********" << endl; // DEBUG list<string> folder_names; folder_root = ""; // Nombre del buzón de correo que queremos que liste int return_code; return_code = getIMAPFolders(connection, folder_names, folder_root ); cout << endl << "-------------------------------------" << endl; // DEBUG cout << "-----------List of Folders-----------" << endl; // DEBUG cout << "-------------------------------------" << endl; // DEBUG cout << folder_root << "/"<< endl; // DEBUG if( return_code == SUCCESS ) { // Successful create_folder_list(folder_names); } // DEBUG - Show folder_list list<Folder>::iterator itera = folder_list.begin(); while(itera != folder_list.end()) { //cout << "folder: " << (*itera).get_Folder_Name() << endl; //cout << " -> full_name= " << (*itera).get_Full_Folder_Name() << endl; //cout << " -> seq_start= " << (*itera).get_Sequence_Start() << endl; //cout << " -> seq_stop = " << (*itera).get_Sequence_Stop() << endl; //cout << " -> num_mess = " << (*itera).get_Num_Messages() << endl; if (strcmp("INBOX", (char*) (*itera).get_Folder_Name().c_str()) == 0) break; itera++; } /** * Select a folder * - In order to get the emails of a folder, we must select it before. */ string folderOpenStatus; int numMessages; //itera = folder_list.begin(); cout << endl << "********** SelectFolders **********" << endl; // DEBUG cout << "Folder name: " << (*itera).get_Folder_Name() << endl; // DEBUG cout << "Full folder name: " << (*itera).get_Full_Folder_Name() << endl;// DEBUG i = SelectFolder(connection, (*itera).get_Folder_Name(), numMessages, folderOpenStatus); if (i == UNKNOWN_MAILBOX) printf("Unknown mailbox - %d\n",i); cout << "numMessages = " << numMessages << " |folderOpenStatus = " << folderOpenStatus << endl;// DEBUG /** * Get new emails * - We must select a folder before or the function return us a failure */ printf("\n\n********************************************\n"); cout << "Folder name: " << (*itera).get_Folder_Name() << endl; cout << "Full folder name: " << (*itera).get_Folder_Name() << endl; i = GetNewMail(connection, (*itera)); if (i>BEG_FAIL || i==LIST_FAILED || i== FOLDER_NOT_EXIST) { printf("GetNewMail Error - %d\n",i); return -1; } int Message_id = 2; // Message identifier Message *email = (*itera).get_Message(Message_id); // Para obtener cuerpo de un email a partir de su uid, // primero necesitamos coger uno de la lista (orden por id) if (email != NULL) { cout << "From: " << email->get_From_Address() << endl; // DEBUG //cout << "Have body? " << email->have_Body_Text() << endl; // DEBUG //cout << "Date: " << email->get_Date() << endl; // DEBUG cout << "Subject: " << email->get_Subject() << endl; // DEBUG //cout << "UID: " << email->get_UID() << endl; // DEBUG //cout << "-------------------------------" << endl; // DEBUG i=email->get_Body_From_Server(connection); //cout << "getbodyfromserver=" << i << endl; // DEBUG //cout << "Have body? " << email->have_Body_Text() << endl; // DEBUG if (email->have_Body_Text() == 1) cout << "BODY: " << email->get_Body_Text(); // DEBUG } else cout << "The message does not exist." << endl; /** * Logout * - Finalize the session */ i = IMAPLogout(connection); if (i != SUCCESS) { cout << "An error ocurred" << endl; return -1; } return 0; }
INT_PTR CALLBACK ChooseMethodHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: { if (LOWORD(wParam) == ID_METHOD_BACK) { UpdateGlobalPosition(hDlg); EndDialog(hDlg, (INT_PTR)DisplayWelcome); return (INT_PTR)TRUE; } else if (LOWORD(wParam) == ID_METHOD_EXIT || LOWORD(wParam) == ID_CLOSE) { return AskToExit(hDlg); } else if (LOWORD(wParam) == IDC_METHOD_DED_SERVER || LOWORD(wParam) == IDC_METHOD_ALONE_SERVER || LOWORD(wParam) == IDC_METHOD_LISTEN_SERVER || LOWORD(wParam) == IDC_METHOD_UPLOAD_FTP || LOWORD(wParam) == IDC_METHOD_CUSTOM_FOLDER) { method_chosen = LOWORD(wParam); HWND button = GetDlgItem(hDlg, ID_METHOD_NEXT); EnableWindow(button, TRUE); break; } else if (LOWORD(wParam) == ID_METHOD_NEXT) { unsigned int game_type = 0; switch (method_chosen) { case IDC_METHOD_DED_SERVER: { game_type = GAMES_DEDICATED; break; } case IDC_METHOD_ALONE_SERVER: { game_type = GAMES_STANDALONE; break; } case IDC_METHOD_LISTEN_SERVER: { game_type = GAMES_LISTEN; break; } case IDC_METHOD_UPLOAD_FTP: { break; } case IDC_METHOD_CUSTOM_FOLDER: { int val; if (!SelectFolder(hDlg)) { break; } val = IsValidFolder(method_path); if (val != GAMEINFO_IS_USABLE) { DisplayBadFolderDialog(hDlg, val); break; } g_LocalCopier.SetOutputPath(method_path); SetInstallMethod(&g_LocalCopier); UpdateGlobalPosition(hDlg); EndDialog(hDlg, (INT_PTR)DisplayPerformInstall); } } if (game_type != 0) { g_game_group = NULL; BuildGameDB(); if (game_type == GAMES_DEDICATED) { g_game_group = &g_games.dedicated; } else if (game_type == GAMES_LISTEN) { g_game_group = &g_games.listen; } else if (game_type == GAMES_STANDALONE) { g_game_group = &g_games.standalone; } if (g_game_group == NULL) { return (INT_PTR)TRUE; } if (g_game_group->list_count == 0) { DisplayBadGamesDialog(hDlg, g_game_group->error_code); return (INT_PTR)TRUE; } /* If we got a valid games list, we can display the next * dialog box. */ UpdateGlobalPosition(hDlg); EndDialog(hDlg, (INT_PTR)DisplaySelectGame); return (INT_PTR)TRUE; } } break; } case WM_INITDIALOG: { SetToGlobalPosition(hDlg); return (INT_PTR)TRUE; } } return (INT_PTR)FALSE; }
void FilesystemWidget::ShowContextMenu(const QPoint&) { auto* selection = m_tree_view->selectionModel(); if (!selection->hasSelection()) return; auto* item = m_tree_model->itemFromIndex(selection->selectedIndexes()[0]); QMenu* menu = new QMenu(this); EntryType type = item->data(ENTRY_TYPE).value<EntryType>(); DiscIO::Partition partition = type == EntryType::Disc ? DiscIO::PARTITION_NONE : GetPartitionFromID(item->data(ENTRY_PARTITION).toInt()); QString path = item->data(ENTRY_NAME).toString(); const bool is_filesystem_root = (type == EntryType::Disc && m_volume->GetPartitions().empty()) || type == EntryType::Partition; if (type == EntryType::Dir || is_filesystem_root) { AddAction(menu, tr("Extract Files..."), this, [this, partition, path] { auto folder = SelectFolder(); if (!folder.isEmpty()) ExtractDirectory(partition, path, folder); }); } if (is_filesystem_root) { AddAction(menu, tr("Extract System Data..."), this, [this, partition] { auto folder = SelectFolder(); if (folder.isEmpty()) return; if (ExtractSystemData(partition, folder)) QMessageBox::information(nullptr, tr("Success"), tr("Successfully extracted system data.")); else QMessageBox::critical(nullptr, tr("Error"), tr("Failed to extract system data.")); }); } switch (type) { case EntryType::Disc: AddAction(menu, tr("Extract Entire Disc..."), this, [this, path] { auto folder = SelectFolder(); if (folder.isEmpty()) return; if (m_volume->GetPartitions().empty()) { ExtractPartition(DiscIO::PARTITION_NONE, folder); } else { for (DiscIO::Partition& p : m_volume->GetPartitions()) { if (const std::optional<u32> partition_type = m_volume->GetPartitionType(p)) { const std::string partition_name = DiscIO::DirectoryNameForPartitionType(*partition_type); ExtractPartition(p, folder + QChar(u'/') + QString::fromStdString(partition_name)); } } } }); break; case EntryType::Partition: AddAction(menu, tr("Extract Entire Partition..."), this, [this, partition] { auto folder = SelectFolder(); if (!folder.isEmpty()) ExtractPartition(partition, folder); }); if (m_volume->IsEncryptedAndHashed()) { menu->addSeparator(); AddAction(menu, tr("Check Partition Integrity"), this, [this, partition] { CheckIntegrity(partition); }); } break; case EntryType::File: AddAction(menu, tr("Extract File..."), this, [this, partition, path] { auto dest = QFileDialog::getSaveFileName(this, tr("Save File to")); if (!dest.isEmpty()) ExtractFile(partition, path, dest); }); break; case EntryType::Dir: // Handled above the switch statement break; } menu->exec(QCursor::pos()); }