Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

jabberoo::Session Class Reference

A session with a Jabber server. More...

#include <session.hh>

Inheritance diagram for jabberoo::Session:

judo::ElementStreamEventListener judo::ElementStream List of all members.

Public Types

enum  AuthType { atPlaintextAuth, atDigestAuth, atAutoAuth, at0kAuth }
 The authorization type. More...

enum  ConnectionState {
  csNotConnected, csCreateUser, csAuthReq, csAwaitingAuth,
  csConnected
}
 The connection state. More...


Public Member Functions

 Session ()
 Construct a Session.

virtual ~Session ()
 Deconstruct a Session.

Session & operator>> (const char *buffer)
 Read from the Session.

Session & operator<< (const Packet &p)
 Send a Packet.

Session & operator<< (const char *buffer)
 Send text.

void connect (const std::string &server, AuthType atype, const std::string &username, const std::string &resource, const std::string &password, bool createuser=false, bool should_auth=true)
 Log into a server and authenticate.

bool disconnect ()
 Disconnect from the server.

ConnectionState getConnState ()
 Get the ConnectionState.

virtual void push (const char *data, int datasz)
 Push raw XML to the session.

void registerIQ (const std::string &id, ElementCallbackFunc f)
 Register an iq callback.

judo::XPath::QueryregisterXPath (const std::string &query, ElementCallbackFunc f, bool incoming=true)
 Register a judo::XPath callback The callback will be called with any packets that match the given judo::XPath query.

void unregisterXPath (judo::XPath::Query *id, bool incoming=true)
 Unregister a judo::XPath callback.

void queryNamespace (const std::string &nspace, ElementCallbackFunc f, const std::string &to="")
 Query a namespace on a specific JabberID.

const Rosterroster () const
 Get the Roster.

Rosterroster ()
 Get the Roster.

const DiscoDBdiscoDB () const
 Get the DiscoDB.

DiscoDBdiscoDB ()
 Get the DiscoDB.

const PresenceDBpresenceDB () const
 Get the PresenceDB.

PresenceDBpresenceDB ()
 Get the PresenceDB.

AuthType getAuthType () const
 Get the AuthType which was used.

const std::string & getUserName () const
 Get the username which was used.

std::string getNextID ()
 Get the next available id Using this function ensures that ids are not repeated in the same Session.

std::string getDigest ()
 Get the digest hash.


Public Attributes

SigC::Signal2< void, int,
const std::string &, SigC::Marshal<
void > > 
evtXMLParserError
 This event is emitted when there is an error parsing the XML received.

SigC::Signal1< void, const
char *, SigC::Marshal< void > > 
evtTransmitXML
 This event is emitted when XML is transmitted.

SigC::Signal1< void, const
char *, SigC::Marshal< void > > 
evtRecvXML
 This event is emitted when XML is received.

SigC::Signal1< void, const
Packet &, SigC::Marshal< void > > 
evtTransmitPacket
 This event is emitted when a Packet is transmitted.

SigC::Signal1< void, const
judo::Element &, SigC::Marshal<
void > > 
evtConnected
 This event is emitted when the connection to the server has been established.

SigC::Signal0< void, SigC::Marshal<
void > > 
evtDisconnected
 This event is emitted when the connection to the server has been discontinued.

SigC::Signal1< void, const
Message &, SigC::Marshal<
void > > 
evtMessage
 This event is emitted when a Message is received.

SigC::Signal1< void, const
judo::Element &, SigC::Marshal<
void > > 
evtIQ
 This event is emitted when an IQ judo::element is received.

SigC::Signal1< void, const
Presence &, SigC::Marshal<
void > > 
evtMyPresence
 This event is emitted when a Presence judo::element which appears to be from the server is received.

SigC::Signal2< void, const
Presence &, Presence::Type,
SigC::Marshal< void > > 
evtPresence
 This event is emitted when a Presence judo::element is received.

SigC::Signal1< void, const
Presence &, SigC::Marshal<
void > > 
evtPresenceRequest
 This event is emitted when a Presence subscription request is received.

