class Protocol

Abstract baseclass for all protocols.

Inheritance:


Public Methods

[more]virtual int getState()
The current state the protocol is in (as defined in the state enum above)
[more]virtual const string protocol()
The name of the protocol as a string identifer
[more]virtual const string screenName()
The users username, as known by the server
[more]virtual void update()
Allow the protocol to update things.
[more]virtual void logout()
Logout and disconnect
[more]virtual void sendMessage(Contact &recipient, string message)
Send an IM message to a user
[more]virtual void addBuddy(Contact &c)
Add a buddy to the presence notification list.
[more]virtual void delBuddy(Contact &c)
Delete a buddy when you're no longer interested in him :)
[more]virtual void getPubkey()
Request the servers public key (only KitProtocol supports this, it's a noop for the other protocols)
[more]virtual void newUser()
Register a new user
[more]virtual void c_loggedOut(string proto)
The client has been logged out
[more]virtual void c_recvdMessage(Contact &c, string message)
A message has come!
[more]virtual void c_statusChange(Contact &c)
The status for a contact has changed (May have gone offline, or gone away)
[more]virtual void c_error(int errno, string error)
An error has occured.
[more]virtual void c_stateChange(int state)
Our own state (as opposed to c_statusChange for buddy states) has changed
[more]virtual void c_gotPubkey(string key)
We've gotten the servers public key (only kitprotocol)
[more]virtual void handleData(char* buf, int avail)
Parse this data yourself
[more]virtual void connectionError(int error)
A socket or network error has occured, tell the protocol about it

Public Members

[more] The Action functions
[more] The Callbacks
[more] Network functions
[more]typedef map<string,Contact > buddy_t


Documentation

Abstract baseclass for all protocols. Defines the interface that all protocols should comply with.

The various c_* functions are callbacks, override these in a child class if you're interested in the event that happens. Typically, a client will override all of them. For example c_loggedIn() is called as soon as the login process is finished.

The states that the protocol can be in are defined here. The current state the protocol is in is returned by getState().

Sometimes everything doesnt go as planned, and a way of reporting error are needed. These are the currently defined protocol errors.When an error occurs, c_error() will be called with the error code (this) and plaintext description of the error.

ovirtual int getState()
The current state the protocol is in (as defined in the state enum above)

ovirtual const string protocol()
The name of the protocol as a string identifer

ovirtual const string screenName()
The users username, as known by the server

ovirtual void update()
Allow the protocol to update things. Should be called periodically to allow the protocols to send keepalive messages and other housekeeping tasks.

o The Action functions
The Action functions

You call these functions to initiate an event. For example, to send an instant message or to login to the server. Hopefully the names should be descriptive enough for you to figure out what they do. Usually all actions are supported by all protocols with the exception of getPubkey()

ovirtual void logout()
Logout and disconnect

ovirtual void sendMessage(Contact &recipient, string message)
Send an IM message to a user

ovirtual void addBuddy(Contact &c)
Add a buddy to the presence notification list. You will now be notified of this buddies connection status. (with c_stateChange() )

ovirtual void delBuddy(Contact &c)
Delete a buddy when you're no longer interested in him :)

ovirtual void getPubkey()
Request the servers public key (only KitProtocol supports this, it's a noop for the other protocols)

ovirtual void newUser()
Register a new user

o The Callbacks
The Callbacks

These are meant to be overiden in the acctual client to allow the client to recive messages in a systemindependant clean way.

ovirtual void c_loggedOut(string proto)
The client has been logged out

ovirtual void c_recvdMessage(Contact &c, string message)
A message has come! Someone is interested in talking to user

ovirtual void c_statusChange(Contact &c)
The status for a contact has changed (May have gone offline, or gone away)
See Also:
Contact

ovirtual void c_error(int errno, string error)
An error has occured.
Parameters:
errno - The error code
error - Human readable error description

ovirtual void c_stateChange(int state)
Our own state (as opposed to c_statusChange for buddy states) has changed

ovirtual void c_gotPubkey(string key)
We've gotten the servers public key (only kitprotocol)

o Network functions
Network functions

The protocol classes are completely network agnostic - they contain no code to interface with the outside world. This is both to increase portability and flexibility. User interfaces and network code needs to share a common event system, and the protocol can't know in advance how a client may choose to implement the network.

See Also:
Network - the network interface class

ovirtual void handleData(char* buf, int avail)
Parse this data yourself

ovirtual void connectionError(int error)
A socket or network error has occured, tell the protocol about it

otypedef map<string,Contact > buddy_t


Direct child classes:
KitProtocol
Author:
Henrik Abelsson <henrik@abelsson.com>
Version:
0.1

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.