BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJSIP Reference

#include <account.hpp>

Public Member Functions

 Account ()
 
virtual ~Account ()
 
void create (const AccountConfig &cfg, bool make_default=false) throw (Error)
 
void shutdown ()
 
void modify (const AccountConfig &cfg) throw (Error)
 
bool isValid () const
 
void setDefault () throw (Error)
 
bool isDefault () const
 
int getId () const
 
AccountInfo getInfo () const throw (Error)
 
void setRegistration (bool renew) throw (Error)
 
void setOnlineStatus (const PresenceStatus &pres_st) throw (Error)
 
void setTransport (TransportId tp_id) throw (Error)
 
void presNotify (const PresNotifyParam &prm) throw (Error)
 
const BuddyVectorenumBuddies () const throw (Error)
 
BuddyVector2 enumBuddies2 () const throw (Error)
 
BuddyfindBuddy (string uri, FindBuddyMatch *buddy_match=NULL) const throw (Error)
 
Buddy findBuddy2 (string uri) const throw (Error)
 
virtual void onIncomingCall (OnIncomingCallParam &prm)
 
virtual void onRegStarted (OnRegStartedParam &prm)
 
virtual void onRegState (OnRegStateParam &prm)
 
virtual void onIncomingSubscribe (OnIncomingSubscribeParam &prm)
 
virtual void onInstantMessage (OnInstantMessageParam &prm)
 
virtual void onInstantMessageStatus (OnInstantMessageStatusParam &prm)
 
virtual void onTypingIndication (OnTypingIndicationParam &prm)
 
virtual void onMwiInfo (OnMwiInfoParam &prm)
 

Static Public Member Functions

static Accountlookup (int acc_id)
 

Friends

class Endpoint
 
class Buddy
 

Detailed Description

Constructor & Destructor Documentation

◆ Account()

pj::Account::Account ( )

Constructor.

◆ ~Account()

virtual pj::Account::~Account ( )
virtual

Destructor. Note that if the account is deleted, it will also delete the corresponding account in the PJSUA-LIB.

If application implements a derived class, the derived class should call shutdown() in the beginning stage in its destructor, or alternatively application should call shutdown() before deleting the derived class instance. This is to avoid race condition between the derived class destructor and Account callbacks.

Member Function Documentation

◆ create()

void pj::Account::create ( const AccountConfig cfg,
bool  make_default = false 
)
throw (Error
)

Create the account.

If application implements a derived class, the derived class should call shutdown() in the beginning stage in its destructor, or alternatively application should call shutdown() before deleting the derived class instance. This is to avoid race condition between the derived class destructor and Account callbacks.

Parameters
cfgThe account config.
make_defaultMake this the default account.

◆ shutdown()

void pj::Account::shutdown ( )

Shutdown the account. This will initiate unregistration if needed, and delete the corresponding account in the PJSUA-LIB.

Note that application must delete all Buddy instances belong to this account before shutting down the account.

If application implements a derived class, the derived class should call this method in the beginning stage in its destructor, or alternatively application should call this method before deleting the derived class instance. This is to avoid race condition between the derived class destructor and Account callbacks.

◆ modify()

void pj::Account::modify ( const AccountConfig cfg)
throw (Error
)

Modify the account to use the specified account configuration. Depending on the changes, this may cause unregistration or reregistration on the account.

Parameters
cfgNew account config to be applied to the account.

◆ isValid()

bool pj::Account::isValid ( ) const

Check if this account is still valid.

Returns
True if it is.

◆ setDefault()

void pj::Account::setDefault ( )
throw (Error
)

Set this as default account to be used when incoming and outgoing requests don't match any accounts.

◆ isDefault()

bool pj::Account::isDefault ( ) const

Check if this account is the default account. Default account will be used for incoming and outgoing requests that don't match any other accounts.

Returns
True if this is the default account.

◆ getId()

int pj::Account::getId ( ) const

Get PJSUA-LIB account ID or index associated with this account.

Returns
Integer greater than or equal to zero.

◆ lookup()

static Account * pj::Account::lookup ( int  acc_id)
static

Get the Account class for the specified account Id.

Parameters
acc_idThe account ID to lookup
Returns
The Account instance or NULL if not found.

◆ getInfo()

AccountInfo pj::Account::getInfo ( ) const
throw (Error
)

Get account info.

Returns
Account info.

◆ setRegistration()

void pj::Account::setRegistration ( bool  renew)
throw (Error
)

Update registration or perform unregistration. Application normally only needs to call this function if it wants to manually update the registration or to unregister from the server.

Parameters
renewIf False, this will start unregistration process.

◆ setOnlineStatus()

void pj::Account::setOnlineStatus ( const PresenceStatus pres_st)
throw (Error
)

Set or modify account's presence online status to be advertised to remote/presence subscribers. This would trigger the sending of outgoing NOTIFY request if there are server side presence subscription for this account, and/or outgoing PUBLISH if presence publication is enabled for this account.

Parameters
pres_stPresence online status.

◆ setTransport()

void pj::Account::setTransport ( TransportId  tp_id)
throw (Error
)

