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" |
(...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(), |
| 452 MB_OK); |
| 453 return; |
| 454 } |
| 455 // Ask if a user wants to enable a status bar automatically |
| 456 LRESULT res = MessageBox((HWND)m_hTabWnd, |
| 457 dictionary->Lookup("status-bar", "question").c_str(), |
| 458 dictionary->Lookup("status-bar", "title").c_str(), |
| 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)) |
| 471 { |
| 472 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATUSBAR,
"Class::Enable statusbar"); |
| 473 } |
| 474 CreateStatusBarPane(); |
447 | 475 |
448 HKEY pHkey; | 476 // We need to restart the tab now, to enable the status bar properly |
449 HKEY pHkeySub; | 477 VARIANT vFlags; |
450 LSTATUS regRes = 0; | 478 vFlags.vt = VT_I4; |
451 regRes = RegOpenCurrentUser(KEY_WRITE, &pHkey); | 479 vFlags.intVal = navOpenInNewTab; |
452 | 480 |
453 // Do we have enough rights to enable a status bar? | 481 CComBSTR curLoc; |
454 if (regRes != 0) | 482 browser->get_LocationURL(&curLoc); |
| 483 HRESULT hr = browser->Navigate(curLoc, &vFlags, NULL, NULL, NULL); |
| 484 if (FAILED(hr)) |
455 { | 485 { |
456 // We use the tab window here and in the next few calls, since the b
rowser window may still not be available | 486 vFlags.intVal = navOpenInNewWindow; |
457 LRESULT res = MessageBox((HWND)m_hTabWnd, | 487 |
458 dictionary->Lookup("status-bar", "error-text").c_str(), | 488 hr = browser->Navigate(CComBSTR(curLoc), &vFlags, NULL, NULL, NULL); |
459 dictionary->Lookup("status-bar", "error-title").c_str(), | |
460 MB_OK); | |
461 return; | |
462 } | |
463 // Ask if a user wants to enable a status bar automatically | |
464 LRESULT res = MessageBox((HWND)m_hTabWnd, | |
465 dictionary->Lookup("status-bar", "question").c_str(), | |
466 dictionary->Lookup("status-bar", "title").c_str(), | |
467 MB_YESNO); | |
468 if (res == IDYES) | |
469 { | |
470 DWORD trueth = 1; | |
471 regRes = RegOpenKey(pHkey, L"Software\\Microsoft\\Internet Explorer\
\MINIE", &pHkeySub); | |
472 regRes = RegSetValueEx(pHkeySub, L"ShowStatusBar", 0, REG_DWORD, (BY
TE*)&trueth, sizeof(DWORD)); | |
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 805 |
816 // Create status pane | 806 // Create status pane |
817 if (bBHO) | 807 if (bBHO) |
818 { | 808 { |
819 if (!CreateStatusBarPane()) | 809 if (!CreateStatusBarPane()) |
820 { | 810 { |
821 return false; | 811 return false; |
822 } | 812 } |
823 } | 813 } |
824 | 814 |
| 815 if (CPluginClient::GetInstance()->IsFirstRun()) |
| 816 { |
| 817 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThrea
d, NULL, NULL, NULL); |
| 818 if ((m_hPaneWnd == NULL) || (!IsStatusBarEnabled())) |
| 819 { |
| 820 ShowStatusBar(); |
| 821 } |
| 822 |
| 823 } |
| 824 |
825 CPluginSettings* settings = CPluginSettings::GetInstance(); | 825 CPluginSettings* settings = CPluginSettings::GetInstance(); |
826 return true; | 826 return true; |
827 } | 827 } |
828 | 828 |
829 bool CPluginClass::CreateStatusBarPane() | 829 bool CPluginClass::CreateStatusBarPane() |
830 { | 830 { |
831 DEBUG_GENERAL(L"Getting client"); | 831 DEBUG_GENERAL(L"Getting client"); |
832 | 832 |
833 CPluginClient* client = CPluginClient::GetInstance(); | 833 CPluginClient* client = CPluginClient::GetInstance(); |
834 | 834 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 INT *pData = new INT[nPartCount]; | 991 INT *pData = new INT[nPartCount]; |
992 | 992 |
993 ::SendMessage(m_hStatusBarWnd, SB_GETPARTS, nPartCount, (LPARAM)pData); | 993 ::SendMessage(m_hStatusBarWnd, SB_GETPARTS, nPartCount, (LPARAM)pData); |
994 ::SendMessage(m_hStatusBarWnd, SB_SETPARTS, nPartCount, (LPARAM)pData); | 994 ::SendMessage(m_hStatusBarWnd, SB_SETPARTS, nPartCount, (LPARAM)pData); |
995 | 995 |
996 delete[] pData; | 996 delete[] pData; |
997 } | 997 } |
998 HDC hdc = GetWindowDC(m_hStatusBarWnd); | 998 HDC hdc = GetWindowDC(m_hStatusBarWnd); |
999 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); | 999 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); |
1000 ReleaseDC(m_hStatusBarWnd, hdc); | 1000 ReleaseDC(m_hStatusBarWnd, hdc); |
| 1001 |
1001 return true; | 1002 return true; |
1002 } | 1003 } |
1003 | 1004 |
| 1005 void CPluginClass::FirstRunThread() |
| 1006 { |
| 1007 CoInitialize(NULL); |
| 1008 VARIANT vFlags; |
| 1009 vFlags.vt = VT_I4; |
| 1010 vFlags.intVal = navOpenInNewTab; |
| 1011 |
| 1012 CComBSTR bTest = CComBSTR(UserSettingsFirstRunPageUrl().c_str()); |
| 1013 |
| 1014 //Try 10 times, or until successful |
| 1015 int numberOfAttempts = 0; |
| 1016 HRESULT hr = S_FALSE; |
| 1017 hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL); |
| 1018 if (FAILED(hr)) |
| 1019 { |
| 1020 vFlags.intVal = navOpenInNewWindow; |
| 1021 hr = GetAsyncBrowser()->Navigate(bTest, &vFlags, NULL, NULL, NULL); |
| 1022 } |
| 1023 |
| 1024 |
| 1025 if (FAILED(hr)) |
| 1026 { |
| 1027 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION_WELCOME
, "Navigation::Welcome page failed") |
| 1028 } |
| 1029 } |
1004 void CPluginClass::CloseTheme() | 1030 void CPluginClass::CloseTheme() |
1005 { | 1031 { |
1006 if (m_hTheme) | 1032 if (m_hTheme) |
1007 { | 1033 { |
1008 if (pfnClose) | 1034 if (pfnClose) |
1009 { | 1035 { |
1010 pfnClose(m_hTheme); | 1036 pfnClose(m_hTheme); |
1011 } | 1037 } |
1012 | 1038 |
1013 m_hTheme = NULL; | 1039 m_hTheme = NULL; |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL,
NULL, NULL); | 1750 hr = browser->Navigate(BString(UserSettingsFileUrl()), &vFlags, NULL,
NULL, NULL); |
1725 if (FAILED(hr)) | 1751 if (FAILED(hr)) |
1726 { | 1752 { |
1727 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") | 1753 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_SETTINGS, "Navigation::Failed") |
1728 } | 1754 } |
1729 } | 1755 } |
1730 } | 1756 } |
1731 #endif | 1757 #endif |
1732 } | 1758 } |
1733 break; | 1759 break; |
1734 | |
1735 | |
1736 // First run page | |
1737 case WM_LAUNCH_INFO: | |
1738 { | |
1739 // Set the status bar visible, if it isn't | |
1740 // Otherwise the user won't see the icon the first time | |
1741 | |
1742 if (wParam == 1) | |
1743 { | |
1744 // Redirect to welcome page | |
1745 VARIANT_BOOL isVisible; | |
1746 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | |
1747 if (browser) | |
1748 { | |
1749 HRESULT hr = S_OK; | |
1750 | |
1751 hr = browser->get_StatusBar(&isVisible); | |
1752 if (SUCCEEDED(hr)) | |
1753 { | |
1754 if (!isVisible) | |
1755 { | |
1756 Dictionary* dictionary = Dictionary::GetInstance(); | |
1757 | |
1758 LRESULT res = MessageBox(NULL, | |
1759 dictionary->Lookup("status-bar", "question").c_str(), | |
1760 dictionary->Lookup("status-bar", "title").c_str(), | |
1761 MB_YESNO); | |
1762 if (res == IDYES) | |
1763 { | |
1764 hr = browser->put_StatusBar(TRUE); | |
1765 if (FAILED(hr)) | |
1766 { | |
1767 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_PUT_STATU
SBAR, "Class::Enable statusbar"); | |
1768 } | |
1769 } | |
1770 } | |
1771 } | |
1772 else | |
1773 { | |
1774 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR,
"Class::Get statusbar state"); | |
1775 } | |
1776 | |
1777 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
1778 | |
1779 //TODO: Navigate to first run page here | |
1780 /* hr = browser->Navigate(CComBSTR("FIRST_RUN_PAGE_URL"), NULL, NULL, NUL
L, NULL); | |
1781 if (FAILED(hr)) | |
1782 { | |
1783 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION
_WELCOME, "Navigation::Welcome page failed") | |
1784 } | |
1785 */ | |
1786 } | |
1787 } | |
1788 else | |
1789 { | |
1790 // Redirect to info page | |
1791 CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser(); | |
1792 if (browser) | |
1793 { | |
1794 VARIANT vFlags; | |
1795 vFlags.vt = VT_I4; | |
1796 vFlags.intVal = navOpenInNewTab; | |
1797 | |
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); | |
1800 if (FAILED(hr)) | |
1801 { | |
1802 vFlags.intVal = navOpenInNewWindow; | |
1803 | |
1804 hr = browser->Navigate(CComBSTR(httpRequest.GetUrl()), &vFlags, NULL
, NULL, NULL); | |
1805 if (FAILED(hr)) | |
1806 { | |
1807 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATI
ON_INFO, "Navigation::Info page failed") | |
1808 } | |
1809 } | |
1810 */ | |
1811 } | |
1812 } | |
1813 } | |
1814 break; | |
1815 | |
1816 case WM_DESTROY: | 1760 case WM_DESTROY: |
1817 break; | 1761 break; |
1818 case SC_CLOSE: | 1762 case SC_CLOSE: |
1819 break; | 1763 break; |
1820 | 1764 |
1821 case WM_UPDATEUISTATE: | 1765 case WM_UPDATEUISTATE: |
1822 { | 1766 { |
1823 CPluginTab* tab = GetTab(::GetCurrentThreadId()); | 1767 CPluginTab* tab = GetTab(::GetCurrentThreadId()); |
1824 if (tab) | 1768 if (tab) |
1825 { | 1769 { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1963 } | 1907 } |
1964 } | 1908 } |
1965 } | 1909 } |
1966 | 1910 |
1967 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1911 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1968 } | 1912 } |
1969 | 1913 |
1970 return hTabWnd; | 1914 return hTabWnd; |
1971 | 1915 |
1972 } | 1916 } |
OLD | NEW |