2
* Copyright 2014 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Charles Kerr <charles.kerr@canonical.com>
20
#include <transfer/actions-live.h>
30
LiveActions::LiveActions(std::shared_ptr<Transfers>& transfers):
31
m_transfers{transfers}
35
LiveActions::~LiveActions()
39
std::shared_ptr<Transfer> LiveActions::find_transfer_by_id(const Transfer::Id& id) const
41
for (const auto& transfer : m_transfers->get())
42
if (transfer->id() == id)
45
return std::shared_ptr<Transfer>();
49
LiveActions::pause_all()
51
for (const auto& transfer : m_transfers->get())
56
LiveActions::resume_all()
58
for (const auto& transfer : m_transfers->get())
63
LiveActions::clear_all()
65
for (const auto& transfer : m_transfers->get())
70
LiveActions::activate(const Transfer::Id& id)
72
auto transfer = find_transfer_by_id(id);
73
g_return_if_fail(transfer);
75
switch(transfer->state().get())
77
case Transfer::STARTING:
78
case Transfer::RUNNING:
82
case Transfer::CANCELING:
86
case Transfer::PAUSED:
87
case Transfer::FAILED:
98
LiveActions::pause(const Transfer::Id& id)
100
auto transfer = find_transfer_by_id(id);
101
g_return_if_fail(transfer);
106
LiveActions::cancel(const Transfer::Id& id)
108
auto transfer = find_transfer_by_id(id);
109
g_return_if_fail(transfer);
114
LiveActions::resume(const Transfer::Id& id)
116
auto transfer = find_transfer_by_id(id);
117
g_return_if_fail(transfer);
125
} // namespace transfer
126
} // namespace indicator