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

Side by Side Diff: shell/src/FiltersCommand.cpp

Issue 10254076: API cleanup, get rid of JsObject and GetProperty() methods that don`t return JsValue (Closed)
Patch Set: Created April 26, 2013, 11:41 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 | « include/AdblockPlus/JsValue.h ('k') | shell/src/MatchesCommand.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 <iostream> 1 #include <iostream>
2 #include <sstream> 2 #include <sstream>
3 3
4 #include "FiltersCommand.h" 4 #include "FiltersCommand.h"
5 5
6 namespace 6 namespace
7 { 7 {
8 typedef std::vector<AdblockPlus::FilterPtr> FilterList; 8 typedef std::vector<AdblockPlus::FilterPtr> FilterList;
9 9
10 void ShowFilterList(const FilterList& filters) 10 void ShowFilterList(const FilterList& filters)
11 { 11 {
12 for (FilterList::const_iterator it = filters.begin(); 12 for (FilterList::const_iterator it = filters.begin();
13 it != filters.end(); it++) 13 it != filters.end(); it++)
14 { 14 {
15 std::string type; 15 std::string type;
16 switch ((*it)->GetProperty("type", -1)) 16 switch ((*it)->GetType())
17 { 17 {
18 case AdblockPlus::Filter::TYPE_BLOCKING: 18 case AdblockPlus::Filter::TYPE_BLOCKING:
19 type = "blocking"; 19 type = "blocking";
20 break; 20 break;
21 case AdblockPlus::Filter::TYPE_EXCEPTION: 21 case AdblockPlus::Filter::TYPE_EXCEPTION:
22 type = "exception"; 22 type = "exception";
23 break; 23 break;
24 case AdblockPlus::Filter::TYPE_ELEMHIDE: 24 case AdblockPlus::Filter::TYPE_ELEMHIDE:
25 type = "elemhide"; 25 type = "elemhide";
26 break; 26 break;
27 case AdblockPlus::Filter::TYPE_ELEMHIDE_EXCEPTION: 27 case AdblockPlus::Filter::TYPE_ELEMHIDE_EXCEPTION:
28 type = "elemhideexception"; 28 type = "elemhideexception";
29 break; 29 break;
30 case AdblockPlus::Filter::TYPE_COMMENT: 30 case AdblockPlus::Filter::TYPE_COMMENT:
31 type = "comment"; 31 type = "comment";
32 break; 32 break;
33 case AdblockPlus::Filter::TYPE_INVALID: 33 case AdblockPlus::Filter::TYPE_INVALID:
34 type = "invalid"; 34 type = "invalid";
35 break; 35 break;
36 default: 36 default:
37 type = "(unknown type)"; 37 type = "(unknown type)";
38 break; 38 break;
39 } 39 }
40 std::cout << (*it)->GetProperty("text", "(no text)") << " - " << 40 std::cout << (*it)->GetProperty("text")->AsString() << " - " <<
41 type << std::endl; 41 type << std::endl;
42 } 42 }
43 } 43 }
44 } 44 }
45 45
46 FiltersCommand::FiltersCommand(AdblockPlus::FilterEngine& filterEngine) 46 FiltersCommand::FiltersCommand(AdblockPlus::FilterEngine& filterEngine)
47 : Command("filters"), filterEngine(filterEngine) 47 : Command("filters"), filterEngine(filterEngine)
48 { 48 {
49 } 49 }
50 50
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void FiltersCommand::RemoveFilter(const std::string& text) 105 void FiltersCommand::RemoveFilter(const std::string& text)
106 { 106 {
107 AdblockPlus::FilterPtr filter = filterEngine.GetFilter(text); 107 AdblockPlus::FilterPtr filter = filterEngine.GetFilter(text);
108 if (!filter->IsListed()) 108 if (!filter->IsListed())
109 { 109 {
110 std::cout << "No such filter '" << text << "'" << std::endl; 110 std::cout << "No such filter '" << text << "'" << std::endl;
111 return; 111 return;
112 } 112 }
113 filter->RemoveFromList(); 113 filter->RemoveFromList();
114 } 114 }
OLDNEW
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | shell/src/MatchesCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld