summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sq_archivehandler.h
blob: 7955eaa20d2b74b0fb14272d1f7688b7b9ade9d5 (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
/***************************************************************************
                          sq_archivehandler.h  -  description
                             -------------------
    begin                : ??? ??? 26 2004
    copyright            : (C) 2004 by Baryshev Dmitry
    email                : ksquirrel.iv@gmail.com
  ***************************************************************************/

#ifndef SQ_ARCHIVEHANDLER_H
#define SQ_ARCHIVEHANDLER_H

#include <tqobject.h>
#include <tqstring.h>
#include <tqmap.h>

// forward declarations
class KFileItem;
class KURL;

#define SQ_AH SQ_ArchiveHandler

/*
 *  Helper class for archive extracting via kio-slaves (since 0.7.1).
 */

class SQ_ArchiveHandler : public TQObject, TQMap<TQString, TQString>
{
    Q_OBJECT
  TQ_OBJECT

    public: 
        SQ_ArchiveHandler(TQObject *parent = 0, const char *name = 0);
        ~SQ_ArchiveHandler();

        /*
         *  Find protocol name by mimetype name.
         * 
         *  For example findProtocolByMime(""application/x-tgz"") will
         *  return "tar".
         */
        TQString findProtocolByMime(const TQString &mime);

        /*
         *  Find protocol name by KFileItem's mimetype.
         */
        TQString findProtocolByFile(KFileItem *item);

        /*
         *  Determine mimetype and emit unpack() signal
         */
        void tryUnpack(KFileItem *);

        void tryUnpack(const KURL &, const TQString &mime);

        static SQ_ArchiveHandler* instance() { return m_instance; }

    private:
        void fillProtocols();

    signals:
        void unpack(const KURL &);

    private:
        static SQ_ArchiveHandler *m_instance;
};

#endif