static HRESULT get_doc_string(HTMLDocumentNode *This, char **str) { nsIDOMNode *nsnode; LPCWSTR strw; nsAString nsstr; nsresult nsres; if(!This->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; } nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode); if(NS_FAILED(nsres)) { ERR("Could not get nsIDOMNode failed: %08x\n", nsres); return E_FAIL; } nsAString_Init(&nsstr, NULL); nsnode_to_nsstring(nsnode, &nsstr); nsIDOMNode_Release(nsnode); nsAString_GetData(&nsstr, &strw); TRACE("%s\n", debugstr_w(strw)); *str = heap_strdupWtoA(strw); nsAString_Finish(&nsstr); return S_OK; }
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) { LPVOID lpvNewInfo = NULL; if( !hdr->lpfnStatusCB ) return; /* the IE5 version of wininet does not send callbacks if dwContext is zero */ if( !dwContext ) return; lpvNewInfo = lpvStatusInfo; if(hdr->dwInternalFlags & INET_CALLBACKW) { switch(dwInternetStatus) { case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER: lpvNewInfo = heap_strdupAtoW(lpvStatusInfo); dwStatusInfoLength *= sizeof(WCHAR); break; case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT: lpvNewInfo = heap_strdupW(lpvStatusInfo); break; } }else { switch(dwInternetStatus) { case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER: lpvNewInfo = heap_alloc(strlen(lpvStatusInfo) + 1); if (lpvNewInfo) strcpy(lpvNewInfo, lpvStatusInfo); break; case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT: lpvNewInfo = heap_strdupWtoA(lpvStatusInfo); dwStatusInfoLength /= sizeof(WCHAR); break; } } TRACE(" callback(%p) (%p (%p), %08lx, %d (%s), %p, %d)\n", hdr->lpfnStatusCB, hdr->hInternet, hdr, dwContext, dwInternetStatus, get_callback_name(dwInternetStatus), lpvNewInfo, dwStatusInfoLength); hdr->lpfnStatusCB(hdr->hInternet, dwContext, dwInternetStatus, lpvNewInfo, dwStatusInfoLength); TRACE(" end callback().\n"); if(lpvNewInfo != lpvStatusInfo) HeapFree(GetProcessHeap(), 0, lpvNewInfo); }
static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) { TRACE("(%p)->(%p %p)\n", This, in, out); if(!This->doc_obj->nscontainer) { update_doc(This, UPDATE_UI); return E_FAIL; } if(in) { char *stra; if(V_VT(in) != VT_BSTR) { FIXME("Unsupported fontname %s\n", debugstr_variant(out)); return E_INVALIDARG; } TRACE("%s\n", debugstr_w(V_BSTR(in))); stra = heap_strdupWtoA(V_BSTR(in)); set_ns_fontname(This, stra); heap_free(stra); update_doc(This, UPDATE_UI); } if(out) { nsICommandParams *nsparam; LPWSTR strw; char *stra; DWORD len; nsresult nsres; V_VT(out) = VT_BSTR; V_BSTR(out) = NULL; nsparam = create_nscommand_params(); nsres = get_ns_command_state(This->doc_obj->nscontainer, NSCMD_FONTFACE, nsparam); if(NS_FAILED(nsres)) return S_OK; nsICommandParams_GetCStringValue(nsparam, NSSTATE_ATTRIBUTE, &stra); nsICommandParams_Release(nsparam); len = MultiByteToWideChar(CP_ACP, 0, stra, -1, NULL, 0); strw = heap_alloc(len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, stra, -1, strw, len); nsfree(stra); V_BSTR(out) = SysAllocString(strw); heap_free(strw); } return S_OK; }
/*********************************************************************** * ExtractFilesW (ADVPACK.@) * * Extracts the specified files from a cab archive into * a destination directory. * * PARAMS * CabName [I] Filename of the cab archive. * ExpandDir [I] Destination directory for the extracted files. * Flags [I] Reserved. * FileList [I] Optional list of files to extract. See NOTES. * LReserved [I] Reserved. Must be NULL. * Reserved [I] Reserved. Must be 0. * * RETURNS * Success: S_OK. * Failure: E_FAIL. * * NOTES * FileList is a colon-separated list of filenames. If FileList is * non-NULL, only the files in the list will be extracted from the * cab file, otherwise all files will be extracted. Any number of * spaces, tabs, or colons can be before or after the list, but * the list itself must only be separated by colons. * * BUGS * Unimplemented. */ HRESULT WINAPI ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags, LPCWSTR FileList, LPVOID LReserved, DWORD Reserved) { char *cab_name = NULL, *expand_dir = NULL, *file_list = NULL; HRESULT hres = S_OK; TRACE("(%s, %s, %d, %s, %p, %d)\n", debugstr_w(CabName), debugstr_w(ExpandDir), Flags, debugstr_w(FileList), LReserved, Reserved); if(CabName) { cab_name = heap_strdupWtoA(CabName); if(!cab_name) return E_OUTOFMEMORY; } if(ExpandDir) { expand_dir = heap_strdupWtoA(ExpandDir); if(!expand_dir) hres = E_OUTOFMEMORY; } if(SUCCEEDED(hres) && FileList) { file_list = heap_strdupWtoA(FileList); if(!file_list) hres = E_OUTOFMEMORY; } /* cabinet.dll, which does the real job of extracting files, doesn't have UNICODE API, so we need W->A conversion at some point anyway. */ if(SUCCEEDED(hres)) hres = ExtractFilesA(cab_name, expand_dir, Flags, file_list, LReserved, Reserved); heap_free(cab_name); heap_free(expand_dir); heap_free(file_list); return hres; }
static BOOL install_cab(LPCWSTR file_name) { HMODULE advpack; char install_dir[MAX_PATH]; HRESULT (WINAPI *pExtractFilesA)(LPCSTR,LPCSTR,DWORD,LPCSTR,LPVOID,DWORD); LPSTR file_name_a; DWORD res; HRESULT hres; static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0}; TRACE("(%s)\n", debugstr_w(file_name)); GetWindowsDirectoryA(install_dir, sizeof(install_dir)); strcat(install_dir, "\\gecko\\"); res = CreateDirectoryA(install_dir, NULL); if(!res && GetLastError() != ERROR_ALREADY_EXISTS) { ERR("Could not create directory: %08u\n", GetLastError()); return FALSE; } strcat(install_dir, GECKO_VERSION); res = CreateDirectoryA(install_dir, NULL); if(!res && GetLastError() != ERROR_ALREADY_EXISTS) { ERR("Could not create directory: %08u\n", GetLastError()); return FALSE; } advpack = LoadLibraryW(wszAdvpack); pExtractFilesA = (void *)GetProcAddress(advpack, "ExtractFiles"); /* FIXME: Use unicode version (not yet implemented) */ file_name_a = heap_strdupWtoA(file_name); hres = pExtractFilesA(file_name_a, install_dir, 0, NULL, NULL, 0); FreeLibrary(advpack); heap_free(file_name_a); if(FAILED(hres)) { ERR("Could not extract package: %08x\n", hres); clean_up(); return FALSE; } set_registry(install_dir); clean_up(); return TRUE; }
void INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR context, DWORD status, void *info, DWORD info_len) { void *new_info = info; if( !hdr->lpfnStatusCB ) return; /* the IE5 version of wininet does not send callbacks if dwContext is zero */ if(!context) return; switch(status) { case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER: new_info = heap_alloc(info_len); if(new_info) memcpy(new_info, info, info_len); break; case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT: if(hdr->dwInternalFlags & INET_CALLBACKW) { new_info = heap_strdupW(info); break; }else { new_info = heap_strdupWtoA(info); info_len = strlen(new_info)+1; break; } } TRACE(" callback(%p) (%p (%p), %08lx, %d (%s), %s, %d)\n", hdr->lpfnStatusCB, hdr->hInternet, hdr, context, status, get_callback_name(status), debugstr_status_info(status, new_info), info_len); hdr->lpfnStatusCB(hdr->hInternet, context, status, new_info, info_len); TRACE(" end callback().\n"); if(new_info != info) heap_free(new_info); }