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

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

Issue 29419623: Issue 5165 - Remove SubscriptionPtr (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added move assignment operator Created April 24, 2017, 7:08 p.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/FilterEngine.h ('k') | src/FilterEngine.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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <iostream> 18 #include <iostream>
19 #include <sstream> 19 #include <sstream>
20 20
21 #include "SubscriptionsCommand.h" 21 #include "SubscriptionsCommand.h"
22 22
23 namespace 23 namespace
24 { 24 {
25 typedef std::vector<AdblockPlus::SubscriptionPtr> SubscriptionList; 25 typedef std::vector<AdblockPlus::Subscription> SubscriptionList;
26 26
27 void ShowSubscriptionList(const SubscriptionList& subscriptions) 27 void ShowSubscriptionList(const SubscriptionList& subscriptions)
28 { 28 {
29 for (SubscriptionList::const_iterator it = subscriptions.begin(); 29 for (SubscriptionList::const_iterator it = subscriptions.begin();
30 it != subscriptions.end(); it++) 30 it != subscriptions.end(); it++)
31 { 31 {
32 std::cout << (*it)->GetProperty("title").AsString(); 32 std::cout << it->GetProperty("title").AsString();
33 std::cout << " - " << (*it)->GetProperty("url").AsString(); 33 std::cout << " - " << it->GetProperty("url").AsString();
34 if (!(*it)->GetProperty("author").IsUndefined()) 34 if (!it->GetProperty("author").IsUndefined())
35 std::cout << " - " << (*it)->GetProperty("author").AsString(); 35 std::cout << " - " << it->GetProperty("author").AsString();
36 if (!(*it)->GetProperty("specialization").IsUndefined()) 36 if (!it->GetProperty("specialization").IsUndefined())
37 std::cout << " - " << (*it)->GetProperty("specialization").AsString(); 37 std::cout << " - " << it->GetProperty("specialization").AsString();
38 std::cout << std::endl; 38 std::cout << std::endl;
39 } 39 }
40 } 40 }
41 } 41 }
42 42
43 SubscriptionsCommand::SubscriptionsCommand( 43 SubscriptionsCommand::SubscriptionsCommand(
44 AdblockPlus::FilterEngine& filterEngine) 44 AdblockPlus::FilterEngine& filterEngine)
45 : Command("subscriptions"), filterEngine(filterEngine) 45 : Command("subscriptions"), filterEngine(filterEngine)
46 { 46 {
47 } 47 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 void SubscriptionsCommand::ShowSubscriptions() 98 void SubscriptionsCommand::ShowSubscriptions()
99 { 99 {
100 ShowSubscriptionList(filterEngine.GetListedSubscriptions()); 100 ShowSubscriptionList(filterEngine.GetListedSubscriptions());
101 } 101 }
102 102
103 void SubscriptionsCommand::AddSubscription(const std::string& url, 103 void SubscriptionsCommand::AddSubscription(const std::string& url,
104 const std::string& title) 104 const std::string& title)
105 { 105 {
106 AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription(url); 106 AdblockPlus::Subscription subscription = filterEngine.GetSubscription(url);
107 if (title.size()) 107 if (title.size())
108 subscription->SetProperty("title", title); 108 subscription.SetProperty("title", title);
109 subscription->AddToList(); 109 subscription.AddToList();
110 } 110 }
111 111
112 void SubscriptionsCommand::RemoveSubscription(const std::string& url) 112 void SubscriptionsCommand::RemoveSubscription(const std::string& url)
113 { 113 {
114 AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription(url); 114 AdblockPlus::Subscription subscription = filterEngine.GetSubscription(url);
115 if (!subscription->IsListed()) 115 if (!subscription.IsListed())
116 { 116 {
117 std::cout << "No subscription with URL '" << url << "'" << std::endl; 117 std::cout << "No subscription with URL '" << url << "'" << std::endl;
118 return; 118 return;
119 } 119 }
120 subscription->RemoveFromList(); 120 subscription.RemoveFromList();
121 } 121 }
122 122
123 void SubscriptionsCommand::UpdateSubscriptions() 123 void SubscriptionsCommand::UpdateSubscriptions()
124 { 124 {
125 const SubscriptionList& subscriptions = filterEngine.GetListedSubscriptions(); 125 SubscriptionList subscriptions = filterEngine.GetListedSubscriptions();
126 for (SubscriptionList::const_iterator it = subscriptions.begin(); 126 for (SubscriptionList::iterator it = subscriptions.begin();
127 it != subscriptions.end(); it++) 127 it != subscriptions.end(); it++)
128 (*it)->UpdateFilters(); 128 it->UpdateFilters();
129 } 129 }
130 130
131 void SubscriptionsCommand::FetchSubscriptions() 131 void SubscriptionsCommand::FetchSubscriptions()
132 { 132 {
133 ShowSubscriptionList(filterEngine.FetchAvailableSubscriptions()); 133 ShowSubscriptionList(filterEngine.FetchAvailableSubscriptions());
134 } 134 }
OLDNEW
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | src/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld