|
Link Here
|
| 13 |
|
13 |
|
| 14 |
#include <kio/job.h> |
14 |
#include <kio/job.h> |
| 15 |
#include <kprocess.h> |
15 |
#include <kprocess.h> |
|
|
16 |
#include <kstaticdeleter.h> |
| 16 |
#include <kurl.h> |
17 |
#include <kurl.h> |
| 17 |
#include <kdebug.h> |
18 |
#include <kdebug.h> |
| 18 |
|
19 |
|
| 19 |
#include <qdom.h> |
20 |
#include <qdom.h> |
| 20 |
#include <qbuffer.h> |
21 |
#include <qbuffer.h> |
| 21 |
#include <qregexp.h> |
22 |
#include <qregexp.h> |
|
|
23 |
#include <qstring.h> |
| 22 |
#include <qstringlist.h> |
24 |
#include <qstringlist.h> |
| 23 |
#include <qtimer.h> |
25 |
#include <qtimer.h> |
| 24 |
|
26 |
|
|
Link Here
|
| 32 |
{ |
34 |
{ |
| 33 |
} |
35 |
} |
| 34 |
|
36 |
|
| 35 |
struct FileRetriever::Private |
37 |
class FileRetriever::Private |
| 36 |
{ |
38 |
{ |
|
|
39 |
public: |
| 40 |
|
| 37 |
Private() |
41 |
Private() |
| 38 |
: buffer(NULL), |
42 |
: buffer(NULL), |
| 39 |
lastError(0), job(NULL) |
43 |
lastError(0), job(NULL) |
|
Link Here
|
| 48 |
QBuffer *buffer; |
52 |
QBuffer *buffer; |
| 49 |
int lastError; |
53 |
int lastError; |
| 50 |
KIO::Job *job; |
54 |
KIO::Job *job; |
|
|
55 |
static KStaticDeleter<QString> userAgentsd; |
| 56 |
static QString* userAgent; |
| 51 |
}; |
57 |
}; |
| 52 |
|
58 |
|
|
|
59 |
KStaticDeleter<QString> FileRetriever::Private::userAgentsd; |
| 60 |
QString* FileRetriever::Private::userAgent = 0L; |
| 53 |
FileRetriever::FileRetriever() |
61 |
FileRetriever::FileRetriever() |
| 54 |
: d(new Private) |
62 |
: d(new Private) |
| 55 |
{ |
63 |
{ |
|
Link Here
|
| 61 |
} |
69 |
} |
| 62 |
|
70 |
|
| 63 |
bool FileRetriever::m_useCache = true; |
71 |
bool FileRetriever::m_useCache = true; |
| 64 |
QString FileRetriever::m_userAgent = 0; |
72 |
|
|
|
73 |
QString FileRetriever::userAgent() |
| 74 |
{ |
| 75 |
if (Private::userAgent == 0L) |
| 76 |
FileRetriever::Private::userAgentsd.setObject(Private::userAgent, new QString); |
| 77 |
return *Private::userAgent; |
| 78 |
} |
| 65 |
|
79 |
|
| 66 |
void FileRetriever::setUserAgent(const QString &ua) |
80 |
void FileRetriever::setUserAgent(const QString &ua) |
| 67 |
{ |
81 |
{ |
| 68 |
m_userAgent = ua; |
82 |
if (Private::userAgent == 0L) |
|
|
83 |
FileRetriever::Private::userAgentsd.setObject(Private::userAgent, new QString); |
| 69 |
} |
84 |
} |
| 70 |
|
85 |
|
| 71 |
void FileRetriever::setUseCache(bool enabled) |
86 |
void FileRetriever::setUseCache(bool enabled) |
|
Link Here
|
| 88 |
|
103 |
|
| 89 |
d->job = KIO::get(u, !m_useCache, false); |
104 |
d->job = KIO::get(u, !m_useCache, false); |
| 90 |
|
105 |
|
| 91 |
d->job->addMetaData("UserAgent", m_userAgent); |
106 |
QString ua = userAgent(); |
|
|
107 |
if (!ua.isEmpty()) |
| 108 |
d->job->addMetaData("UserAgent", ua); |
| 92 |
|
109 |
|
| 93 |
|
110 |
|
| 94 |
QTimer::singleShot(1000*90, this, SLOT(slotTimeout())); |
111 |
QTimer::singleShot(1000*90, this, SLOT(slotTimeout())); |
|
Link Here
|
| 298 |
return d->discoveredFeedURL; |
315 |
return d->discoveredFeedURL; |
| 299 |
} |
316 |
} |
| 300 |
|
317 |
|
| 301 |
#include <kdebug.h> |
|
|
| 302 |
|
| 303 |
void Loader::slotRetrieverDone(const QByteArray &data, bool success) |
318 |
void Loader::slotRetrieverDone(const QByteArray &data, bool success) |
| 304 |
{ |
319 |
{ |
| 305 |
d->lastError = d->retriever->errorCode(); |
320 |
d->lastError = d->retriever->errorCode(); |