summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Client/Client.cpp13
-rw-r--r--Swiften/Client/Client.h29
2 files changed, 41 insertions, 1 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 5c64506..e3e8a45 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -7,15 +7,23 @@
#include "Swiften/Client/Client.h"
#include "Swiften/Queries/Responders/SoftwareVersionResponder.h"
+#include "Swiften/Roster/XMPPRoster.h"
+#include "Swiften/Roster/XMPPRosterController.h"
namespace Swift {
Client::Client(const JID& jid, const String& password) : CoreClient(jid, password) {
softwareVersionResponder = new SoftwareVersionResponder(getIQRouter());
softwareVersionResponder->start();
+
+ roster = new XMPPRoster();
+ rosterController = new XMPPRosterController(getIQRouter(), roster);
}
Client::~Client() {
+ delete rosterController;
+ delete roster;
+
softwareVersionResponder->stop();
delete softwareVersionResponder;
}
@@ -24,4 +32,9 @@ void Client::setSoftwareVersion(const String& name, const String& version) {
softwareVersionResponder->setVersion(name, version);
}
+void Client::requestRoster() {
+ rosterController->requestRoster();
+}
+
+
}
diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h
index 54d6e56..9f3e935 100644
--- a/Swiften/Client/Client.h
+++ b/Swiften/Client/Client.h
@@ -10,6 +10,8 @@
namespace Swift {
class SoftwareVersionResponder;
+ class XMPPRoster;
+ class XMPPRosterController;
/**
* Provides the core functionality for writing XMPP client software.
@@ -30,8 +32,33 @@ namespace Swift {
*/
void setSoftwareVersion(const String& name, const String& version);
+ /**
+ * Returns a representation of the roster.
+ *
+ * The roster is initially empty. To populate it, call requestRoster(), which
+ * will request the roster from the server. When the roster has been requested,
+ * it will also be kept up to date when it is updated on the server side.
+ *
+ * This pointer remains the same across the lifetime of Client. All changes
+ * to the roster (e.g. after the initial roster request, or after subsequent
+ * roster updates) are notified through the XMPPRoster's signals.
+ *
+ * \see requestRoster()
+ */
+ XMPPRoster* getRoster() const {
+ return roster;
+ }
+
+ /**
+ * Requests the roster from the server.
+ *
+ * \see getRoster()
+ */
+ void requestRoster();
+
private:
SoftwareVersionResponder* softwareVersionResponder;
-
+ XMPPRoster* roster;
+ XMPPRosterController* rosterController;
};
}