summaryrefslogtreecommitdiffstats
path: root/src/newstuff/providerloader.h
blob: 5dd8c17272392cac4697f1c6277147889662fc62 (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
/***************************************************************************
    copyright            : (C) 2006 by Robby Stephenson
    email                : [email protected]
 ***************************************************************************/

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

// this class is largely copied from kdelibs/knewstuff/provider.h
// which is Copyright (c) 2002 Cornelius Schumacher <[email protected]>
// and licensed under GPL v2, just like Tellico
//
// I want progress info for the download, and this was the
// easiest way to get it

#ifndef TELLICO_NEWSTUFF_PROVIDERLOADER_H
#define TELLICO_NEWSTUFF_PROVIDERLOADER_H

#include <tqobject.h>
#include <tqptrlist.h>

namespace KIO {
  class Job;
}
namespace KNS {
  class Provider;
}

namespace Tellico {
  namespace NewStuff {

class ProviderLoader : public TQObject {
Q_OBJECT
  TQ_OBJECT
public:
    /**
     * Constructor.
     *
     * @param parentWidget the parent widget
     */
    ProviderLoader( TQWidget *parentWidget );

    /**
     * Starts asynchronously loading the list of providers of the
     * specified type.
     *
     * @param type data type such as 'kdesktop/wallpaper'.
     * @param providerList the URl to the list of providers; if empty
     *    we first try the ProvidersUrl from KGlobal::config, then we
     *    fall back to a hardcoded value.
     */
    void load( const TQString &type, const TQString &providerList = TQString() );

    void setAlternativeProvider(const TQString& alt) { mAltProvider = alt; }

  signals:
    /**
     * Indicates that the list of providers has been successfully loaded.
     */
    void providersLoaded( TQPtrList<KNS::Provider>* );
    void percent(KIO::Job *job, unsigned long percent);
    void error();

  protected slots:
    void slotJobData( KIO::Job *, const TQByteArray & );
    void slotJobResult( KIO::Job * );

  private:
    TQWidget *mParentWidget;

    TQString mJobData;

    TQPtrList<KNS::Provider> mProviders;
    TQString mAltProvider;
    bool mTryAlt;
};

  }
}
#endif