BookmarkStorage Class Reference

This is an implementation of XEP-0048 (Bookmark Storage). More...

#include <bookmarkstorage.h>

Inherits gloox::PrivateXML, and gloox::PrivateXMLHandler.

List of all members.

Public Member Functions

 BookmarkStorage (ClientBase *parent)
virtual ~BookmarkStorage ()
void storeBookmarks (const BookmarkList &bList, const ConferenceList &cList)
void requestBookmarks ()
void registerBookmarkHandler (BookmarkHandler *bmh)
void removeBookmarkHandler ()
virtual void handlePrivateXML (const Tag *xml)
virtual void handlePrivateXMLResult (const std::string &uid, PrivateXMLResult pxResult)

Detailed Description

This is an implementation of XEP-0048 (Bookmark Storage).

You can use this class to store bookmarks to multi-user chat rooms or ordinary URLs on the server (and to retrieve them later on). To retrieve all stored bookmarks for the current user you have to create a class which inherits from BookmarkHandler. This handler receives retrieved bookmarks.

 class MyClass : public BookmarkHandler
 {
   public:
     // ...
     void myFuncRetrieve();
     void myFuncStore();
     void handleBookmarks( const BookmarkList &bList, const ConferenceList &cList );

   private:
     BookmarkStorage* m_bs;
     BookmarkList m_bList;
     ConferenceList m_cList;
 };

 void MyClass::myFuncRetrieve()
 {
   m_bs = new BookmarkStorage( m_client );
   m_bs->requestBookmarks();
 }

 void MyClass::handleBookmarks( const BookmarkList &bList, const ConferenceList &cList )
 {
   m_bList = bList;
   m_cList = cList;
 }

To store additional bookmarks you have to fetch the currently stored ones first, add your new bookmark to the list, and transfer them all together back to the server. This protocol does not support storage of 'deltas', that is, when saving bookmarks all previously saved bookmarks are overwritten.

 void MyClass::myFuncStore()
 {
   BookmarkListItem bi;
   bi.url = "http://www.jabber.org";
   bi.name = "my favourite IM protocol";
   m_bList.push_back( bi );

   conferenceListItem ci
   ci.name = "jabber/xmpp development room";
   ci.jid = "jdev@conference.jabber.org";
   ci.nick = "myNick";
   ci.password = EmptyString;
   ci.autojoin = true;
   m_cList.push_back( ci );

   m_bs->storeBookmarks( m_bList, m_cList );
 }
Author:
Jakob Schroeter <js@camaya.net>
Since:
0.3

Definition at line 97 of file bookmarkstorage.h.


Constructor & Destructor Documentation

BookmarkStorage ( ClientBase parent  ) 

Constructs a new BookmarkStorage object.

Parameters:
parent The ClientBase to use for communication.

Definition at line 18 of file bookmarkstorage.cpp.

~BookmarkStorage (  )  [virtual]

Virtual destructor.

Definition at line 24 of file bookmarkstorage.cpp.


Member Function Documentation

void handlePrivateXML ( const Tag xml  )  [virtual]

Reimplement this function to receive the private XML that was requested earlier using PrivateXML::requestXML().

Parameters:
xml The private xml, i.e. the first child of the <query> tag. May be 0. You should not delete the object.

Implements PrivateXMLHandler.

Definition at line 59 of file bookmarkstorage.cpp.

void handlePrivateXMLResult ( const std::string &  uid,
PrivateXMLResult  pxResult 
) [virtual]

This function is called to notify about the result of a 'store' or 'request' operation (successful requests are announced by means of handlePrivateXML()).

Parameters:
uid The ID of the query.
pxResult The result of the operation.
Since:
0.7

Implements PrivateXMLHandler.

Definition at line 110 of file bookmarkstorage.cpp.

void registerBookmarkHandler ( BookmarkHandler bmh  )  [inline]

Use this function to register a BookmarkHandler.

Parameters:
bmh The BookmarkHandler which shall receive retrieved bookmarks.

Definition at line 129 of file bookmarkstorage.h.

void removeBookmarkHandler (  )  [inline]

Use this function to un-register the BookmarkHandler.

Definition at line 135 of file bookmarkstorage.h.

void requestBookmarks (  ) 

Use this function to initiate retrieval of bookmarks. Use registerBookmarkHandler() to register an object which will receive the lists of bookmarks.

Definition at line 54 of file bookmarkstorage.cpp.

void storeBookmarks ( const BookmarkList bList,
const ConferenceList cList 
)

Use this function to store a number of URL and conference bookmarks on the server. Make sure you store the whole set of bookmarks, not a 'delta'.

Parameters:
bList A list of URLs to store.
cList A list of conferences to store.

Definition at line 28 of file bookmarkstorage.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 8 23:37:55 2010 for gloox by  doxygen 1.6.3