summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-01 17:21:06 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-01 17:21:06 (GMT)
commit9e3d7f4183f515a4d768be8166936340dee5a9b9 (patch)
tree1238b84a06e67b493b781259b80e770f5f3e2e41 /Swiften/Roster
parentc3b4fc7dcf8475e4dcf7b42b496e332df4a4f7b1 (diff)
downloadswift-9e3d7f4183f515a4d768be8166936340dee5a9b9.zip
swift-9e3d7f4183f515a4d768be8166936340dee5a9b9.tar.bz2
Roster now includes avatars.
Diffstat (limited to 'Swiften/Roster')
-rw-r--r--Swiften/Roster/ContactRosterItem.cpp8
-rw-r--r--Swiften/Roster/ContactRosterItem.h2
-rw-r--r--Swiften/Roster/SetAvatar.h33
-rw-r--r--Swiften/Roster/SetPresence.h2
-rw-r--r--Swiften/Roster/TreeWidgetItem.h2
5 files changed, 47 insertions, 0 deletions
diff --git a/Swiften/Roster/ContactRosterItem.cpp b/Swiften/Roster/ContactRosterItem.cpp
index f38b0f7..2f2f787 100644
--- a/Swiften/Roster/ContactRosterItem.cpp
+++ b/Swiften/Roster/ContactRosterItem.cpp
@@ -34,6 +34,14 @@ void ContactRosterItem::setStatusShow(StatusShow::Type show) {
widget_->setTextColor(colour);
}
+void ContactRosterItem::setStatusText(const String& status) {
+ widget_->setStatusText(status);
+}
+
+void ContactRosterItem::setAvatarPath(const String& path) {
+ widget_->setAvatarPath(path);
+}
+
const JID& ContactRosterItem::getJID() const {
return jid_;
}
diff --git a/Swiften/Roster/ContactRosterItem.h b/Swiften/Roster/ContactRosterItem.h
index 20f9f65..f1810aa 100644
--- a/Swiften/Roster/ContactRosterItem.h
+++ b/Swiften/Roster/ContactRosterItem.h
@@ -23,6 +23,8 @@ class ContactRosterItem : public RosterItem {
StatusShow::Type getStatusShow();
void setStatusShow(StatusShow::Type show);
+ void setStatusText(const String& status);
+ void setAvatarPath(const String& path);
const JID& getJID() const;
void show();
void hide();
diff --git a/Swiften/Roster/SetAvatar.h b/Swiften/Roster/SetAvatar.h
new file mode 100644
index 0000000..7bc9c37
--- /dev/null
+++ b/Swiften/Roster/SetAvatar.h
@@ -0,0 +1,33 @@
+#ifndef SWIFTEN_SetAvatar_H
+#define SWIFTEN_SetAvatar_H
+
+#include "Swiften/Elements/Presence.h"
+#include "Swiften/JID/JID.h"
+#include "Swiften/Roster/RosterItemOperation.h"
+#include "Swiften/Roster/ContactRosterItem.h"
+
+namespace Swift {
+
+class RosterItem;
+
+class SetAvatar : public RosterItemOperation {
+ public:
+ SetAvatar(const JID& jid, const String& path, JID::CompareType compareType = JID::WithoutResource) : jid_(jid), path_(path), compareType_(compareType) {
+ }
+
+ virtual void operator() (RosterItem* item) const {
+ ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
+ if (contact && contact->getJID().equals(jid_, compareType_)) {
+ contact->setAvatarPath(path_);
+ }
+ }
+
+ private:
+ JID jid_;
+ String path_;
+ JID::CompareType compareType_;
+};
+
+}
+#endif
+
diff --git a/Swiften/Roster/SetPresence.h b/Swiften/Roster/SetPresence.h
index aa36a52..a18ae6d 100644
--- a/Swiften/Roster/SetPresence.h
+++ b/Swiften/Roster/SetPresence.h
@@ -20,8 +20,10 @@ class SetPresence : public RosterItemOperation {
if (contact && contact->getJID().equals(presence_->getFrom(), compareType_)) {
if (presence_->getType() != Presence::Available) {
contact->setStatusShow(StatusShow::None);
+ contact->setStatusText(presence_->getStatus());
} else {
contact->setStatusShow(presence_->getShow());
+ contact->setStatusText(presence_->getStatus());
}
}
}
diff --git a/Swiften/Roster/TreeWidgetItem.h b/Swiften/Roster/TreeWidgetItem.h
index 5a96a41..4e20050 100644
--- a/Swiften/Roster/TreeWidgetItem.h
+++ b/Swiften/Roster/TreeWidgetItem.h
@@ -13,6 +13,8 @@ class TreeWidgetItem {
public:
virtual ~TreeWidgetItem() {}
virtual void setText(const String& text) = 0;
+ virtual void setStatusText(const String& text) = 0;
+ virtual void setAvatarPath(const String& path) = 0;
virtual void setExpanded(bool b) = 0;
virtual void setTextColor(unsigned long color) = 0;
virtual void setBackgroundColor(unsigned long color) = 0;