OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginClass.h" | 3 #include "PluginClass.h" |
4 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
5 #include "PluginSystem.h" | 5 #include "PluginSystem.h" |
6 #ifdef SUPPORT_FILTER | 6 #ifdef SUPPORT_FILTER |
7 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
8 #endif | 8 #endif |
9 #include "PluginMimeFilterClient.h" | 9 #include "PluginMimeFilterClient.h" |
10 #include "PluginClient.h" | 10 #include "PluginClient.h" |
11 #include "PluginClientFactory.h" | 11 #include "PluginClientFactory.h" |
12 #include "PluginHttpRequest.h" | |
13 #include "PluginMutex.h" | 12 #include "PluginMutex.h" |
14 #include "DownloadSource.h" | |
15 #include "sddl.h" | 13 #include "sddl.h" |
16 #include "PluginUtil.h" | 14 #include "PluginUtil.h" |
17 #include "PluginUserSettings.h" | 15 #include "PluginUserSettings.h" |
18 | 16 |
19 #include "../shared/Dictionary.h" | 17 #include "../shared/Dictionary.h" |
20 | 18 |
21 #ifdef DEBUG_HIDE_EL | 19 #ifdef DEBUG_HIDE_EL |
22 DWORD profileTime = 0; | 20 DWORD profileTime = 0; |
23 #endif | 21 #endif |
24 | 22 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 m_hStatusBarWnd = NULL; | 63 m_hStatusBarWnd = NULL; |
66 m_hPaneWnd = NULL; | 64 m_hPaneWnd = NULL; |
67 m_nPaneWidth = 0; | 65 m_nPaneWidth = 0; |
68 m_pWndProcStatus = NULL; | 66 m_pWndProcStatus = NULL; |
69 m_hTheme = NULL; | 67 m_hTheme = NULL; |
70 m_isInitializedOk = false; | 68 m_isInitializedOk = false; |
71 | 69 |
72 | 70 |
73 m_tab = new CPluginTab(this); | 71 m_tab = new CPluginTab(this); |
74 | 72 |
75 // Load / create settings | 73 // Load settings (fetch the available subscriptions, if still not fetched) |
76 CPluginSettings* settings = CPluginSettings::GetInstance(); | 74 CPluginSettings* settings = CPluginSettings::GetInstance(); |
77 | 75 |
78 CPluginSystem* system = CPluginSystem::GetInstance(); | 76 CPluginSystem* system = CPluginSystem::GetInstance(); |
79 | 77 |
80 std::wstring locale((LPCWSTR)system->GetBrowserLanguage()); | 78 std::wstring locale((LPCWSTR)system->GetBrowserLanguage()); |
81 Dictionary::Create(locale); | 79 Dictionary::Create(locale); |
82 | |
83 bool isMainTab = settings->IncrementTabCount(); | |
84 | |
85 if (isMainTab) | |
86 { | |
87 // Prepare settings | |
88 settings->SetMainProcessId(); | |
89 settings->SetMainUiThreadId(); | |
90 | |
91 // Ensure plugin version | |
92 if (!settings->Has(SETTING_PLUGIN_VERSION)) | |
93 { | |
94 settings->SetString(SETTING_PLUGIN_VERSION, IEPLUGIN_VERSION); | |
95 settings->SetFirstRunUpdate(); | |
96 } | |
97 | |
98 // First run or deleted settings file (dictionary version = 1) | |
99 if (settings->GetString(SETTING_DICTIONARY_VERSION, L"1").Compare(L"1") == 0
) | |
100 { | |
101 settings->SetFirstRun(); | |
102 } | |
103 | |
104 // Update? | |
105 CString oldVersion = settings->GetString(SETTING_PLUGIN_VERSION); | |
106 if (settings->IsFirstRunUpdate() || settings->GetString(SETTING_PLUGIN_UPDAT
E_VERSION) == IEPLUGIN_VERSION || oldVersion != IEPLUGIN_VERSION) | |
107 { | |
108 settings->SetString(SETTING_PLUGIN_VERSION, IEPLUGIN_VERSION); | |
109 | |
110 settings->SetFirstRunUpdate(); | |
111 } | |
112 | |
113 int info = settings->GetValue(SETTING_PLUGIN_INFO_PANEL, 0); | |
114 | |
115 #ifdef ENABLE_DEBUG_RESULT | |
116 CPluginDebug::DebugResultClear(); | |
117 #endif | |
118 | |
119 #ifdef ENABLE_DEBUG_INFO | |
120 if (info == 0 || info > 2) | |
121 { | |
122 CPluginDebug::DebugClear(); | |
123 } | |
124 #endif // ENABLE_DEBUG_INFO | |
125 | |
126 settings->Write(false); | |
127 } | |
128 } | 80 } |
129 | 81 |
130 CPluginClass::~CPluginClass() | 82 CPluginClass::~CPluginClass() |
131 { | 83 { |
132 delete m_tab; | 84 delete m_tab; |
133 | |
134 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
135 | |
136 settings->DecrementTabCount(); | |
137 } | 85 } |
138 | 86 |
139 | 87 |
140 ///////////////////////////////////////////////////////////////////////////// | 88 ///////////////////////////////////////////////////////////////////////////// |
141 // Initialization | 89 // Initialization |
142 | 90 |
143 HRESULT CPluginClass::FinalConstruct() | 91 HRESULT CPluginClass::FinalConstruct() |
144 { | 92 { |
145 return S_OK; | 93 return S_OK; |
146 } | 94 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 207 } |
260 } | 208 } |
261 else | 209 else |
262 { | 210 { |
263 url = m_tab->GetDocumentUrl(); | 211 url = m_tab->GetDocumentUrl(); |
264 } | 212 } |
265 | 213 |
266 return url; | 214 return url; |
267 } | 215 } |
268 | 216 |
269 void CPluginClass::LaunchUpdater(const CString& strPath) | |
270 { | |
271 PROCESS_INFORMATION pi; | |
272 ::ZeroMemory(&pi, sizeof(pi)); | |
273 | |
274 STARTUPINFO si; | |
275 ::ZeroMemory(&si, sizeof(si)); | |
276 si.cb = sizeof(si); | |
277 si.wShowWindow = FALSE; | |
278 CString cpath; | |
279 if (strPath.Find(L".exe") == strPath.GetLength() - 4) | |
280 { | |
281 cpath = strPath; | |
282 } | |
283 else | |
284 { | |
285 cpath = _T("\"msiexec.exe\" /i \"") + strPath + _T("\" UPDATEPLUGIN=\"True\"
"); | |
286 } | |
287 | |
288 if (!::CreateProcess(NULL, cpath.GetBuffer(), NULL, NULL, FALSE, CREATE_BREAKA
WAY_FROM_JOB, NULL, NULL, &si, &pi)) | |
289 { | |
290 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UPDATER, PLUGIN_ERROR_UPDATER
_CREATE_PROCESS, "Class::Updater - Failed to start process"); | |
291 return; | |
292 } | |
293 #ifndef AUTOMATIC_SHUTDOWN | |
294 else | |
295 { | |
296 ::WaitForSingleObject(pi.hProcess, INFINITE); | |
297 } | |
298 #endif // not AUTOMATIC_SHUTDOWN | |
299 | |
300 ::CloseHandle(pi.hProcess); | |
301 ::CloseHandle(pi.hThread); | |
302 } | |
303 | |
304 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 217 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
305 { | 218 { |
306 if (thisPtr == NULL) | 219 if (thisPtr == NULL) |
307 return 0; | 220 return 0; |
308 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 221 if (!((CPluginClass*)thisPtr)->InitObject(true)) |
309 { | 222 { |
310 ((CPluginClass*)thisPtr)->Unadvice(); | 223 ((CPluginClass*)thisPtr)->Unadvice(); |
311 } | 224 } |
312 | 225 |
313 if ((((CPluginClass*)thisPtr)->m_hPaneWnd == NULL) || (!((CPluginClass*)thisPt
r)->IsStatusBarEnabled())) | 226 if ((((CPluginClass*)thisPtr)->m_hPaneWnd == NULL) || (!((CPluginClass*)thisPt
r)->IsStatusBarEnabled())) |
(...skipping 12 matching lines...) Expand all Loading... |
326 // so we should handle that it is called this way several times during a session | 239 // so we should handle that it is called this way several times during a session |
327 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 240 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
328 { | 241 { |
329 CPluginSettings* settings = CPluginSettings::GetInstance(); | 242 CPluginSettings* settings = CPluginSettings::GetInstance(); |
330 CPluginSystem* system = CPluginSystem::GetInstance(); | 243 CPluginSystem* system = CPluginSystem::GetInstance(); |
331 | 244 |
332 MULTIPLE_VERSIONS_CHECK(); | 245 MULTIPLE_VERSIONS_CHECK(); |
333 | 246 |
334 if (unknownSite) | 247 if (unknownSite) |
335 { | 248 { |
336 if (settings->IsMainProcess() && settings->IsMainUiThread()) | 249 DEBUG_GENERAL(L"============================================================
====================\nNEW TAB UI\n==============================================
==================================") |
337 { | |
338 DEBUG_GENERAL(L"==========================================================
======================\nMAIN TAB UI\n===========================================
=====================================") | |
339 } | |
340 else | |
341 { | |
342 DEBUG_GENERAL(L"==========================================================
======================\nNEW TAB UI\n============================================
====================================") | |
343 } | |
344 | 250 |
345 HRESULT hr = ::CoInitialize(NULL); | 251 HRESULT hr = ::CoInitialize(NULL); |
346 if (FAILED(hr)) | 252 if (FAILED(hr)) |
347 { | 253 { |
348 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "
Class::SetSite - CoInitialize"); | 254 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "
Class::SetSite - CoInitialize"); |
349 } | 255 } |
350 | 256 |
351 s_criticalSectionBrowser.Lock(); | 257 s_criticalSectionBrowser.Lock(); |
352 { | 258 { |
353 m_webBrowser2 = unknownSite; | 259 m_webBrowser2 = unknownSite; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 m_hStatusBarWnd = NULL; | 364 m_hStatusBarWnd = NULL; |
459 | 365 |
460 // Remove instance from the list, shutdown threads | 366 // Remove instance from the list, shutdown threads |
461 HANDLE hMainThread = NULL; | 367 HANDLE hMainThread = NULL; |
462 HANDLE hTabThread = NULL; | 368 HANDLE hTabThread = NULL; |
463 | 369 |
464 s_criticalSectionLocal.Lock(); | 370 s_criticalSectionLocal.Lock(); |
465 { | 371 { |
466 s_instances.Remove(this); | 372 s_instances.Remove(this); |
467 | 373 |
468 if (s_instances.GetSize() == 0) | |
469 { | |
470 if (settings->IsMainProcess() && settings->IsMainUiThread()) | |
471 { | |
472 hMainThread = s_hMainThread; | |
473 s_hMainThread = NULL; | |
474 } | |
475 } | |
476 | |
477 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC
urrentThreadId()); | 374 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC
urrentThreadId()); |
478 if (it != s_threadInstances.end()) | 375 if (it != s_threadInstances.end()) |
479 { | 376 { |
480 s_threadInstances.erase(it); | 377 s_threadInstances.erase(it); |
481 } | 378 } |
482 if (s_instances.GetSize() == 0) | 379 if (s_instances.GetSize() == 0) |
483 { | 380 { |
484 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | 381 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
485 } | 382 } |
486 } | 383 } |
487 s_criticalSectionLocal.Unlock(); | 384 s_criticalSectionLocal.Unlock(); |
488 | 385 |
489 if (hMainThread != NULL) | |
490 { | |
491 s_isMainThreadDone = true; | |
492 | |
493 ::WaitForSingleObject(hMainThread, INFINITE); | |
494 ::CloseHandle(hMainThread); | |
495 } | |
496 | |
497 // Release browser interface | 386 // Release browser interface |
498 s_criticalSectionBrowser.Lock(); | 387 s_criticalSectionBrowser.Lock(); |
499 { | 388 { |
500 m_webBrowser2.Release(); | 389 m_webBrowser2.Release(); |
501 } | 390 } |
502 s_criticalSectionBrowser.Unlock(); | 391 s_criticalSectionBrowser.Unlock(); |
503 | 392 |
504 if (settings->IsMainProcess() && settings->IsMainUiThread()) | 393 DEBUG_GENERAL("=============================================================
===================\nNEW TAB UI - END\n=========================================
=======================================") |
505 { | |
506 DEBUG_GENERAL("===========================================================
=====================\nMAIN TAB UI - END\n======================================
==========================================") | |
507 } | |
508 else | |
509 { | |
510 DEBUG_GENERAL("===========================================================
=====================\nNEW TAB UI - END\n=======================================
=========================================") | |
511 } | |
512 | 394 |
513 ::CoUninitialize(); | 395 ::CoUninitialize(); |
514 } | 396 } |
515 | 397 |
516 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); | 398 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); |
517 } | 399 } |
518 | 400 |
519 bool CPluginClass::IsStatusBarEnabled() | 401 bool CPluginClass::IsStatusBarEnabled() |
520 { | 402 { |
521 HKEY pHkey; | 403 HKEY pHkey; |
(...skipping 27 matching lines...) Expand all Loading... |
549 | 431 |
550 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 432 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
551 if (browser) | 433 if (browser) |
552 { | 434 { |
553 HRESULT hr = S_OK; | 435 HRESULT hr = S_OK; |
554 hr = browser->get_StatusBar(&isVisible); | 436 hr = browser->get_StatusBar(&isVisible); |
555 if (SUCCEEDED(hr)) | 437 if (SUCCEEDED(hr)) |
556 { | 438 { |
557 if (!isVisible) | 439 if (!isVisible) |
558 { | 440 { |
559 if (!settings->GetBool("statusbarasked", false)) | 441 if (!settings->GetStatusBarAsked()) |
560 { | 442 { |
561 SHANDLE_PTR pBrowserHWnd; | 443 SHANDLE_PTR pBrowserHWnd; |
562 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); | 444 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); |
563 Dictionary* dictionary = Dictionary::GetInstance(); | 445 Dictionary* dictionary = Dictionary::GetInstance(); |
564 settings->SetBool("statusbarasked", true); | 446 settings->SetStatusBarAsked(); |
565 settings->Write(); | |
566 | 447 |
567 HKEY pHkey; | 448 HKEY pHkey; |
568 HKEY pHkeySub; | 449 HKEY pHkeySub; |
569 LSTATUS regRes = 0; | 450 LSTATUS regRes = 0; |
570 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); | 451 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); |
571 | 452 |
572 // Do we have enough rights to enable a status bar? | 453 // Do we have enough rights to enable a status bar? |
573 if (regRes != 0) | 454 if (regRes != 0) |
574 { | 455 { |
575 // We use the tab window here and in the next few calls, since the b
rowser window may still not be available | 456 // We use the tab window here and in the next few calls, since the b
rowser window may still not be available |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 // Create status pane | 816 // Create status pane |
936 if (bBHO) | 817 if (bBHO) |
937 { | 818 { |
938 if (!CreateStatusBarPane()) | 819 if (!CreateStatusBarPane()) |
939 { | 820 { |
940 return false; | 821 return false; |
941 } | 822 } |
942 } | 823 } |
943 | 824 |
944 CPluginSettings* settings = CPluginSettings::GetInstance(); | 825 CPluginSettings* settings = CPluginSettings::GetInstance(); |
945 | |
946 // Create main thread | |
947 if (GetMainThreadHandle() == NULL && settings->IsMainProcess() && settings->Is
MainUiThread()) | |
948 { | |
949 DWORD id; | |
950 HANDLE handle = ::CreateThread(NULL, 0, MainThreadProc, (LPVOID)m_tab, CREAT
E_SUSPENDED, &id); | |
951 if (handle == NULL) | |
952 { | |
953 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_T
HREAD_CREATE_PROCESS, "Class::Thread - Failed to create main thread"); | |
954 } | |
955 | |
956 s_hMainThread = handle; | |
957 | |
958 ::ResumeThread(handle); | |
959 } | |
960 | |
961 return true; | 826 return true; |
962 } | 827 } |
963 | 828 |
964 bool CPluginClass::CreateStatusBarPane() | 829 bool CPluginClass::CreateStatusBarPane() |
965 { | 830 { |
966 DEBUG_GENERAL(L"Getting client"); | 831 DEBUG_GENERAL(L"Getting client"); |
967 | 832 |
968 CPluginClient* client = CPluginClient::GetInstance(); | 833 CPluginClient* client = CPluginClient::GetInstance(); |
969 | 834 |
970 DEBUG_GENERAL(L"Getting ieversion"); | 835 DEBUG_GENERAL(L"Getting ieversion"); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 | 992 |
1128 ::SendMessage(m_hStatusBarWnd, SB_GETPARTS, nPartCount, (LPARAM)pData); | 993 ::SendMessage(m_hStatusBarWnd, SB_GETPARTS, nPartCount, (LPARAM)pData); |
1129 ::SendMessage(m_hStatusBarWnd, SB_SETPARTS, nPartCount, (LPARAM)pData); | 994 ::SendMessage(m_hStatusBarWnd, SB_SETPARTS, nPartCount, (LPARAM)pData); |
1130 | 995 |
1131 delete[] pData; | 996 delete[] pData; |
1132 } | 997 } |
1133 HDC hdc = GetWindowDC(m_hStatusBarWnd); | 998 HDC hdc = GetWindowDC(m_hStatusBarWnd); |
1134 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); | 999 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); |
1135 ReleaseDC(m_hStatusBarWnd, hdc); | 1000 ReleaseDC(m_hStatusBarWnd, hdc); |
1136 return true; | 1001 return true; |
1137 }///////////////////////////////////////////////////////////////////////////// | 1002 } |
1138 // Implementation | |
1139 | 1003 |
1140 void CPluginClass::CloseTheme() | 1004 void CPluginClass::CloseTheme() |
1141 { | 1005 { |
1142 if (m_hTheme) | 1006 if (m_hTheme) |
1143 { | 1007 { |
1144 if (pfnClose) | 1008 if (pfnClose) |
1145 { | 1009 { |
1146 pfnClose(m_hTheme); | 1010 pfnClose(m_hTheme); |
1147 } | 1011 } |
1148 | 1012 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 else | 1257 else |
1394 { | 1258 { |
1395 s_mimeFilter = NULL; | 1259 s_mimeFilter = NULL; |
1396 | 1260 |
1397 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | 1261 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
1398 } | 1262 } |
1399 } | 1263 } |
1400 s_criticalSectionLocal.Unlock(); | 1264 s_criticalSectionLocal.Unlock(); |
1401 } | 1265 } |
1402 break; | 1266 break; |
1403 #ifndef ENTERPRISE | |
1404 case ID_SETTINGS: | |
1405 { | |
1406 url = CString(UserSettingsFileUrl().c_str()); | |
1407 } | |
1408 break; | |
1409 #endif | |
1410 case ID_INVITEFRIENDS: | |
1411 { | |
1412 url = CPluginHttpRequest::GetStandardUrl(USERS_SCRIPT_INVITATION); | |
1413 navigationErrorId = PLUGIN_ERROR_NAVIGATION_INVITATION; | |
1414 } | |
1415 break; | |
1416 | |
1417 case ID_FAQ: | |
1418 { | |
1419 url = CPluginHttpRequest::GetStandardUrl(USERS_SCRIPT_FAQ); | |
1420 navigationErrorId = PLUGIN_ERROR_NAVIGATION_FAQ; | |
1421 } | |
1422 break; | |
1423 | |
1424 case ID_FEEDBACK: | |
1425 { | |
1426 CPluginHttpRequest httpRequest(USERS_SCRIPT_FEEDBACK); | |
1427 | |
1428 httpRequest.AddPluginId(); | |
1429 httpRequest.Add("reason", 0); | |
1430 httpRequest.Add(L"url", m_tab->GetDocumentUrl(), false); | |
1431 | |
1432 url = httpRequest.GetUrl(); | |
1433 navigationErrorId = PLUGIN_ERROR_NAVIGATION_FEEDBACK; | |
1434 } | |
1435 break; | |
1436 | |
1437 case ID_ABOUT: | |
1438 { | |
1439 url = CPluginHttpRequest::GetStandardUrl(USERS_SCRIPT_ABOUT); | |
1440 navigationErrorId = PLUGIN_ERROR_NAVIGATION_ABOUT; | |
1441 } | |
1442 break; | |
1443 | |
1444 default: | 1267 default: |
1445 | |
1446 break; | 1268 break; |
1447 } | 1269 } |
1448 | 1270 |
1449 // Invalidate and redraw the control | 1271 // Invalidate and redraw the control |
1450 UpdateStatusBar(); | 1272 UpdateStatusBar(); |
1451 | 1273 |
1452 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 1274 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
1453 if (!url.IsEmpty() && browser) | 1275 if (!url.IsEmpty() && browser) |
1454 { | 1276 { |
1455 VARIANT vFlags; | 1277 VARIANT vFlags; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 MENUITEMINFOW miiSep; | 1320 MENUITEMINFOW miiSep; |
1499 memset(&miiSep, 0, sizeof(MENUITEMINFO)); | 1321 memset(&miiSep, 0, sizeof(MENUITEMINFO)); |
1500 miiSep.cbSize = sizeof(MENUITEMINFO); | 1322 miiSep.cbSize = sizeof(MENUITEMINFO); |
1501 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1323 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
1502 miiSep.fType = MFT_SEPARATOR; | 1324 miiSep.fType = MFT_SEPARATOR; |
1503 | 1325 |
1504 CPluginClient* client = CPluginClient::GetInstance(); | 1326 CPluginClient* client = CPluginClient::GetInstance(); |
1505 | 1327 |
1506 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1328 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1507 | 1329 |
1508 settings->RefreshTab(); | |
1509 | |
1510 // Update settings | |
1511 m_tab->OnUpdateSettings(false); | |
1512 | |
1513 #ifdef SUPPORT_WHITELIST | 1330 #ifdef SUPPORT_WHITELIST |
1514 { | 1331 { |
1515 // White list domain | 1332 // White list domain |
1516 ctext = dictionary->Lookup("menu", "disable-on-site"); | 1333 ctext = dictionary->Lookup("menu", "disable-on-site"); |
1517 fmii.fMask = MIIM_STRING | MIIM_STATE; | 1334 fmii.fMask = MIIM_STRING | MIIM_STATE; |
1518 fmii.fState = MFS_DISABLED; | 1335 fmii.fState = MFS_DISABLED; |
1519 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1336 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1520 fmii.cch = ctext.size(); | 1337 fmii.cch = ctext.size(); |
1521 | 1338 |
1522 UINT index = WM_WHITELIST_DOMAIN; | 1339 UINT index = WM_WHITELIST_DOMAIN; |
1523 | 1340 |
1524 ::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); | 1341 ::SetMenuItemInfoW(hMenu, ID_WHITELISTDOMAIN, FALSE, &fmii); |
1525 } | 1342 } |
1526 #else | 1343 #else |
1527 { | 1344 { |
1528 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); | 1345 ::DeleteMenu(hMenu, ID_WHITELISTDOMAIN, FALSE); |
1529 } | 1346 } |
1530 #endif // SUPPORT_WHITELIST | 1347 #endif // SUPPORT_WHITELIST |
1531 | 1348 |
1532 // Invite friends | |
1533 ctext = dictionary->Lookup("menu", "invite"); | |
1534 fmii.fMask = MIIM_STATE | MIIM_STRING; | |
1535 fmii.fState = MFS_ENABLED; | |
1536 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | |
1537 fmii.cch = ctext.size(); | |
1538 ::SetMenuItemInfoW(hMenu, ID_INVITEFRIENDS, FALSE, &fmii); | |
1539 | |
1540 // FAQ | |
1541 ctext = dictionary->Lookup("menu", "faq"); | |
1542 fmii.fMask = MIIM_STATE | MIIM_STRING; | |
1543 fmii.fState = MFS_ENABLED; | |
1544 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | |
1545 fmii.cch = ctext.size(); | |
1546 ::SetMenuItemInfoW(hMenu, ID_FAQ, FALSE, &fmii); | |
1547 | |
1548 // About | |
1549 ctext = dictionary->Lookup("menu", "about"); | |
1550 fmii.fMask = MIIM_STATE | MIIM_STRING; | |
1551 fmii.fState = MFS_ENABLED; | |
1552 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | |
1553 fmii.cch = ctext.size(); | |
1554 ::SetMenuItemInfoW(hMenu, ID_ABOUT, FALSE, &fmii); | |
1555 | |
1556 // Feedback | |
1557 ctext = dictionary->Lookup("menu", "feedback"); | |
1558 fmii.fMask = MIIM_STATE | MIIM_STRING; | |
1559 fmii.fState = MFS_ENABLED; | |
1560 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | |
1561 fmii.cch = ctext.size(); | |
1562 ::SetMenuItemInfoW(hMenu, ID_FEEDBACK, FALSE, &fmii); | |
1563 | |
1564 // Plugin enable | 1349 // Plugin enable |
1565 if (settings->GetPluginEnabled()) | 1350 if (settings->GetPluginEnabled()) |
1566 { | 1351 { |
1567 ctext = dictionary->Lookup("menu", "disable"); | 1352 ctext = dictionary->Lookup("menu", "disable"); |
1568 } | 1353 } |
1569 else | 1354 else |
1570 { | 1355 { |
1571 ctext = dictionary->Lookup("menu", "enable"); | 1356 ctext = dictionary->Lookup("menu", "enable"); |
1572 } | 1357 } |
1573 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1358 fmii.fMask = MIIM_STATE | MIIM_STRING; |
1574 fmii.fState = client ? MFS_ENABLED : MFS_DISABLED; | 1359 fmii.fState = client ? MFS_ENABLED : MFS_DISABLED; |
1575 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1360 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1576 fmii.cch = ctext.size(); | 1361 fmii.cch = ctext.size(); |
1577 ::SetMenuItemInfoW(hMenu, ID_PLUGIN_ENABLE, FALSE, &fmii); | 1362 ::SetMenuItemInfoW(hMenu, ID_PLUGIN_ENABLE, FALSE, &fmii); |
1578 | 1363 |
1579 // Settings | 1364 // Settings |
1580 #ifndef ENTERPRISE | |
1581 ctext = dictionary->Lookup("menu", "settings"); | 1365 ctext = dictionary->Lookup("menu", "settings"); |
1582 fmii.fMask = MIIM_STATE | MIIM_STRING; | 1366 fmii.fMask = MIIM_STATE | MIIM_STRING; |
1583 fmii.fState = MFS_ENABLED; | 1367 fmii.fState = MFS_ENABLED; |
1584 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1368 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1585 fmii.cch = ctext.size(); | 1369 fmii.cch = ctext.size(); |
1586 ::SetMenuItemInfoW(hMenu, ID_SETTINGS, FALSE, &fmii); | 1370 ::SetMenuItemInfoW(hMenu, ID_SETTINGS, FALSE, &fmii); |
1587 #else | |
1588 RemoveMenu(hMenu, ID_SETTINGS, MF_BYCOMMAND); | |
1589 RemoveMenu(hMenu, 5, MF_BYPOSITION); | |
1590 #endif | |
1591 | 1371 |
1592 return true; | 1372 return true; |
1593 } | 1373 } |
1594 | 1374 |
1595 | 1375 |
1596 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) | 1376 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) |
1597 { | 1377 { |
1598 HWND hBrowserWnd = GetBrowserHWND(); | 1378 HWND hBrowserWnd = GetBrowserHWND(); |
1599 if (!hBrowserWnd) | 1379 if (!hBrowserWnd) |
1600 { | 1380 { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 if (FAILED(hr)) | 1725 if (FAILED(hr)) |
1946 { | 1726 { |
1947 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") | 1727 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") |
1948 } | 1728 } |
1949 } | 1729 } |
1950 } | 1730 } |
1951 #endif | 1731 #endif |
1952 } | 1732 } |
1953 break; | 1733 break; |
1954 | 1734 |
1955 #ifndef ENTERPRISE | |
1956 | 1735 |
1957 case WM_LAUNCH_INFO: | 1736 // First run page |
| 1737 case WM_LAUNCH_INFO: |
1958 { | 1738 { |
1959 // Set the status bar visible, if it isn't | 1739 // Set the status bar visible, if it isn't |
1960 // Otherwise the user won't see the icon the first time | 1740 // Otherwise the user won't see the icon the first time |
1961 | 1741 |
1962 if (wParam == 1) | 1742 if (wParam == 1) |
1963 { | 1743 { |
1964 // Redirect to welcome page | 1744 // Redirect to welcome page |
1965 VARIANT_BOOL isVisible; | 1745 VARIANT_BOOL isVisible; |
1966 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 1746 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
1967 if (browser) | 1747 if (browser) |
(...skipping 21 matching lines...) Expand all Loading... |
1989 } | 1769 } |
1990 } | 1770 } |
1991 } | 1771 } |
1992 else | 1772 else |
1993 { | 1773 { |
1994 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR,
"Class::Get statusbar state"); | 1774 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR,
"Class::Get statusbar state"); |
1995 } | 1775 } |
1996 | 1776 |
1997 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1777 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1998 | 1778 |
1999 CPluginHttpRequest httpRequest(USERS_SCRIPT_WELCOME); | 1779 //TODO: Navigate to first run page here |
2000 | 1780 /* hr = browser->Navigate(CComBSTR("FIRST_RUN_PAGE_URL"), NULL, NULL, NUL
L, NULL); |
2001 httpRequest.Add("errors", settings->GetErrorList()); | |
2002 | |
2003 | |
2004 hr = browser->Navigate(CComBSTR(httpRequest.GetUrl() + "&src=" + DOWNL
OAD_SOURCE), NULL, NULL, NULL, NULL); | |
2005 if (FAILED(hr)) | 1781 if (FAILED(hr)) |
2006 { | 1782 { |
2007 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_WELCOME, "Navigation::Welcome page failed") | 1783 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_WELCOME, "Navigation::Welcome page failed") |
2008 } | 1784 } |
2009 | 1785 */ |
2010 // Update settings server side on next IE start, as they have possibly
changed | |
2011 settings->ForceConfigurationUpdateOnStart(); | |
2012 } | 1786 } |
2013 } | 1787 } |
2014 else | 1788 else |
2015 { | 1789 { |
2016 // Redirect to info page | 1790 // Redirect to info page |
2017 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 1791 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
2018 if (browser) | 1792 if (browser) |
2019 { | 1793 { |
2020 CPluginHttpRequest httpRequest(USERS_SCRIPT_INFO); | |
2021 | |
2022 httpRequest.Add("info", wParam); | |
2023 | |
2024 VARIANT vFlags; | 1794 VARIANT vFlags; |
2025 vFlags.vt = VT_I4; | 1795 vFlags.vt = VT_I4; |
2026 vFlags.intVal = navOpenInNewTab; | 1796 vFlags.intVal = navOpenInNewTab; |
2027 | 1797 |
2028 HRESULT hr = browser->Navigate(CComBSTR(httpRequest.GetUrl()), &vFlags
, NULL, NULL, NULL); | 1798 // TODO: Navigate to info page here or remove this clause |
| 1799 /* HRESULT hr = browser->Navigate(CComBSTR(INFO_PAGE_URL), &vFlags, NUL
L, NULL, NULL); |
2029 if (FAILED(hr)) | 1800 if (FAILED(hr)) |
2030 { | 1801 { |
2031 vFlags.intVal = navOpenInNewWindow; | 1802 vFlags.intVal = navOpenInNewWindow; |
2032 | 1803 |
2033 hr = browser->Navigate(CComBSTR(httpRequest.GetUrl()), &vFlags, NULL
, NULL, NULL); | 1804 hr = browser->Navigate(CComBSTR(httpRequest.GetUrl()), &vFlags, NULL
, NULL, NULL); |
2034 if (FAILED(hr)) | 1805 if (FAILED(hr)) |
2035 { | 1806 { |
2036 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI
ON_INFO, "Navigation::Info page failed") | 1807 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI
ON_INFO, "Navigation::Info page failed") |
2037 } | 1808 } |
2038 } | 1809 } |
| 1810 */ |
2039 } | 1811 } |
2040 } | 1812 } |
2041 } | 1813 } |
2042 break; | 1814 break; |
2043 #endif | |
2044 | 1815 |
2045 case WM_DESTROY: | 1816 case WM_DESTROY: |
2046 break; | 1817 break; |
2047 case SC_CLOSE: | 1818 case SC_CLOSE: |
2048 break; | 1819 break; |
2049 | 1820 |
2050 case WM_UPDATEUISTATE: | 1821 case WM_UPDATEUISTATE: |
2051 { | 1822 { |
2052 CPluginTab* tab = GetTab(::GetCurrentThreadId()); | 1823 CPluginTab* tab = GetTab(::GetCurrentThreadId()); |
2053 if (tab) | 1824 if (tab) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2192 } | 1963 } |
2193 } | 1964 } |
2194 } | 1965 } |
2195 | 1966 |
2196 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1967 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
2197 } | 1968 } |
2198 | 1969 |
2199 return hTabWnd; | 1970 return hTabWnd; |
2200 | 1971 |
2201 } | 1972 } |
OLD | NEW |