~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/share/shareprovider.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright 2010 Artur Duque de Souza <asouza@kde.org>                  *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program; if not, write to the                         *
 
16
 *   Free Software Foundation, Inc.,                                       *
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
 
18
 ***************************************************************************/
 
19
 
 
20
#ifndef SHAREPROVIDER_H
 
21
#define SHAREPROVIDER_H
 
22
 
 
23
#include <QObject>
 
24
#include <kio/global.h>
 
25
#include <KDE/KIO/Job>
 
26
 
 
27
#include <Plasma/PackageStructure>
 
28
 
 
29
 
 
30
class ShareProvider : public QObject
 
31
{
 
32
    Q_OBJECT
 
33
 
 
34
public:
 
35
    ShareProvider(QObject *parent =0);
 
36
    static Plasma::PackageStructure::Ptr packageStructure();
 
37
 
 
38
    QString method() const;
 
39
    void setMethod(const QString &method);
 
40
 
 
41
    KUrl url() const;
 
42
    void setUrl(const QString &url);
 
43
 
 
44
    void addPostFile(const QString &contentKey, const QString &content);
 
45
 
 
46
Q_SIGNALS:
 
47
    void handleResultData(QString data);
 
48
    void handleRedirection(const QString &url);
 
49
    void readyToPublish();
 
50
    void finished(const QString &url);
 
51
    void finishedError(const QString &msg);
 
52
 
 
53
public Q_SLOTS:
 
54
    // ###: Function to return the content so the plugin can
 
55
    // play with it before publishing?
 
56
 
 
57
    // helper methods
 
58
    void publish();
 
59
    QString parseXML(const QString &key, const QString &data);
 
60
    void addQueryItem(const QString &key, const QString &value);
 
61
    void addPostItem(const QString &key, const QString &value,
 
62
                     const QString &contentType);
 
63
 
 
64
    // result methods
 
65
    void success(const QString &url);
 
66
    void error(const QString &msg);
 
67
    void redirected(KIO::Job *job, const KUrl &from);
 
68
 
 
69
protected Q_SLOTS:
 
70
    // slots for kio
 
71
    void openFile(KIO::Job *job);
 
72
    void finishedContentData(KIO::Job *job, const QByteArray &data);
 
73
    void finishedPublish(KJob *job);
 
74
    void readPublishData(KIO::Job *job, const QByteArray &data);
 
75
 
 
76
protected:
 
77
    void finishHeader();
 
78
 
 
79
private:
 
80
    QString m_content;
 
81
    QString m_contentKey;
 
82
    QString m_mimetype;
 
83
 
 
84
    bool m_isBlob;
 
85
    bool m_isPost;
 
86
 
 
87
    KUrl m_url;
 
88
    KUrl m_service;
 
89
 
 
90
    QByteArray m_data;
 
91
    QByteArray m_buffer;
 
92
    QByteArray m_boundary;
 
93
 
 
94
    static Plasma::PackageStructure::Ptr m_packageStructure;
 
95
};
 
96
 
 
97
#endif // SHAREPROVIDER