Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: Shared/PluginClass.cpp

Issue 8978054: Removal of shareware parts (Closed)
Patch Set: Created Dec. 5, 2012, 7:59 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Shared/PluginClass.h ('k') | Shared/PluginClassThread.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginClass.h" 3 #include "PluginClass.h"
4 #include "PluginDictionary.h" 4 #include "PluginDictionary.h"
5 #include "PluginSettings.h" 5 #include "PluginSettings.h"
6 #include "PluginSystem.h" 6 #include "PluginSystem.h"
7 #ifdef SUPPORT_FILTER 7 #ifdef SUPPORT_FILTER
8 #include "PluginFilter.h" 8 #include "PluginFilter.h"
9 #endif 9 #endif
10 #include "PluginMimeFilterClient.h" 10 #include "PluginMimeFilterClient.h"
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 } 626 }
627 } 627 }
628 else 628 else
629 { 629 {
630 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET _STATUSBAR, "Class::Get statusbar state"); 630 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET _STATUSBAR, "Class::Get statusbar state");
631 } 631 }
632 } 632 }
633 } 633 }
634 634
635 void CPluginClass::DisplayActivateMessage()
636 {
637 CPluginSettings* settings = CPluginSettings::GetInstance();
638
639 CString messageString;
640 messageString.Format(L"The daily adblocklimit has been reached and no-mo re ads are blocked today.\nThe free version of Simple Adblock only blocks %d adr equests a day.\n\nTo enjoy unlimited adblocking please upgrade.", settings->GetV alue(SETTING_PLUGIN_ADBLOCKLIMIT, 0));
641
642 settings->SetValue(SETTING_PLUGIN_ADBLOCKCOUNT, settings->GetValue(SETTI NG_PLUGIN_ADBLOCKLIMIT, 0) + 1);
643 settings->Write();
644
645 LRESULT res = MessageBox(NULL, messageString, L"Upgrade to Simple Adbloc k Pro", MB_OKCANCEL);
646 if (res == IDOK)
647 {
648 CPluginSettings* settings = CPluginSettings::GetInstance();
649 CPluginHttpRequest httpRequest(USERS_SCRIPT_UPGRADE);
650 CPluginSystem* system = CPluginSystem::GetInstance();
651 httpRequest.Add(L"plugin", system->GetPluginId());
652 httpRequest.Add(L"user", settings->GetString(SETTING_USER_ID));
653 httpRequest.Add(L"version", settings->GetString(SETTING_PLUGIN_V ERSION));
654 CString url = httpRequest.GetUrl();
655
656 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId());
657 CComQIPtr<IWebBrowser2> browser = tab->m_plugin->GetBrowser();
658 if (!url.IsEmpty() && browser)
659 {
660 VARIANT vFlags;
661 vFlags.vt = VT_I4;
662 vFlags.intVal = navOpenInNewTab;
663
664 HRESULT hr = browser->Navigate(CComBSTR(url), &vFlags, N ULL, NULL, NULL);
665 if (FAILED(hr))
666 {
667 vFlags.intVal = navOpenInNewWindow;
668
669 hr = browser->Navigate(CComBSTR(url), &vFlags, N ULL, NULL, NULL);
670 }
671 }
672 }
673 }
674 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams) 635 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams)
675 { 636 {
676 637
677 if (pDispParams->cArgs < 7) 638 if (pDispParams->cArgs < 7)
678 { 639 {
679 return; 640 return;
680 } 641 }
681 » CPluginSettings* settings = CPluginSettings::GetInstance(); 642 » //Register a mime filter if it's not registered yet
682 » //Reset adblockcount every day 643 » if (s_mimeFilter == NULL)
683 » SYSTEMTIME stNow;
684 » GetSystemTime(&stNow);
685 » WORD limitDay = settings->GetValue(SETTING_PLUGIN_LIMITDAY, 0);
686 » if (limitDay != stNow.wDay)
687 { 644 {
688 » » settings->SetValue(SETTING_PLUGIN_ADBLOCKCOUNT, 0); 645 » » s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance ();
689 » » settings->SetValue(SETTING_PLUGIN_LIMITDAY, stNow.wDay);
690 » » settings->Write();
691 » » settings->Read();
692
693 » » //Also register a mime filter if it's not registered yet
694 » » if (s_mimeFilter == NULL)
695 » » {
696 » » » s_mimeFilter = CPluginClientFactory::GetMimeFilterClient Instance();
697 » » }
698
699 » }
700
701 » if (!settings->GetBool(SETTING_PLUGIN_REGISTRATION, false))
702 » {
703 » » if ((settings->GetValue(SETTING_PLUGIN_ADBLOCKCOUNT, 0) == setti ngs->GetValue(SETTING_PLUGIN_ADBLOCKLIMIT, 0))
704 » » » && (settings->GetValue(SETTING_PLUGIN_ADBLOCKLIMIT, 0) > 0))
705 » » {
706 » » » DisplayActivateMessage();
707 » » }
708 } 646 }
709 647
710 // Get the IWebBrowser2 interface 648 // Get the IWebBrowser2 interface
711 CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> WebBrowser2Ptr; 649 CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> WebBrowser2Ptr;
712 VARTYPE vt = pDispParams->rgvarg[6].vt; 650 VARTYPE vt = pDispParams->rgvarg[6].vt;
713 if (vt == VT_DISPATCH) 651 if (vt == VT_DISPATCH)
714 { 652 {
715 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; 653 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal;
716 } 654 }
717 else 655 else
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 ::DestroyWindow(hMenuWnd); 1349 ::DestroyWindow(hMenuWnd);
1412 1350
1413 switch (nCommand) 1351 switch (nCommand)
1414 { 1352 {
1415 case ID_PLUGIN_UPDATE: 1353 case ID_PLUGIN_UPDATE:
1416 { 1354 {
1417 s_isPluginToBeUpdated = true; 1355 s_isPluginToBeUpdated = true;
1418 } 1356 }
1419 break; 1357 break;
1420 1358
1421 case ID_PLUGIN_ACTIVATE:
1422 {
1423 url = CPluginHttpRequest::GetStandardUrl(USERS_SCRIPT_AC TIVATE);
1424 navigationErrorId = PLUGIN_ERROR_NAVIGATION_ACTIVATE;
1425 }
1426 break;
1427
1428 case ID_PLUGIN_ENABLE: 1359 case ID_PLUGIN_ENABLE:
1429 { 1360 {
1430 CPluginSettings* settings = CPluginSettings::GetInstance (); 1361 CPluginSettings* settings = CPluginSettings::GetInstance ();
1431 » » » //Display activation menu if enabling expired plugin 1362
1432 » » » if (!settings->GetPluginEnabled())
1433 » » » {
1434 » » » » if (!settings->GetBool(SETTING_PLUGIN_REGISTRATI ON, false) &&
1435 » » » » » (settings->GetValue(SETTING_PLUGIN_ADBLO CKCOUNT, 0) >=settings->GetValue(SETTING_PLUGIN_ADBLOCKLIMIT, 0)) &&
1436 » » » » » (settings->GetValue(SETTING_PLUGIN_ADBLO CKLIMIT, 0) > 0))
1437 » » » » {» »
1438 » » » » » DisplayActivateMessage();
1439 » » » » » return;
1440 » » » » }
1441 » » » }
1442 settings->TogglePluginEnabled(); 1363 settings->TogglePluginEnabled();
1443 1364
1444 // Enable / disable mime filter 1365 // Enable / disable mime filter
1445 s_criticalSectionLocal.Lock(); 1366 s_criticalSectionLocal.Lock();
1446 { 1367 {
1447 //Display activation menu if enabling expired pl ugin
1448 if (settings->GetPluginEnabled()) 1368 if (settings->GetPluginEnabled())
1449 { 1369 {
1450 s_mimeFilter = CPluginClientFactory::Get MimeFilterClientInstance(); 1370 s_mimeFilter = CPluginClientFactory::Get MimeFilterClientInstance();
1451 } 1371 }
1452 else 1372 else
1453 { 1373 {
1454 s_mimeFilter = NULL; 1374 s_mimeFilter = NULL;
1455 1375
1456 CPluginClientFactory::ReleaseMimeFilterC lientInstance(); 1376 CPluginClientFactory::ReleaseMimeFilterC lientInstance();
1457 } 1377 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 1618
1699 CPluginClient* client = CPluginClient::GetInstance(); 1619 CPluginClient* client = CPluginClient::GetInstance();
1700 1620
1701 CPluginSettings* settings = CPluginSettings::GetInstance(); 1621 CPluginSettings* settings = CPluginSettings::GetInstance();
1702 1622
1703 settings->RefreshTab(); 1623 settings->RefreshTab();
1704 1624
1705 // Update settings 1625 // Update settings
1706 m_tab->OnUpdateSettings(false); 1626 m_tab->OnUpdateSettings(false);
1707 1627
1708 #ifndef ENTERPRISE
1709 // Plugin activate
1710 if (!settings->GetBool(SETTING_PLUGIN_REGISTRATION, false))
1711 {
1712 ctext = dictionary->Lookup("MENU_ACTIVATE");
1713 fmii.fMask = MIIM_STATE | MIIM_STRING;
1714 fmii.fState = MFS_ENABLED;
1715 fmii.dwTypeData = ctext.GetBuffer();
1716 fmii.cch = ctext.GetLength();
1717 ::SetMenuItemInfo(hMenu, ID_PLUGIN_ACTIVATE, FALSE, &fmii);
1718 }
1719 else
1720 {
1721 ::DeleteMenu(hMenu, ID_PLUGIN_ACTIVATE, FALSE);
1722 }
1723 #else
1724 ::DeleteMenu(hMenu, ID_PLUGIN_ACTIVATE, FALSE);
1725 #endif
1726 #ifndef ENTERPRISE
1727 // Plugin update 1628 // Plugin update
1728 if (settings->IsPluginUpdateAvailable()) 1629 if (settings->IsPluginUpdateAvailable())
1729 { 1630 {
1730 ctext = dictionary->Lookup("MENU_UPDATE"); 1631 ctext = dictionary->Lookup("MENU_UPDATE");
1731 fmii.fMask = MIIM_STATE | MIIM_STRING; 1632 fmii.fMask = MIIM_STATE | MIIM_STRING;
1732 fmii.fState = MFS_ENABLED; 1633 fmii.fState = MFS_ENABLED;
1733 fmii.dwTypeData = ctext.GetBuffer(); 1634 fmii.dwTypeData = ctext.GetBuffer();
1734 fmii.cch = ctext.GetLength(); 1635 fmii.cch = ctext.GetLength();
1735 ::SetMenuItemInfo(hMenu, ID_PLUGIN_UPDATE, FALSE, &fmii); 1636 ::SetMenuItemInfo(hMenu, ID_PLUGIN_UPDATE, FALSE, &fmii);
1736 } 1637 }
1737 else 1638 else
1738 { 1639 {
1739 ::DeleteMenu(hMenu, ID_PLUGIN_UPDATE, FALSE); 1640 ::DeleteMenu(hMenu, ID_PLUGIN_UPDATE, FALSE);
1740 } 1641 }
1741 #else
1742 ::DeleteMenu(hMenu, ID_PLUGIN_UPDATE, FALSE);
1743 #endif
1744 #ifdef SUPPORT_WHITELIST 1642 #ifdef SUPPORT_WHITELIST
1745 { 1643 {
1746 // White list domain 1644 // White list domain
1747 ctext = dictionary->Lookup("MENU_DISABLE_ON"); 1645 ctext = dictionary->Lookup("MENU_DISABLE_ON");
1748 fmii.fMask = MIIM_STRING | MIIM_STATE; 1646 fmii.fMask = MIIM_STRING | MIIM_STATE;
1749 fmii.fState = MFS_DISABLED; 1647 fmii.fState = MFS_DISABLED;
1750 fmii.dwTypeData = ctext.GetBuffer(); 1648 fmii.dwTypeData = ctext.GetBuffer();
1751 fmii.cch = ctext.GetLength(); 1649 fmii.cch = ctext.GetLength();
1752 1650
1753 UINT index = WM_WHITELIST_DOMAIN; 1651 UINT index = WM_WHITELIST_DOMAIN;
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 } 2465 }
2568 } 2466 }
2569 } 2467 }
2570 2468
2571 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 2469 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
2572 } 2470 }
2573 2471
2574 return hTabWnd; 2472 return hTabWnd;
2575 2473
2576 } 2474 }
OLDNEW
« no previous file with comments | « Shared/PluginClass.h ('k') | Shared/PluginClassThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld