summaryrefslogtreecommitdiffstats
path: root/konqueror/keditbookmarks/importers.h
blob: e831d6f44fc85901704e403826a20f0b27891ddc (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* This file is part of the KDE project
   Copyright (C) 2000 David Faure <faure@kde.org>
   Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License version 2 as published by the Free Software Foundation.

   This program 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 program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __importers_h
#define __importers_h

#include "commands.h"
#include <tdelocale.h>
#include <tdeio/job.h>

#include <kcommand.h>
#include <kbookmark.h>

#include <tqptrstack.h>
#include <tqobject.h>

// part pure
class ImportCommand : public TQObject, public KCommand, public IKEBCommand
{
   Q_OBJECT
public:
   ImportCommand()
      : KCommand(), m_utf8(false), m_folder(false), m_cleanUpCmd(0L)
   { ; }

   virtual void import(const TQString &fileName, bool folder) = 0;

   virtual TQString name() const;
   virtual TQString visibleName() const { return m_visibleName; }
   virtual TQString requestFilename() const = 0;

   static ImportCommand* performImport(const TQCString &, TQWidget *);
   static ImportCommand* importerFactory(const TQCString &);

   virtual ~ImportCommand()
   { ; }

   virtual void execute();
   virtual void unexecute();
   virtual TQString affectedBookmarks() const;

   TQString groupAddress() const { return m_group; }
   TQString folder() const;

protected:
   /**
    * @param fileName HTML file to import
    * @param folder name of the folder to create. Empty for no creation (root()).
    * @param icon icon for the new folder, if @p folder isn't empty
    * @param utf8 true if the HTML is in utf-8 encoding
    */
   void init(const TQString &fileName, bool folder, const TQString &icon, bool utf8)
   {
      m_fileName = fileName;
      m_folder = folder;
      m_icon = icon;
      m_utf8 = utf8;
   }

   virtual void doCreateHoldingFolder(KBookmarkGroup &bkGroup);
   virtual void doExecute(const KBookmarkGroup &) = 0;

protected:
   TQString m_visibleName;
   TQString m_fileName;
   TQString m_icon;
   TQString m_group;
   bool m_utf8;

private:
   bool m_folder;
   KMacroCommand *m_cleanUpCmd;
};

// part pure
class XBELImportCommand : public ImportCommand
{
public:
   XBELImportCommand() : ImportCommand() { ; }
   virtual void import(const TQString &fileName, bool folder) = 0;
   virtual TQString requestFilename() const = 0;
private:
   virtual void doCreateHoldingFolder(KBookmarkGroup &bkGroup);
   virtual void doExecute(const KBookmarkGroup &);
};

class GaleonImportCommand : public XBELImportCommand
{
public:
   GaleonImportCommand() : XBELImportCommand() { m_visibleName = i18n("Galeon"); }
   virtual void import(const TQString &fileName, bool folder) {
      init(fileName, folder, "", false);
   }
   virtual TQString requestFilename() const;
};

class KDE2ImportCommand : public XBELImportCommand
{
public:
   KDE2ImportCommand() : XBELImportCommand() { m_visibleName = i18n("KDE"); }
   virtual void import(const TQString &fileName, bool folder) {
      init(fileName, folder, "", false);
   }
   virtual TQString requestFilename() const;
};

// part pure
class HTMLImportCommand : public ImportCommand
{
public:
   HTMLImportCommand() : ImportCommand() { ; }
   virtual void import(const TQString &fileName, bool folder) = 0;
   virtual TQString requestFilename() const = 0;
private:
   virtual void doExecute(const KBookmarkGroup &);
};

class NSImportCommand : public HTMLImportCommand
{
public:
   NSImportCommand() : HTMLImportCommand() { m_visibleName = i18n("Netscape"); }
   virtual void import(const TQString &fileName, bool folder) {
      init(fileName, folder, "netscape", false);
   }
   virtual TQString requestFilename() const;
};

class MozImportCommand : public HTMLImportCommand
{
public:
   MozImportCommand() : HTMLImportCommand() { m_visibleName = i18n("Mozilla"); }
   virtual void import(const TQString &fileName, bool folder) {
      init(fileName, folder, "mozilla", true);
   }
   virtual TQString requestFilename() const;
};

class IEImportCommand : public ImportCommand
{
public:
   IEImportCommand() : ImportCommand() { m_visibleName = i18n("IE"); }
   virtual void import(const TQString &fileName, bool folder) {
      init(fileName, folder, "", false);
   }
   virtual TQString requestFilename() const;
private:
   virtual void doExecute(const KBookmarkGroup &);
};

class OperaImportCommand : public ImportCommand
{
public:
   OperaImportCommand() : ImportCommand() { m_visibleName = i18n("Opera"); }
   virtual void import(const TQString &fileName, bool folder) {
      init(fileName, folder, "opera", false);
   }
   virtual TQString requestFilename() const;
private:
   virtual void doExecute(const KBookmarkGroup &);
};

class CrashesImportCommand : public ImportCommand
{
public:
   CrashesImportCommand() : ImportCommand() { m_visibleName = i18n("Crashes"); }
   virtual void import(const TQString &fileName, bool folder) {
      init(fileName, folder, "core", false);
   }
   virtual TQString requestFilename() const;
private:
   virtual void doExecute(const KBookmarkGroup &);
};

#endif