~ubuntu-branches/ubuntu/feisty/kdetv/feisty

« back to all changes in this revision

Viewing changes to kdetv/libkdetv/kdetvchannelplugin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-09-17 23:25:16 UTC
  • Revision ID: james.westby@ubuntu.com-20050917232516-9wdsn3ckagbqieh8
Tags: upstream-0.8.8
ImportĀ upstreamĀ versionĀ 0.8.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Copyright (C) 2003 George Staikos <staikos@kde.org>
 
4
 *               2004 Dirk Ziegelmeier <dziegel@gmx.de>
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library 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 GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public License
 
17
 * along with this library; see the file COPYING.LIB.  If not, write to
 
18
 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
 
19
 * Boston, MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
 
 
23
#include "kdetvchannelplugin.h"
 
24
#include "channelstore.h"
 
25
 
 
26
#include <qfile.h>
 
27
 
 
28
#include <kdebug.h>
 
29
#include <kparts/componentfactory.h>
 
30
 
 
31
 
 
32
KdetvChannelPlugin::KdetvChannelPlugin(Kdetv *ktv, const QString& cfgkey, QObject *o, const char* n)
 
33
    : KdetvPluginBase(ktv, cfgkey, o, n),
 
34
      _flags(FormatReadWrite)
 
35
{
 
36
}
 
37
 
 
38
 
 
39
KdetvChannelPlugin::~KdetvChannelPlugin()
 
40
{
 
41
}
 
42
 
 
43
 
 
44
bool KdetvChannelPlugin::canRead(const QString& fmt) const
 
45
{
 
46
        return (_flags & FormatRead) && (_fmtName == fmt);
 
47
}
 
48
 
 
49
 
 
50
bool KdetvChannelPlugin::canWrite(const QString& fmt) const
 
51
{
 
52
        return (_flags & FormatWrite) && (_fmtName == fmt);
 
53
}
 
54
 
 
55
 
 
56
bool KdetvChannelPlugin::handlesFile(const QString& filename, int rflags) const
 
57
{
 
58
        return ((_flags & rflags) == rflags) && filename.endsWith(_fmtName);
 
59
}
 
60
 
 
61
 
 
62
bool KdetvChannelPlugin::load(ChannelStore *store, KdetvChannelPlugin::ChannelFileMetaInfo *info,
 
63
                              const QString &filename, const QString& fmt)
 
64
{  
 
65
        QFile file(filename);
 
66
        if (!file.open(IO_ReadOnly)) {
 
67
            return false;
 
68
        }
 
69
 
 
70
        if (!load(store, info, &file, fmt)) {
 
71
                kdWarning() << "KdetvChannelPlugin::load(...) sub-class load method failed" << endl;
 
72
                return false;
 
73
        }
 
74
 
 
75
        kdDebug() << "KdetvChannelPlugin::load(...) sub-class load ok" << endl;
 
76
        return true;
 
77
}
 
78
 
 
79
 
 
80
bool KdetvChannelPlugin::save(ChannelStore *store, KdetvChannelPlugin::ChannelFileMetaInfo *info,
 
81
                              const QString &filename, const QString& fmt)
 
82
{
 
83
        QFile file(filename);
 
84
        if (!file.open(IO_WriteOnly)) {
 
85
            return false;
 
86
        }
 
87
 
 
88
        if (!save(store, info, &file, fmt)) {
 
89
                kdWarning() << "KdetvChannelPlugin::save(...) sub-class save method failed" << endl;
 
90
                return false;
 
91
        }
 
92
 
 
93
        kdDebug() << "KdetvChannelPlugin::save(...) sub-class save ok" << endl;
 
94
        return true;
 
95
}
 
96
 
 
97
 
 
98
bool KdetvChannelPlugin::load(ChannelStore *, KdetvChannelPlugin::ChannelFileMetaInfo *,
 
99
                              QIODevice *, const QString&)
 
100
{
 
101
        return false;
 
102
}
 
103
 
 
104
bool KdetvChannelPlugin::save(ChannelStore *, KdetvChannelPlugin::ChannelFileMetaInfo *,
 
105
                              QIODevice *, const QString&)
 
106
{
 
107
        return false;
 
108
}
 
109
 
 
110
 
 
111
#include "kdetvchannelplugin.moc"
 
112