Lock/bind this account to a specific transport/listener. Normally application shouldn't need to do this, as transports will be selected automatically by the library according to the destination.

When account is locked/bound to a specific transport, all outgoing requests from this account will use the specified transport (this includes SIP registration, dialog (call and event subscription), and out-of-dialog requests such as MESSAGE).

Note that transport id may be specified in AccountConfig too.

Parameters
tp_idThe transport ID.

◆ presNotify()

void pj::Account::presNotify ( const PresNotifyParam prm)
throw (Error
)

Send NOTIFY to inform account presence status or to terminate server side presence subscription. If application wants to reject the incoming request, it should set the param PresNotifyParam.state to PJSIP_EVSUB_STATE_TERMINATED.

Parameters
prmThe sending NOTIFY parameter.

◆ enumBuddies()

const BuddyVector & pj::Account::enumBuddies ( ) const
throw (Error
)

Warning: deprecated, use enumBuddies2() instead. This function is not safe in multithreaded environment.

Enumerate all buddies of the account.

Returns
The buddy list.

◆ enumBuddies2()

BuddyVector2 pj::Account::enumBuddies2 ( ) const
throw (Error
)

Enumerate all buddies of the account.

Returns
The buddy list.

◆ findBuddy()

Buddy * pj::Account::findBuddy ( string  uri,
FindBuddyMatch buddy_match = NULL 
) const
throw (Error
)

Warning: deprecated, use findBuddy2 instead. This function is not safe in multithreaded environment.

Find a buddy in the buddy list with the specified URI.

Exception: if buddy is not found, PJ_ENOTFOUND will be thrown.

Parameters
uriThe buddy URI.
buddy_matchThe buddy match algo.
Returns
The pointer to buddy.

◆ findBuddy2()

Buddy pj::Account::findBuddy2 ( string  uri) const
throw (Error
)

Find a buddy in the buddy list with the specified URI.

Exception: if buddy is not found, PJ_ENOTFOUND will be thrown.

Parameters
uriThe buddy URI.
Returns
The pointer to buddy.

◆ onIncomingCall()

virtual void pj::Account::onIncomingCall ( OnIncomingCallParam prm)
inlinevirtual

Notify application on incoming call.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.

◆ onRegStarted()

virtual void pj::Account::onRegStarted ( OnRegStartedParam prm)
inlinevirtual

Notify application when registration or unregistration has been initiated. Note that this only notifies the initial registration and unregistration. Once registration session is active, subsequent refresh will not cause this callback to be called.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.

◆ onRegState()

virtual void pj::Account::onRegState ( OnRegStateParam prm)
inlinevirtual

Notify application when registration status has changed. Application may then query the account info to get the registration details.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.

◆ onIncomingSubscribe()

virtual void pj::Account::onIncomingSubscribe ( OnIncomingSubscribeParam prm)
inlinevirtual

Notification when incoming SUBSCRIBE request is received. Application may use this callback to authorize the incoming subscribe request (e.g. ask user permission if the request should be granted).

If this callback is not implemented, all incoming presence subscription requests will be accepted.

If this callback is implemented, application has several choices on what to do with the incoming request:

  • it may reject the request immediately by specifying non-200 class final response in the IncomingSubscribeParam.code parameter.
  • it may immediately accept the request by specifying 200 as the IncomingSubscribeParam.code parameter. This is the default value if application doesn't set any value to the IncomingSubscribeParam.code parameter. In this case, the library will automatically send NOTIFY request upon returning from this callback.
  • it may delay the processing of the request, for example to request user permission whether to accept or reject the request. In this case, the application MUST set the IncomingSubscribeParam.code argument to 202, then IMMEDIATELY calls presNotify() with state PJSIP_EVSUB_STATE_PENDING and later calls presNotify() again to accept or reject the subscription request.

Any IncomingSubscribeParam.code other than 200 and 202 will be treated as 200.

Application MUST return from this callback immediately (e.g. it must not block in this callback while waiting for user confirmation).

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.

◆ onInstantMessage()

virtual void pj::Account::onInstantMessage ( OnInstantMessageParam prm)
inlinevirtual

Notify application on incoming instant message or pager (i.e. MESSAGE request) that was received outside call context.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.

◆ onInstantMessageStatus()

virtual void pj::Account::onInstantMessageStatus ( OnInstantMessageStatusParam prm)
inlinevirtual

Notify application about the delivery status of outgoing pager/instant message (i.e. MESSAGE) request.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.

◆ onTypingIndication()

virtual void pj::Account::onTypingIndication ( OnTypingIndicationParam prm)
inlinevirtual

Notify application about typing indication.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.

◆ onMwiInfo()

virtual void pj::Account::onMwiInfo ( OnMwiInfoParam prm)
inlinevirtual

Notification about MWI (Message Waiting Indication) status change. This callback can be called upon the status change of the SUBSCRIBE request (for example, 202/Accepted to SUBSCRIBE is received) or when a NOTIFY reqeust is received.

Parameters
prmCallback parameter.

References PJ_UNUSED_ARG.


The documentation for this class was generated from the following file:

 


PJSIP Open Source, high performance, small footprint, and very very portable SIP stack
Copyright (C) 2006-2008 Teluu Inc.