SigC::Signal1< void, const
judo::Element &, SigC::Marshal<
void > > 
evtUnknownPacket
 This event is emitted when an unknown XML judo::element is received.

SigC::Signal2< void, int,
const char *, SigC::Marshal<
void > > 
evtAuthError
 This event is emitted when an authorization error occurs.

SigC::Signal0< void, SigC::Marshal<
void > > 
evtOnRoster
 This event is emitted when a roster is received.

SigC::Signal3< void, std::string &,
std::string &, std::string &,
SigC::Marshal< void > > 
evtOnVersion
 This event is emitted when a client version is requested.

SigC::Signal1< void, std::string &,
SigC::Marshal< void > > 
evtOnLast
 This event is emitted when idle time is requested.

SigC::Signal2< void, std::string &,
std::string &, SigC::Marshal<
void > > 
evtOnTime
 This event is emitted when the client machine's local time is requested.


Protected Member Functions

virtual void onDocumentStart (judo::Element *t)
 Event point for XML document start event.

virtual void onElement (judo::Element *t)
 Event point for immediate children of XML document root.

virtual void onCDATA (judo::CDATA *c)
 Event point for immediate CDATA of an XML document root.

virtual void onDocumentEnd ()
 Event point for XML document end event.


Detailed Description

A session with a Jabber server.

This class provides common operations needed for raw communication between the client and the server.

Definition at line 53 of file session.hh.


Member Enumeration Documentation

enum jabberoo::Session::AuthType
 

The authorization type.

Enumeration values:
atPlaintextAuth  Send the password as plaintext (plaintext).
atDigestAuth  Send a hash of the password (digest).
atAutoAuth  Automatically determine authorization type, defaulting to the most secure.
at0kAuth  Do not send any password information over the wire (zero knowledge).

Definition at line 62 of file session.hh.

enum jabberoo::Session::ConnectionState
 

The connection state.

Enumeration values:
csNotConnected  Not connected.
csCreateUser  Create a new user.
csAuthReq  Auhtorization request.
csAwaitingAuth  Awaiting authorization.
csConnected  Connected.

Definition at line 73 of file session.hh.

Referenced by getConnState().


Constructor & Destructor Documentation

jabberoo::Session::Session  
 

Construct a Session.

This constructs a Session.

See also:
push();

evtTransmitXML

Definition at line 42 of file jabberoo-session.cpp.

jabberoo::Session::~Session   [virtual]
 

Deconstruct a Session.

This frees memory the Session was using.

Definition at line 52 of file jabberoo-session.cpp.

References csNotConnected, and disconnect().


Member Function Documentation

void jabberoo::Session::connect const std::string &    server,
AuthType    atype,
const std::string &    username,
const std::string &    resource,
const std::string &    password,
bool    createuser = false,
bool    should_auth = true
 

Log into a server and authenticate.

If should_auth is set to false, you will have to use roster().fetch() manually to get Jabberoo to download the roster. The assumption is that if you don't want standard authentication, you probably don't want the standard roster either. Yes, that's one heck of an assumption, but in practice it seems to match up.

See also:
AuthType
Parameters:
server The server to connect to.
atype The authentication type.
username The username to use.
resource The resource of this session.
password The password for this username.
createuser Whether to attempt to create a new user.
should_auth Whether to actually authenticate using jabber:iq:auth.

Definition at line 104 of file jabberoo-session.cpp.

References csAuthReq, csConnected, csCreateUser, csNotConnected, evtConnected, and judo::ElementStream::reset().

DiscoDB & jabberoo::Session::discoDB  
 

Get the DiscoDB.

See also:
DiscoDB
Returns:
the DiscoDB

Definition at line 180 of file jabberoo-session.cpp.

const DiscoDB & jabberoo::Session::discoDB   const
 

Get the DiscoDB.

See also:
DiscoDB
Returns:
the DiscoDB

Definition at line 175 of file jabberoo-session.cpp.

bool jabberoo::Session::disconnect  
 

Disconnect from the server.

Returns:
Whether </stream:stream> was actually sent.

Definition at line 146 of file jabberoo-session.cpp.

References csNotConnected.

Referenced by push(), and ~Session().

Session::AuthType jabberoo::Session::getAuthType   const
 

Get the AuthType which was used.

Returns:
The AuthType which was used to connect.

Definition at line 195 of file jabberoo-session.cpp.

ConnectionState jabberoo::Session::getConnState   [inline]
 

Get the ConnectionState.

Returns:
The current ConnectionState.

Definition at line 143 of file session.hh.

References ConnectionState.

std::string jabberoo::Session::getDigest  
 

Get the digest hash.

Returns:
The hash of the password to be used for authentication.

Definition at line 215 of file jabberoo-session.cpp.

std::string jabberoo::Session::getNextID  
 

Get the next available id Using this function ensures that ids are not repeated in the same Session.

Returns:
A std::string containing a valid id.

Definition at line 208 of file jabberoo-session.cpp.

Referenced by jabberoo::DiscoDB::cache(), and queryNamespace().

const std::string & jabberoo::Session::getUserName   const
 

Get the username which was used.

Returns:
The username which was used to connect.

Definition at line 200 of file jabberoo-session.cpp.

void jabberoo::Session::onCDATA judo::CDATA   c [protected, virtual]
 

Event point for immediate CDATA of an XML document root.

Override this method to get notified when CDATA is encountered immediately below the root document. This is a fairly rare condition within most Jabber processing, but is required for those rare cases. If you don't override this method, the CDATA is automatically cleaned up for you.

Parameters:
c CDATA node. Be sure to delete this once you are done with it.

Reimplemented from judo::ElementStreamEventListener.

Definition at line 459 of file jabberoo-session.cpp.

void jabberoo::Session::onDocumentEnd   [protected, virtual]
 

Event point for XML document end event.

Override this method to get notified when the XML document is ending

Implements judo::ElementStreamEventListener.

Definition at line 467 of file jabberoo-session.cpp.

References jabberoo::PresenceDB::clear(), csNotConnected, evtDisconnected, and jabberoo::Roster::reset().

void jabberoo::Session::onDocumentStart judo::Element   t [protected, virtual]
 

Event point for XML document start event.

Override this method to get notified when the XML document is starting

Parameters:
e Root document element. Be sure to delete this once you are done with it

Implements judo::ElementStreamEventListener.

Definition at line 419 of file jabberoo-session.cpp.

References evtConnected, and judo::Element::getAttrib().

void jabberoo::Session::onElement judo::Element   t [protected, virtual]
 

Event point for immediate children of XML document root.

Override this method to get notified when a complete child Element has been parsed.

Parameters:
e Child element. Be sure to delete this once you are done with it

Implements judo::ElementStreamEventListener.

Definition at line 433 of file jabberoo-session.cpp.

References evtUnknownPacket, and judo::Node::getName().

Session& jabberoo::Session::operator<< const char *    buffer [inline]
 

Send text.

Sends raw text through the session. Usually, this should be well-formed XML.

Definition at line 111 of file session.hh.

References evtTransmitXML.

Session & jabberoo::Session::operator<< const Packet   p
 

Send a Packet.

Sends a Packet through the session.

Definition at line 76 of file jabberoo-session.cpp.

References evtMyPresence, evtTransmitPacket, evtTransmitXML, jabberoo::Packet::getBaseElement(), jabberoo::Packet::getFrom(), judo::Node::getName(), jabberoo::Packet::getTo(), and jabberoo::Packet::toString().

Session& jabberoo::Session::operator>> const char *    buffer [inline]
 

Read from the Session.

Reads data from the session into a const char* buffer.

Definition at line 101 of file session.hh.

References push().

PresenceDB & jabberoo::Session::presenceDB  
 

Get the PresenceDB.

See also:
PresenceDB
Returns:
The PresenceDB.

Definition at line 190 of file jabberoo-session.cpp.

const PresenceDB & jabberoo::Session::presenceDB   const
 

Get the PresenceDB.

See also:
PresenceDB
Returns:
The PresenceDB.

Definition at line 185 of file jabberoo-session.cpp.

