Added Bits Of Binary (XEP-0231) support
[iris.git] / src / xmpp / xmpp-im / xmpp_bitsofbinary.h
blob5ebf43869794e36a12dbca28186f61aba4a9e65e
1 /*
2 * Copyright (C) 2010 Rion
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef XMPP_BITSOFBINARY_H
21 #define XMPP_BITSOFBINARY_H
23 #include <QDomElement>
24 #include <QObject>
25 #include <QHash>
26 #include <QSharedDataPointer>
27 #include "xmpp/jid/jid.h"
29 namespace XMPP
31 class JT_BitsOfBinary;
32 class Client;
34 class BoBData
36 class Private;
37 public:
38 BoBData();
39 BoBData(const BoBData &other);
40 BoBData(const QDomElement &);
41 ~BoBData();
42 BoBData &operator=(const BoBData &other);
44 bool isNull() const;
46 QString cid() const;
47 void setCid(const QString &);
49 QByteArray data() const;
50 void setData(const QByteArray &);
52 QString type() const;
53 void setType(const QString &);
55 unsigned int maxAge() const;
56 void setMaxAge(unsigned int);
58 void fromXml(const QDomElement &);
59 QDomElement toXml(QDomDocument *doc) const;
61 private:
62 QSharedDataPointer<Private> d;
67 class BoBCache : public QObject
69 Q_OBJECT
71 public:
72 BoBCache(QObject *parent);
73 virtual void put(const BoBData &) = 0;
74 virtual BoBData get(const QString &) = 0;
79 class BoBManager : public QObject
81 Q_OBJECT
83 public:
84 BoBManager(Client *);
85 void setCache(BoBCache*);
87 BoBData bobData(const QString &);
88 BoBData makeBoBData(const QByteArray &data, const QString &type,
89 unsigned int maxAge = 0);
90 QString addLocalFile(const QString &filename,
91 const QString &type = "application/octet-stream");
93 void append(const BoBData &);
95 private:
96 BoBCache *_cache;
97 QHash<QString, QPair<QString,QString> > _localFiles; //cid => (filename, mime)
102 #endif // XMPP_BITSOFBINARY_H