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

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

Issue 10236010: Always work with pointers to filters and subscriptions, drop the references for API consistency (Closed)
Patch Set: Created April 11, 2013, 7:24 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 | « shell/src/FiltersCommand.cpp ('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 #include <iostream> 1 #include <iostream>
2 #include <sstream> 2 #include <sstream>
3 3
4 #include "SubscriptionsCommand.h" 4 #include "SubscriptionsCommand.h"
5 5
6 namespace 6 namespace
7 { 7 {
8 typedef std::vector<AdblockPlus::SubscriptionPtr> SubscriptionList; 8 typedef std::vector<AdblockPlus::SubscriptionPtr> SubscriptionList;
9 9
10 void ShowSubscriptionList(const SubscriptionList& subscriptions) 10 void ShowSubscriptionList(const SubscriptionList& subscriptions)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void SubscriptionsCommand::ShowSubscriptions() 73 void SubscriptionsCommand::ShowSubscriptions()
74 { 74 {
75 ShowSubscriptionList(filterEngine.GetListedSubscriptions()); 75 ShowSubscriptionList(filterEngine.GetListedSubscriptions());
76 } 76 }
77 77
78 void SubscriptionsCommand::AddSubscription(const std::string& url, 78 void SubscriptionsCommand::AddSubscription(const std::string& url,
79 const std::string& title) 79 const std::string& title)
80 { 80 {
81 AdblockPlus::Subscription& subscription = filterEngine.GetSubscription(url); 81 AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription(url);
82 if (title.size()) 82 if (title.size())
83 subscription.SetProperty("title", title); 83 subscription->SetProperty("title", title);
84 subscription.AddToList(); 84 subscription->AddToList();
85 } 85 }
86 86
87 void SubscriptionsCommand::RemoveSubscription(const std::string& url) 87 void SubscriptionsCommand::RemoveSubscription(const std::string& url)
88 { 88 {
89 AdblockPlus::Subscription& subscription = filterEngine.GetSubscription(url); 89 AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription(url);
90 if (!subscription.IsListed()) 90 if (!subscription->IsListed())
91 { 91 {
92 std::cout << "No subscription with URL '" << url << "'" << std::endl; 92 std::cout << "No subscription with URL '" << url << "'" << std::endl;
93 return; 93 return;
94 } 94 }
95 subscription.RemoveFromList(); 95 subscription->RemoveFromList();
96 } 96 }
97 97
98 void SubscriptionsCommand::UpdateSubscriptions() 98 void SubscriptionsCommand::UpdateSubscriptions()
99 { 99 {
100 const SubscriptionList& subscriptions = filterEngine.GetListedSubscriptions(); 100 const SubscriptionList& subscriptions = filterEngine.GetListedSubscriptions();
101 for (SubscriptionList::const_iterator it = subscriptions.begin(); 101 for (SubscriptionList::const_iterator it = subscriptions.begin();
102 it != subscriptions.end(); it++) 102 it != subscriptions.end(); it++)
103 (*it)->UpdateFilters(); 103 (*it)->UpdateFilters();
104 } 104 }
105 105
106 void SubscriptionsCommand::FetchSubscriptions() 106 void SubscriptionsCommand::FetchSubscriptions()
107 { 107 {
108 filterEngine.FetchAvailableSubscriptions(&ShowSubscriptionList); 108 filterEngine.FetchAvailableSubscriptions(&ShowSubscriptionList);
109 } 109 }
OLDNEW
« no previous file with comments | « shell/src/FiltersCommand.cpp ('k') | src/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld