~ubuntu-branches/ubuntu/lucid/ktorrent/lucid

« back to all changes in this revision

Viewing changes to libktcore/dbus/dbusgroup.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-02-16 18:37:14 UTC
  • mfrom: (1.1.25 upstream) (0.4.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090216183714-52tf47jrnmk4xkmp
Tags: 3.2+dfsg.1-2ubuntu1
* Merge with Debian, remaining changes: (LP: #296433)
  - Use Kubuntu's kde4.mk
  - Build-depend on libboost-serialization1.35-dev since unversioned -dev is
    in universe
  - Change plasma-applet-ktorrent to plasma-widget-ktorrent since we're
    supposed to call them widgets for the users

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2008 by Joris Guisson and Ivan Vasic                    *
 
3
 *   joris.guisson@gmail.com                                               *
 
4
 *   ivasic@gmail.com                                                      *
 
5
 *                                                                         *
 
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.                                   *
 
10
 *                                                                         *
 
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.                          *
 
15
 *                                                                         *
 
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"
 
25
 
 
26
namespace kt
 
27
{
 
28
 
 
29
        DBusGroup::DBusGroup(Group* g,GroupManager* gman,QObject* parent)
 
30
                        : QObject(parent),group(g),gman(gman)
 
31
        {
 
32
                QDBusConnection::sessionBus().registerObject("/group/" + g->groupName(), this,
 
33
                                                                        QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals);
 
34
        }
 
35
 
 
36
 
 
37
        DBusGroup::~DBusGroup()
 
38
        {
 
39
        }
 
40
 
 
41
        QString DBusGroup::name() const
 
42
        {
 
43
                return group->groupName();
 
44
        }
 
45
        
 
46
        QString DBusGroup::icon() const
 
47
        {
 
48
                return group->groupIconName();
 
49
        }
 
50
        
 
51
        QString DBusGroup::defaultSaveLocation() const
 
52
        {
 
53
                const Group::Policy & p = group->groupPolicy();
 
54
                return p.default_save_location;
 
55
        }
 
56
 
 
57
        void DBusGroup::setDefaultSaveLocation(const QString & dir)
 
58
        {
 
59
                Group::Policy p = group->groupPolicy();
 
60
                p.default_save_location = dir;
 
61
                group->setGroupPolicy(p);
 
62
                gman->saveGroups();
 
63
        }
 
64
        
 
65
        double DBusGroup::maxShareRatio() const
 
66
        {
 
67
                const Group::Policy & p = group->groupPolicy();
 
68
                return p.max_share_ratio;
 
69
        }
 
70
        
 
71
        void DBusGroup::setMaxShareRatio(double ratio)
 
72
        {
 
73
                Group::Policy p = group->groupPolicy();
 
74
                p.max_share_ratio = ratio;
 
75
                group->setGroupPolicy(p);
 
76
                gman->saveGroups();
 
77
        }
 
78
        
 
79
        double DBusGroup::maxSeedTime() const
 
80
        {
 
81
                const Group::Policy & p = group->groupPolicy();
 
82
                return p.max_seed_time;
 
83
        }
 
84
        
 
85
        void DBusGroup::setMaxSeedTime(double hours)
 
86
        {
 
87
                Group::Policy p = group->groupPolicy();
 
88
                p.max_seed_time = hours;
 
89
                group->setGroupPolicy(p);
 
90
                gman->saveGroups();
 
91
        }
 
92
        
 
93
        uint DBusGroup::maxUploadSpeed() const
 
94
        {
 
95
                const Group::Policy & p = group->groupPolicy();
 
96
                return p.max_upload_rate;
 
97
        }
 
98
        
 
99
        void DBusGroup::setMaxUploadSpeed(uint speed)
 
100
        {
 
101
                Group::Policy p = group->groupPolicy();
 
102
                p.max_upload_rate = speed;
 
103
                group->setGroupPolicy(p);
 
104
                gman->saveGroups();
 
105
        }
 
106
        
 
107
        uint DBusGroup::maxDownloadSpeed() const
 
108
        {
 
109
                const Group::Policy & p = group->groupPolicy();
 
110
                return p.max_download_rate;
 
111
        }
 
112
        
 
113
        void DBusGroup::setMaxDownloadSpeed(uint speed)
 
114
        {
 
115
                Group::Policy p = group->groupPolicy();
 
116
                p.max_download_rate = speed;
 
117
                group->setGroupPolicy(p);
 
118
                gman->saveGroups();
 
119
        }
 
120
        
 
121
        bool DBusGroup::onlyApplyOnNewTorrents() const
 
122
        {
 
123
                const Group::Policy & p = group->groupPolicy();
 
124
                return p.only_apply_on_new_torrents;
 
125
        }
 
126
        
 
127
        void DBusGroup::setOnlyApplyOnNewTorrents(bool on)
 
128
        {
 
129
                Group::Policy p = group->groupPolicy();
 
130
                p.only_apply_on_new_torrents = on;
 
131
                group->setGroupPolicy(p);
 
132
                gman->saveGroups();
 
133
        }
 
134
}