summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins/torrent/tdefile_torrent.h
blob: cf62f5455cc5579d7f43d825def9a515037d2bc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (c) 2003, 2004 Michael Pyne <michael.pyne@kdemail.net>
 *
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; see the file COPYING.
 * If not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef _TDEFILE_TORRENT_H
#define _TDEFILE_TORRENT_H

#include <tdefilemetainfo.h>

#include "bdict.h"

class TQStringList;

/**
 * Class to provide meta info for BitTorrent files within Konqueror.
 * Handles the mime type application/x-bittorrent, files typically
 * have the extension .torrent
 *
 * @author Michael Pyne <mpyne@grammarian.homelinux.net>
 * @todo Handle editing the meta info as well
 * @bug The comment meta info should be Multi Line, but that only
 *      works when the comment can also be edited.
 */
class KTorrentPlugin : public KFilePlugin
{
    Q_OBJECT
  

    public:
    /**
     * Constructs the class, and prepares for reading info on a torrent.
     *
     * @param parent the parent of this object
     * @param name the name of this object (not user-readable)
     * @param args unused by this class
     */
    KTorrentPlugin (TQObject *parent, const char *name, const TQStringList &args);

    /**
     * Destructor that closes the dictionary holding the torrent information.
     */
    ~KTorrentPlugin () { delete m_dict; }

    /**
     * Reads information on a torrent file given by @p info.
     *
     * @param info information on the file to decode
     * @return true if the meta info was successfully detected and added,
     *         false otherwise.
     */
    virtual bool readInfo (KFileMetaInfo& info, unsigned int);

    /**
     * Writes information on a torrent file given by @p info.
     * BitTorrent are practically nothing but meta information.
     * Therefore, the entire file might be changed.
     *
     * @param info information on the file to encode
     * @return true if the meta info was successfully updated,
     *         false otherwise
     */
    virtual bool writeInfo (const KFileMetaInfo& info) const;

    private:
    bool m_failed;
    BDict *m_dict;
};

#endif /* _TDEFILE_TORRENT_H */