2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 #define WM_PROCESSTASK 0x8008
40 void push_task(task_t *task)
42 thread_data_t *thread_data = get_thread_data(TRUE);
44 if(thread_data->task_queue_tail)
45 thread_data->task_queue_tail->next = task;
47 thread_data->task_queue_head = task;
49 thread_data->task_queue_tail = task;
51 PostMessageW(thread_data->thread_hwnd, WM_PROCESSTASK, 0, 0);
54 static task_t *pop_task(void)
56 thread_data_t *thread_data = get_thread_data(TRUE);
57 task_t *task = thread_data->task_queue_head;
62 thread_data->task_queue_head = task->next;
63 if(!thread_data->task_queue_head)
64 thread_data->task_queue_tail = NULL;
69 void remove_doc_tasks(HTMLDocument *doc)
71 thread_data_t *thread_data = get_thread_data(FALSE);
74 while(thread_data->task_queue_head
75 && thread_data->task_queue_head->doc == doc)
78 for(iter = thread_data->task_queue_head; iter; iter = iter->next) {
79 while(iter->next && iter->next->doc == doc) {
81 iter->next = tmp->next;
86 thread_data->task_queue_tail = iter;
90 static void set_downloading(HTMLDocument *doc)
92 IOleCommandTarget *olecmd;
98 IOleInPlaceFrame_SetStatusText(doc->frame, NULL /* FIXME */);
103 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
104 if(SUCCEEDED(hres)) {
110 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE, OLECMDEXECOPT_DONTPROMPTUSER,
112 IOleCommandTarget_Release(olecmd);
116 IDropTarget *drop_target = NULL;
118 hres = IDocHostUIHandler_GetDropTarget(doc->hostui, NULL /* FIXME */, &drop_target);
120 FIXME("Use IDropTarget\n");
121 IDropTarget_Release(drop_target);
126 static void set_parsecomplete(HTMLDocument *doc)
128 IOleCommandTarget *olecmd;
131 TRACE("(%p)\n", doc);
133 call_property_onchanged(doc->cp_propnotif, 1005);
134 call_property_onchanged(doc->cp_propnotif, DISPID_READYSTATE);
139 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
140 if(SUCCEEDED(hres)) {
141 VARIANT state, title, progress;
144 V_VT(&progress) = VT_I4;
146 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS, OLECMDEXECOPT_DONTPROMPTUSER,
149 V_VT(&state) = VT_I4;
151 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE, OLECMDEXECOPT_DONTPROMPTUSER,
154 IOleCommandTarget_Exec(olecmd, &CGID_MSHTML, IDM_PARSECOMPLETE, 0, NULL, NULL);
155 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_HTTPEQUIV_DONE, 0, NULL, NULL);
157 V_VT(&title) = VT_BSTR;
158 V_BSTR(&title) = SysAllocString(empty);
159 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER,
161 SysFreeString(V_BSTR(&title));
163 IOleCommandTarget_Release(olecmd);
167 static void process_task(task_t *task)
169 switch(task->task_id) {
170 case TASK_SETDOWNLOADSTATE:
171 return set_downloading(task->doc);
172 case TASK_PARSECOMPLETE:
173 return set_parsecomplete(task->doc);
175 ERR("Wrong task_id %d\n", task->task_id);
179 static LRESULT WINAPI hidden_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
184 task_t *task = pop_task();
196 FIXME("(%p %d %x %lx)\n", hwnd, msg, wParam, lParam);
198 return DefWindowProcW(hwnd, msg, wParam, lParam);
201 static HWND create_thread_hwnd(void)
203 static ATOM hidden_wnd_class = 0;
204 static const WCHAR wszInternetExplorer_Hidden[] = {'I','n','t','e','r','n','e','t',
205 ' ','E','x','p','l','o','r','e','r','_','H','i','d','d','e','n',0};
207 if(!hidden_wnd_class) {
208 WNDCLASSEXW wndclass = {
209 sizeof(WNDCLASSEXW), 0,
211 0, 0, hInst, NULL, NULL, NULL, NULL,
212 wszInternetExplorer_Hidden,
216 hidden_wnd_class = RegisterClassExW(&wndclass);
219 return CreateWindowExW(0, wszInternetExplorer_Hidden, NULL, WS_POPUP,
220 0, 0, 0, 0, NULL, NULL, hInst, NULL);
223 HWND get_thread_hwnd(void)
225 thread_data_t *thread_data = get_thread_data(TRUE);
227 if(!thread_data->thread_hwnd)
228 thread_data->thread_hwnd = create_thread_hwnd();
230 return thread_data->thread_hwnd;
233 thread_data_t *get_thread_data(BOOL create)
235 thread_data_t *thread_data;
239 mshtml_tls = TlsAlloc();
244 thread_data = TlsGetValue(mshtml_tls);
245 if(!thread_data && create) {
246 thread_data = mshtml_alloc_zero(sizeof(thread_data_t));
247 TlsSetValue(mshtml_tls, thread_data);