summaryrefslogtreecommitdiffstats
path: root/tdehtml/misc/knsplugininstaller.h
blob: a77630c198c75bf2d8b06056090d918a50c42dae (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*
    This file is part of the KDE libraries

    Copyright (C) 2005 Benoit Canet <[email protected]>
    Copyright (C) 2005 Aurelien Gateau <[email protected]>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifndef KNSPLUGININSTALLER_H
#define KNSPLUGININSTALLER_H

#include <job.h>
#include <ktextedit.h>
#include <kmimetype.h>
#include <kprogress.h> 
#include <kurl.h>
#include <kwizard.h>

#include <tqbuttongroup.h>
#include <tqdom.h>
#include <tqlabel.h>
#include <tqobject.h>
#include <tqprocess.h>
#include <tqradiobutton.h>
#include <tqvaluelist.h>
#include <tqvbox.h>
#include <tqwidget.h>

class TQStringList;

/*
 * This class contains all the infos needed to install a given plugin
 * Takes and parse a TQDomNode in its constructor
 */
class KNSPluginInfo 
{

public:

    /*
     * Construct the plugin info object
     */
    KNSPluginInfo();
    KNSPluginInfo(TQDomNode pluginNode);
    ~KNSPluginInfo();

    /*
     * Check the validity of the plugin info object
     */
    bool isValid() const;

    //Accessor methods
    TQString pluginName() const;
    TQString licence() const;
    KURL licenceURL() const;
    KURL pluginURL() const;
    const TQStringList& pluginFileList() const;
   
private:
 
    // plugin info
    TQString m_pluginName;
    TQString m_licence;
    KURL m_licenceURL;
    KURL m_pluginURL;
    TQStringList m_pluginFileList;
    
    
};


/*
 * This class contain all the the methods used to perform a plugin installation
 *
 */
class KNSPluginInstallEngine : public TQObject
{
    TQ_OBJECT
public:

    /*
     * Construct the class
     */
    KNSPluginInstallEngine(KMimeType::Ptr mime);
    ~KNSPluginInstallEngine();
    
    /*
     * Check if the installer engine and wizzard is activated
     */
    static bool isActive();
    /**
     * Check the availability of a plugin 
     */
    bool pluginAvailable();
    /*
     * Return the list of plugins Available
     */
    const TQValueList<KNSPluginInfo>& pluginList() const;
    void startInstall(KNSPluginInfo info);

    

private:

    // methods used to check the kde config and detect if an adequate plugin is available
 
    /*
     * load kde KNSPluginInstaller config
     */
    bool loadConfig();
    /*
     * retrieve the xml configuration file
     */
    bool loadXmlConfig();
    /*
     * parse the xml configuration file
     */
    bool findPlugin();
    

    TQMap<TQString, TQString> m_archMap;
    TQString m_pluginsXmlConfig;
    TQValueList<KNSPluginInfo> m_pluginList;
    KMimeType::Ptr m_mime;
    KURL m_pluginsListFileURL;
    TQString m_tmpPluginFileName;
    TDEIO::CopyJob *m_downloadJob;
    TDEIO::CopyJob *m_installFileJob;
    KNSPluginInfo m_toInstallPluginInfo;
    TQProcess *m_scanProc;
    
signals:
    // Signals used to communicate with the wizzard 
    void installProgress(int percent);
    void installCompleted();
    void installFailed();
   
private slots:
    // Used to monitor the plugin downloading
    void slotDownLoadProgress(TDEIO::Job *job, unsigned long percent);
    void slotDownloadResult(TDEIO::Job *job);
    
    // Used to monitor the plugin installation
    void slotCopyProgress(TDEIO::Job *job, unsigned long percent);
    void slotCopyResult(TDEIO::Job *job);

    // Used to monitor the plugins scan
    void readScanProcFromStdout();
    void endScanProc();



};

/*
 * This class is a wizzard used to install a plugin 
 */
class KNSPluginWizard : public KWizard
{
    TQ_OBJECT
public:
        
    /**
    * Construct a KNSpluginInstaller
    */
    KNSPluginWizard(TQWidget *parent, const char *name,  KMimeType::Ptr mime);
    ~KNSPluginWizard();


    /**
     * Lauch the wizzard
     */
    int exec();
    /*
     * Check the availability of a plugin
     */
    bool pluginAvailable();


private:
    // methods used in the constructor to init the wizzard pages
    void initConfirmationPage();
    void initLicencePage();
    void initInstallationProgressPage();
    void initFinishPage();

    // in this method we disable or enable the wizzard pages buttons
    void initPagesButtonStates();
    
    /*
     * Connect signals
     */
    void connectSignals();
    
    /*
     * Overiden method called when a page is shown
     */
    void showPage(TQWidget *page);


    // Plugin installation engine
    KNSPluginInstallEngine m_installEngine;

    // pages widgets
    TQVBox *m_confirmationVBox;
    TQVBox *m_licenceVBox;
    TQWidget *m_installationProgressWidget;
    TQWidget *m_finishWidget;
    
    // plugin list
    TDEListView *m_pluginListView;
    
    // licence stuff
    TQLabel *m_licencePageLabel;
    KTextEdit *m_licencePageText;
    TQRadioButton *m_licencePageAgree;
    TQRadioButton *m_licencePageDisagree;
    TQButtonGroup *m_agreementButtonGroup;

    // installation progress bar
    KProgress *m_installationProgressBar;

    // Finish Label 
    TQLabel *m_finishLabel;

    // installation status
    bool m_installationComplete;
 
private slots:
    /*
     * Check if the user Agree or disagree with the licence
     */
    void slotAgreementClicked(int id);
    /*
     * Called when the installation is completed
     */
    void slotInstallationCompleted();
    /*
     * Called when the installation has failed
     */
    void slotInstallationFailed();

signals:
    /*
     * Emited when the installation has complete - TODO connect this signal to reload the page
     */
    void pluginInstallCompleted();
};



   

#endif