nsFileChannel::nsFileChannel(nsIURI *uri) { // If we have a link file, we should resolve its target right away. // This is to protect against a same origin attack where the same link file // can point to different resources right after the first resource is loaded. nsCOMPtr<nsIFile> file; nsCOMPtr <nsIURI> targetURI; nsAutoCString fileTarget; nsCOMPtr<nsIFile> resolvedFile; bool symLink; nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri); if (fileURL && NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) && NS_SUCCEEDED(file->IsSymlink(&symLink)) && symLink && NS_SUCCEEDED(file->GetNativeTarget(fileTarget)) && NS_SUCCEEDED(NS_NewNativeLocalFile(fileTarget, PR_TRUE, getter_AddRefs(resolvedFile))) && NS_SUCCEEDED(NS_NewFileURI(getter_AddRefs(targetURI), resolvedFile, nullptr))) { SetURI(targetURI); SetOriginalURI(uri); nsLoadFlags loadFlags = 0; GetLoadFlags(&loadFlags); SetLoadFlags(loadFlags | nsIChannel::LOAD_REPLACE); } else { SetURI(uri); } }
LRESULT MainDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { HKL hKl; switch (Msg) { case WM_INITDIALOG: { WCHAR Buf[255]; UpdateData(hDlg); hMainDlg = hDlg; SubclassWnd(GetDlgItem(hDlg, IDC_LIST), L"List"); SubclassWnd(GetDlgItem(hDlg, IDC_EDIT1), L"Edit1"); SubclassWnd(GetDlgItem(hDlg, IDC_KLID), L"Klid"); SubclassWnd(GetDlgItem(hDlg, ID_CANCEL), L"CancelB"); SubclassWnd(GetDlgItem(hDlg, IDC_ACTIVATE), L"ActivateB"); SubclassWnd(GetDlgItem(hDlg, IDC_REFRESH), L"RefreshB"); SubclassWnd(GetDlgItem(hDlg, IDC_UNLOAD), L"UnloadB"); SubclassWnd(GetDlgItem(hDlg, IDC_LOAD), L"LoadB"); CheckRadioButton(hDlg, IDC_FROMLIST, IDC_FROMEDIT, IDC_FROMLIST); SetWindowText(GetDlgItem(hDlg, IDC_KLID), L"00000419"); swprintf(Buf, L"Current thread id: %d", GetCurrentThreadId()); SetWindowText(GetDlgItem(hDlg, IDC_CURTHREAD), Buf); SetWindowText(GetDlgItem(hDlg, IDC_DELAY), L"0"); return 0; } /* WM_INITDIALOG */ case WM_COMMAND: { switch(LOWORD(wParam)) { case ID_CANCEL: { EndDialog(hDlg, ERROR_CANCELLED); break; } case IDC_ACTIVATE: { if((hKl = GetActivateHandle(hDlg)) != INVALID_HANDLE_VALUE) { Sleep(GetDelayMilliseconds(hDlg)); if(!(hKl = ActivateKeyboardLayout(hKl, GetActivateFlags(hDlg)))) FormatBox(hDlg, MB_ICONERROR, L"Error", L"ActivateKeyboardLayout() failed. %d", GetLastError()); else UpdateData(hDlg); //FormatBox(hDlg, 0, L"Activated", L"Prev - %x, err - %d.", hKl, // GetLastError()); } else MessageBox(hDlg, L"No item selected", L"Error", MB_ICONERROR); break; } case IDC_UNLOAD: { if((hKl = GetSelectedLayout(hDlg)) != INVALID_HANDLE_VALUE) { Sleep(GetDelayMilliseconds(hDlg)); if(!UnloadKeyboardLayout(hKl)) FormatBox(hDlg, MB_ICONERROR, L"Error", L"UnloadKeyboardLayout() failed. %d", GetLastError()); else UpdateData(hDlg); } else MessageBox(hDlg, L"No item selected", L"Error", MB_ICONERROR); break; } case IDC_LOAD: { WCHAR buf[255]; GetWindowText(GetDlgItem(hDlg, IDC_KLID), buf, sizeof(buf)); Sleep(GetDelayMilliseconds(hDlg)); if(!LoadKeyboardLayout(buf, GetLoadFlags(hDlg))) FormatBox(hDlg, MB_ICONERROR, L"Error", L"LoadKeyboardLayout() failed. %d", GetLastError()); else UpdateData(hDlg); break; } case IDC_REFRESH: { UpdateData(hDlg); break; } case IDC_NEWTHREAD: { if(!CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL)) { FormatBox(hDlg, MB_ICONERROR, L"Error!", L"Can not create thread (%d).", GetLastError()); } } case IDC_LIST: { if(HIWORD(wParam) == LBN_SELCHANGE) { WCHAR buf[25]; if((hKl = GetSelectedLayout(hDlg)) != NULL) { swprintf(buf, L"%x", hKl); SetWindowText(GetDlgItem(hDlg, IDC_HANDLE), buf); } } break; } } return TRUE; } /* WM_COMMAND */ case WM_INPUTLANGCHANGE: { FormatMsg(L"dlg WM_INPUTLANGCHANGE lParam=%x wParam=%x\n", lParam, wParam); return FALSE; } case WM_INPUTLANGCHANGEREQUEST: { FormatMsg(L"dlg WM_INPUTLANGCHANGEREQUEST lParam=%x wParam=%x\n", lParam, wParam); UpdateData(hDlg); return FALSE; } case WM_CLOSE: { EndDialog(hDlg, ERROR_CANCELLED); return TRUE; } /* WM_CLOSE */ default: return FALSE; } }