1
/***************************************************************************
2
* Copyright (C) 2008 by Joris Guisson and Ivan Vasic *
3
* joris.guisson@gmail.com *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20
***************************************************************************/
21
#include <QDBusConnection>
22
#include <groups/group.h>
23
#include <groups/groupmanager.h>
24
#include "dbusgroup.h"
29
DBusGroup::DBusGroup(Group* g,GroupManager* gman,QObject* parent)
30
: QObject(parent),group(g),gman(gman)
32
QDBusConnection::sessionBus().registerObject("/group/" + g->groupName(), this,
33
QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals);
37
DBusGroup::~DBusGroup()
41
QString DBusGroup::name() const
43
return group->groupName();
46
QString DBusGroup::icon() const
48
return group->groupIconName();
51
QString DBusGroup::defaultSaveLocation() const
53
const Group::Policy & p = group->groupPolicy();
54
return p.default_save_location;
57
void DBusGroup::setDefaultSaveLocation(const QString & dir)
59
Group::Policy p = group->groupPolicy();
60
p.default_save_location = dir;
61
group->setGroupPolicy(p);
65
double DBusGroup::maxShareRatio() const
67
const Group::Policy & p = group->groupPolicy();
68
return p.max_share_ratio;
71
void DBusGroup::setMaxShareRatio(double ratio)
73
Group::Policy p = group->groupPolicy();
74
p.max_share_ratio = ratio;
75
group->setGroupPolicy(p);
79
double DBusGroup::maxSeedTime() const
81
const Group::Policy & p = group->groupPolicy();
82
return p.max_seed_time;
85
void DBusGroup::setMaxSeedTime(double hours)
87
Group::Policy p = group->groupPolicy();
88
p.max_seed_time = hours;
89
group->setGroupPolicy(p);
93
uint DBusGroup::maxUploadSpeed() const
95
const Group::Policy & p = group->groupPolicy();
96
return p.max_upload_rate;
99
void DBusGroup::setMaxUploadSpeed(uint speed)
101
Group::Policy p = group->groupPolicy();
102
p.max_upload_rate = speed;
103
group->setGroupPolicy(p);
107
uint DBusGroup::maxDownloadSpeed() const
109
const Group::Policy & p = group->groupPolicy();
110
return p.max_download_rate;
113
void DBusGroup::setMaxDownloadSpeed(uint speed)
115
Group::Policy p = group->groupPolicy();
116
p.max_download_rate = speed;
117
group->setGroupPolicy(p);
121
bool DBusGroup::onlyApplyOnNewTorrents() const
123
const Group::Policy & p = group->groupPolicy();
124
return p.only_apply_on_new_torrents;
127
void DBusGroup::setOnlyApplyOnNewTorrents(bool on)
129
Group::Policy p = group->groupPolicy();
130
p.only_apply_on_new_torrents = on;
131
group->setGroupPolicy(p);