forked from blue/squawk
muc participant avatars
This commit is contained in:
parent
efc90e18c3
commit
55703c2007
15 changed files with 506 additions and 221 deletions
|
@ -35,6 +35,8 @@ class Archive : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class AvatarInfo;
|
||||
|
||||
Archive(const QString& jid, QObject* parent = 0);
|
||||
~Archive();
|
||||
|
||||
|
@ -53,11 +55,9 @@ public:
|
|||
std::list<Shared::Message> getBefore(int count, const QString& id);
|
||||
bool isFromTheBeginning();
|
||||
void setFromTheBeginning(bool is);
|
||||
bool getHasAvatar() const;
|
||||
bool getAutoAvatar() const;
|
||||
QString getAvatarHash() const;
|
||||
QString getAvatarType() const;
|
||||
bool setAvatar(const QByteArray& data, bool generated = false);
|
||||
bool setAvatar(const QByteArray& data, bool generated = false, const QString& resource = "");
|
||||
AvatarInfo getAvatarInfo(const QString& resource = "") const;
|
||||
bool readAvatarInfo(AvatarInfo& target, const QString& resource = "") const;
|
||||
|
||||
public:
|
||||
const QString jid;
|
||||
|
@ -121,6 +121,22 @@ public:
|
|||
std::string key;
|
||||
};
|
||||
|
||||
class NoAvatar:
|
||||
public Utils::Exception
|
||||
{
|
||||
public:
|
||||
NoAvatar(const std::string& el, const std::string& res):Exception(), element(el), resource(res){
|
||||
if (resource.size() == 0) {
|
||||
resource = "for himself";
|
||||
}
|
||||
}
|
||||
|
||||
std::string getMessage() const{return "Element " + element + " has no avatar for " + resource ;}
|
||||
private:
|
||||
std::string element;
|
||||
std::string resource;
|
||||
};
|
||||
|
||||
class Unknown:
|
||||
public Utils::Exception
|
||||
{
|
||||
|
@ -133,6 +149,20 @@ public:
|
|||
std::string msg;
|
||||
};
|
||||
|
||||
|
||||
class AvatarInfo {
|
||||
public:
|
||||
AvatarInfo();
|
||||
AvatarInfo(const QString& type, const QByteArray& hash, bool autogenerated);
|
||||
|
||||
void deserialize(char* pointer, uint32_t size);
|
||||
void serialize(QByteArray* ba) const;
|
||||
|
||||
QString type;
|
||||
QByteArray hash;
|
||||
bool autogenerated;
|
||||
};
|
||||
|
||||
private:
|
||||
bool opened;
|
||||
bool fromTheBeginning;
|
||||
|
@ -140,19 +170,17 @@ private:
|
|||
MDB_dbi main;
|
||||
MDB_dbi order;
|
||||
MDB_dbi stats;
|
||||
bool hasAvatar;
|
||||
bool avatarAutoGenerated;
|
||||
QString avatarHash;
|
||||
QString avatarType;
|
||||
MDB_dbi avatars;
|
||||
|
||||
bool getStatBoolValue(const std::string& id, MDB_txn* txn);
|
||||
std::string getStatStringValue(const std::string& id, MDB_txn* txn);
|
||||
|
||||
bool setStatValue(const std::string& id, bool value, MDB_txn* txn);
|
||||
bool setStatValue(const std::string& id, const std::string& value, MDB_txn* txn);
|
||||
bool readAvatarInfo(AvatarInfo& target, const std::string& res, MDB_txn* txn) const;
|
||||
void printOrder();
|
||||
void printKeys();
|
||||
bool dropAvatar();
|
||||
bool dropAvatar(const std::string& resource);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue