| LEFT | RIGHT |
| 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" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 217 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
| 218 { | 218 { |
| 219 if (thisPtr == NULL) | 219 if (thisPtr == NULL) |
| 220 return 0; | 220 return 0; |
| 221 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 221 if (!((CPluginClass*)thisPtr)->InitObject(true)) |
| 222 { | 222 { |
| 223 ((CPluginClass*)thisPtr)->Unadvice(); | 223 ((CPluginClass*)thisPtr)->Unadvice(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 if ((((CPluginClass*)thisPtr)->m_hPaneWnd == NULL) || (!((CPluginClass*)thisPt
r)->IsStatusBarEnabled())) | |
| 227 { | |
| 228 ((CPluginClass*)thisPtr)->ShowStatusBar(); | |
| 229 } | |
| 230 return 0; | 226 return 0; |
| 231 } | 227 } |
| 232 | 228 |
| 233 | 229 |
| 234 | 230 |
| 235 // This gets called when a new browser window is created (which also triggers th
e | 231 // This gets called when a new browser window is created (which also triggers th
e |
| 236 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 232 // creation of this object). The pointer passed in should be to a IWebBrowser2 |
| 237 // interface that represents the browser for the window. | 233 // interface that represents the browser for the window. |
| 238 // it is also called when a tab is closed, this unknownSite will be null | 234 // it is also called when a tab is closed, this unknownSite will be null |
| 239 // so we should handle that it is called this way several times during a session | 235 // so we should handle that it is called this way several times during a session |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 416 } |
| 421 } | 417 } |
| 422 } | 418 } |
| 423 return trueth == 1; | 419 return trueth == 1; |
| 424 } | 420 } |
| 425 | 421 |
| 426 void CPluginClass::ShowStatusBar() | 422 void CPluginClass::ShowStatusBar() |
| 427 { | 423 { |
| 428 VARIANT_BOOL isVisible; | 424 VARIANT_BOOL isVisible; |
| 429 | 425 |
| 430 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
| 431 | 426 |
| 432 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | 427 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); |
| 433 if (browser) | 428 if (browser) |
| 434 { | 429 { |
| 435 HRESULT hr = S_OK; | 430 HRESULT hr = S_OK; |
| 436 hr = browser->get_StatusBar(&isVisible); | 431 hr = browser->get_StatusBar(&isVisible); |
| 437 if (SUCCEEDED(hr)) | 432 if (SUCCEEDED(hr)) |
| 438 { | 433 { |
| 439 if (!isVisible) | 434 if (!isVisible) |
| 440 { | 435 { |
| 441 if (!settings->GetStatusBarAsked()) | 436 SHANDLE_PTR pBrowserHWnd; |
| 437 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); |
| 438 Dictionary* dictionary = Dictionary::GetInstance(); |
| 439 |
| 440 HKEY pHkey; |
| 441 HKEY pHkeySub; |
| 442 LSTATUS regRes = 0; |
| 443 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); |
| 444 |
| 445 // Do we have enough rights to enable a status bar? |
| 446 if (regRes != 0) |
| 442 { | 447 { |
| 443 SHANDLE_PTR pBrowserHWnd; | 448 // We use the tab window here and in the next few calls, since the bro
wser window may still not be available |
| 444 browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd); | 449 LRESULT res = MessageBox((HWND)m_hTabWnd, |
| 445 Dictionary* dictionary = Dictionary::GetInstance(); | 450 dictionary->Lookup("status-bar", "error-text").c_str(), |
| 446 settings->SetStatusBarAsked(); | 451 dictionary->Lookup("status-bar", "error-title").c_str(), |
| 447 | 452 MB_OK); |
| 448 HKEY pHkey; | 453 return; |
| 449 HKEY pHkeySub; | 454 } |
| 450 LSTATUS regRes = 0; | 455 // Ask if a user wants to enable a status bar automatically |
| 451 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); | 456 LRESULT res = MessageBox((HWND)m_hTabWnd, |
| 452 | 457 dictionary->Lookup("status-bar", "question").c_str(), |
| 453 // Do we have enough rights to enable a status bar? | 458 dictionary->Lookup("status-bar", "title").c_str(), |
| 454 if (regRes != 0) | 459 MB_YESNO); |
| 460 if (res == IDYES) |
| 461 { |
| 462 DWORD trueth = 1; |
| 463 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M
INIE", &pHkeySub); |
| 464 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BYTE
*)&trueth, sizeof(DWORD)); |
| 465 regRes = RegCloseKey(pHkeySub); |
| 466 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\\M
ain", &pHkeySub); |
| 467 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYTE*
)&trueth, sizeof(DWORD)); |
| 468 regRes = RegCloseKey(pHkeySub); |
| 469 hr = browser->put_StatusBar(TRUE); |
| 470 if (FAILED(hr)) |
| 455 { | 471 { |
| 456 // We use the tab window here and in the next few calls, since the b
rowser window may still not be available | 472 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR,
"Class::Enable statusbar"); |
| 457 LRESULT res = MessageBox((HWND)m_hTabWnd, | |
| 458 dictionary->Lookup("status-bar", "error-text").c_str(), | |
| 459 dictionary->Lookup("status-bar", "error-title").c_str(), | |
| 460 MB_OK); | |
| 461 return; | |
| 462 } | 473 } |
| 463 // Ask if a user wants to enable a status bar automatically | 474 CreateStatusBarPane(); |
| 464 LRESULT res = MessageBox((HWND)m_hTabWnd, | 475 |
| 465 dictionary->Lookup("status-bar", "question").c_str(), | 476 // We need to restart the tab now, to enable the status bar properly |
| 466 dictionary->Lookup("status-bar", "title").c_str(), | 477 VARIANT vFlags; |
| 467 MB_YESNO); | 478 vFlags.vt = VT_I4; |
| 468 if (res == IDYES) | 479 vFlags.intVal = navOpenInNewTab; |
| 480 |
| 481 CComBSTR curLoc; |
| 482 browser->get_LocationURL(&curLoc); |
| 483 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); |
| 484 if (FAILED(hr)) |
| 469 { | 485 { |
| 470 DWORD trueth = 1; | 486 vFlags.intVal = navOpenInNewWindow; |
| 471 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\
\MINIE", &pHkeySub); | 487 |
| 472 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BY
TE*)&trueth, sizeof(DWORD)); | 488 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL); |
| 473 regRes = RegCloseKey(pHkeySub); | |
| 474 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\
\Main", &pHkeySub); | |
| 475 regRes = RegSetValueEx(pHkeySub, L"StatusBarWeb", 0, REG_DWORD, (BYT
E*)&trueth, sizeof(DWORD)); | |
| 476 regRes = RegCloseKey(pHkeySub); | |
| 477 hr = browser->put_StatusBar(TRUE); | |
| 478 if (FAILED(hr)) | 489 if (FAILED(hr)) |
| 479 { | 490 { |
| 480 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR
, "Class::Enable statusbar"); | 491 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI
ON, "Navigation::Failed") |
| 481 } | 492 } |
| 482 CreateStatusBarPane(); | |
| 483 | |
| 484 // We need to restart the tab now, to enable the status bar properly | |
| 485 VARIANT vFlags; | |
| 486 vFlags.vt = VT_I4; | |
| 487 vFlags.intVal = navOpenInNewTab; | |
| 488 | |
| 489 CComBSTR curLoc; | |
| 490 browser->get_LocationURL(&curLoc); | |
| 491 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); | |
| 492 if (FAILED(hr)) | |
| 493 { | |
| 494 vFlags.intVal = navOpenInNewWindow; | |
| 495 | |
| 496 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL
); | |
| 497 if (FAILED(hr)) | |
| 498 { | |
| 499 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGA
TION, "Navigation::Failed") | |
| 500 } | |
| 501 } | |
| 502 browser->Quit(); | |
| 503 | |
| 504 } | 493 } |
| 494 browser->Quit(); |
| 505 } | 495 } |
| 506 } | 496 } |
| 507 } | 497 } |
| 508 else | 498 else |
| 509 { | 499 { |
| 510 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class
::Get statusbar state"); | 500 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class
::Get statusbar state"); |
| 511 } | 501 } |
| 512 } | 502 } |
| 513 } | 503 } |
| 514 | 504 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 { | 808 { |
| 819 if (!CreateStatusBarPane()) | 809 if (!CreateStatusBarPane()) |
| 820 { | 810 { |
| 821 return false; | 811 return false; |
| 822 } | 812 } |
| 823 } | 813 } |
| 824 | 814 |
| 825 if (CPluginClient::GetInstance()->IsFirstRun()) | 815 if (CPluginClient::GetInstance()->IsFirstRun()) |
| 826 { | 816 { |
| 827 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThrea
d, NULL, NULL, NULL); | 817 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThrea
d, NULL, NULL, NULL); |
| 818 if ((m_hPaneWnd == NULL) || (!IsStatusBarEnabled())) |
| 819 { |
| 820 ShowStatusBar(); |
| 821 } |
| 822 |
| 828 } | 823 } |
| 829 | 824 |
| 830 CPluginSettings* settings = CPluginSettings::GetInstance(); | 825 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 831 return true; | 826 return true; |
| 832 } | 827 } |
| 833 | 828 |
| 834 bool CPluginClass::CreateStatusBarPane() | 829 bool CPluginClass::CreateStatusBarPane() |
| 835 { | 830 { |
| 836 DEBUG_GENERAL(L"Getting client"); | 831 DEBUG_GENERAL(L"Getting client"); |
| 837 | 832 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 } | 997 } |
| 1003 HDC hdc = GetWindowDC(m_hStatusBarWnd); | 998 HDC hdc = GetWindowDC(m_hStatusBarWnd); |
| 1004 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); | 999 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); |
| 1005 ReleaseDC(m_hStatusBarWnd, hdc); | 1000 ReleaseDC(m_hStatusBarWnd, hdc); |
| 1006 | 1001 |
| 1007 return true; | 1002 return true; |
| 1008 } | 1003 } |
| 1009 | 1004 |
| 1010 void CPluginClass::FirstRunThread() | 1005 void CPluginClass::FirstRunThread() |
| 1011 { | 1006 { |
| 1007 CoInitialize(NULL); |
| 1012 VARIANT vFlags; | 1008 VARIANT vFlags; |
| 1013 vFlags.vt = VT_I4; | 1009 vFlags.vt = VT_I4; |
| 1014 vFlags.intVal = navOpenInNewTab; | 1010 vFlags.intVal = navOpenInNewTab; |
| 1015 | 1011 |
| 1016 CComBSTR bTest = CComBSTR(UserSettingsFirstRunPageUrl().c_str()); | 1012 CComBSTR navigatePath = CComBSTR(FirstRunPageFileUrl().c_str()); |
| 1017 | 1013 |
| 1018 //Try 10 times, or until successful | 1014 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU
LL); |
| 1019 int numberOfAttempts = 0; | |
| 1020 HRESULT hr = S_FALSE; | |
| 1021 hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL); | |
| 1022 if (FAILED(hr)) | 1015 if (FAILED(hr)) |
| 1023 { | 1016 { |
| 1024 vFlags.intVal = navOpenInNewWindow; | 1017 vFlags.intVal = navOpenInNewWindow; |
| 1025 hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL); | 1018 hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NULL); |
| 1026 } | 1019 } |
| 1027 | |
| 1028 | 1020 |
| 1029 if (FAILED(hr)) | 1021 if (FAILED(hr)) |
| 1030 { | 1022 { |
| 1031 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME
, "Navigation::Welcome page failed") | 1023 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME
, "Navigation::Welcome page failed") |
| 1032 } | 1024 } |
| 1033 } | 1025 } |
| 1034 void CPluginClass::CloseTheme() | 1026 void CPluginClass::CloseTheme() |
| 1035 { | 1027 { |
| 1036 if (m_hTheme) | 1028 if (m_hTheme) |
| 1037 { | 1029 { |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 } | 1903 } |
| 1912 } | 1904 } |
| 1913 } | 1905 } |
| 1914 | 1906 |
| 1915 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1907 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
| 1916 } | 1908 } |
| 1917 | 1909 |
| 1918 return hTabWnd; | 1910 return hTabWnd; |
| 1919 | 1911 |
| 1920 } | 1912 } |
| LEFT | RIGHT |