void jabberoo::Session::push const char *    data,
int    datasz
[virtual]
 

Push raw XML to the session.

The socket connector should call this function to push raw XML through to Jabberoo.

Parameters:
data Character data to give to the session.
datasz Size of the character data to give to the session.

Reimplemented from judo::ElementStream.

Definition at line 224 of file jabberoo-session.cpp.

References csNotConnected, disconnect(), evtRecvXML, and evtXMLParserError.

Referenced by operator>>().

void jabberoo::Session::queryNamespace const std::string &    nspace,
ElementCallbackFunc    f,
const std::string &    to = ""
 

Query a namespace on a specific JabberID.

The callback will be called once a response to the namespace query is received.

Parameters:
nspace The namespace to query.
f The function to call.
to The JabberID to query. If empty, it queries the server this Session is connected to.

Definition at line 282 of file jabberoo-session.cpp.

References judo::Element::addElement(), getNextID(), judo::Element::putAttrib(), and judo::Element::toString().

Referenced by jabberoo::Roster::deleteUser().

void jabberoo::Session::registerIQ const std::string &    id,
ElementCallbackFunc    f
 

Register an iq callback.

The callback will be called once an iq message with the given id is received.

Parameters:
id The id of the iq message which was sent.
f The function to call.

Definition at line 241 of file jabberoo-session.cpp.

Referenced by jabberoo::DiscoDB::cache().

judo::XPath::Query * jabberoo::Session::registerXPath const std::string &    query,
ElementCallbackFunc    f,
bool    incoming = true
 

Register a judo::XPath callback The callback will be called with any packets that match the given judo::XPath query.

Parameters:
query The judo::xpath query to search on
f the function to call
incoming When true, default, it is on the incoming data, otherwise it is on the outgoing data
Returns:
The id of the registered judo::XPath

Definition at line 246 of file jabberoo-session.cpp.

Roster & jabberoo::Session::roster  
 

Get the Roster.

See also:
Roster
Returns:
The Roster.

Definition at line 170 of file jabberoo-session.cpp.

const Roster & jabberoo::Session::roster   const
 

Get the Roster.

See also:
Roster
Returns:
The Roster.

Definition at line 165 of file jabberoo-session.cpp.

void jabberoo::Session::unregisterXPath judo::XPath::Query   id,
bool    incoming = true
 

Unregister a judo::XPath callback.

Parameters:
id The id to remove

Definition at line 264 of file jabberoo-session.cpp.


Member Data Documentation

SigC::Signal2<void, int, const char*, SigC::Marshal<void> > jabberoo::Session::evtAuthError
 

This event is emitted when an authorization error occurs.

Parameters:
errorcode The error code.
errormsg The error message.

Definition at line 340 of file session.hh.

SigC::Signal1<void, const judo::Element&, SigC::Marshal<void> > jabberoo::Session::evtConnected
 

This event is emitted when the connection to the server has been established.

See also:
Session::connect()
Parameters:
t The stream header judo::element which was used immediately after connection.

Definition at line 288 of file session.hh.

Referenced by connect(), and onDocumentStart().

SigC::Signal0<void, SigC::Marshal<void> > jabberoo::Session::evtDisconnected
 

This event is emitted when the connection to the server has been discontinued.

This will be emitted whether the connection was due to error or not.

See also:
Session::disconnect()

Definition at line 294 of file session.hh.

Referenced by onDocumentEnd().

SigC::Signal1<void, const judo::Element&, SigC::Marshal<void> > jabberoo::Session::evtIQ
 

This event is emitted when an IQ judo::element is received.

See also:
judo::Element
Parameters:
iq The iq judo::element's judo::Element.

Definition at line 307 of file session.hh.

SigC::Signal1<void, const Message&, SigC::Marshal<void> > jabberoo::Session::evtMessage
 

This event is emitted when a Message is received.

See also:
jabberoo::Message
Parameters:
m The Message.

Definition at line 301 of file session.hh.

SigC::Signal1<void, const Presence&, SigC::Marshal<void> > jabberoo::Session::evtMyPresence
 

This event is emitted when a Presence judo::element which appears to be from the server is received.

This probably is an error, such as specifying some invalid type.

See also:
jabberoo::Presence
Parameters:
p The Presence.

Definition at line 314 of file session.hh.

Referenced by operator<<().

SigC::Signal1<void, std::string&, SigC::Marshal<void> > jabberoo::Session::evtOnLast
 

This event is emitted when idle time is requested.

Parameters:
seconds The number of seconds, as a std::string, of idleness.

Definition at line 361 of file session.hh.

SigC::Signal0<void, SigC::Marshal<void> > jabberoo::Session::evtOnRoster
 

This event is emitted when a roster is received.

Note that this could be simply a roster push or the complete roster. The only reason you'd attach to this is if you want notification of *all* roster changes, whether or not you need to refresh the roster. It probably makes more sense to use jabberoo::Roster::evtRefresh

See also:
jabberoo::Roster::evtRefresh

Definition at line 349 of file session.hh.

SigC::Signal2<void, std::string&, std::string&, SigC::Marshal<void> > jabberoo::Session::evtOnTime
 

This event is emitted when the client machine's local time is requested.

Parameters:
localUTF8Time Local time, given in a nice human-readable std::string.
UTF8TimeZone Client's time zone

Definition at line 368 of file session.hh.

SigC::Signal3<void, std::string&, std::string&, std::string&, SigC::Marshal<void> > jabberoo::Session::evtOnVersion
 

This event is emitted when a client version is requested.

Parameters:
name The name of the client.
version The version of the client.
os The operating system the client is running on.

Definition at line 356 of file session.hh.

SigC::Signal2<void, const Presence&, Presence::Type, SigC::Marshal<void> > jabberoo::Session::evtPresence
 

This event is emitted when a Presence judo::element is received.

See also:
jabberoo::Presence
Parameters:
p The Presence.
previous_type The Presence::Type of the previous Presence received from this user.

Definition at line 321 of file session.hh.

SigC::Signal1<void, const Presence&, SigC::Marshal<void> > jabberoo::Session::evtPresenceRequest
 

This event is emitted when a Presence subscription request is received.

See also:
jabberoo::Presence
Parameters:
p The Presence subscription request.

Definition at line 327 of file session.hh.

SigC::Signal1<void, const char*, SigC::Marshal<void> > jabberoo::Session::evtRecvXML
 

This event is emitted when XML is received.

Parameters:
XML The XML which was received.

Definition at line 276 of file session.hh.

Referenced by push().

SigC::Signal1<void, const Packet&, SigC::Marshal<void> > jabberoo::Session::evtTransmitPacket
 

This event is emitted when a Packet is transmitted.

Parameters:
p The Packet which is being sent.

Definition at line 281 of file session.hh.

Referenced by operator<<().

SigC::Signal1<void, const char*, SigC::Marshal<void> > jabberoo::Session::evtTransmitXML
 

This event is emitted when XML is transmitted.

This should be hooked up to a function in the socket connector which sends the character data.

Parameters:
XML The XML which is being sent.

Definition at line 271 of file session.hh.

Referenced by operator<<().

SigC::Signal1<void, const judo::Element&, SigC::Marshal<void> > jabberoo::Session::evtUnknownPacket
 

This event is emitted when an unknown XML judo::element is received.

See also:
judo::Element
Parameters:
t The judo::element's judo::Element

Definition at line 334 of file session.hh.

Referenced by onElement().

SigC::Signal2<void, int, const std::string&, SigC::Marshal<void> > jabberoo::Session::evtXMLParserError
 

This event is emitted when there is an error parsing the XML received.

Jabberoo catches libjudo's ParserError exception, disconnects the session, and then triggers this event.

Parameters:
error_code The error code as defined by libjudo
error_msg The error message as defined by libjudo
See also:
XML_Error

push

Definition at line 265 of file session.hh.

Referenced by push().


The documentation for this class was generated from the following files:
Generated on Thu Jul 24 13:31:55 2003 for jabberoo by doxygen1.3-rc3