1
/* $Id: account.hpp 4704 2014-01-16 05:30:46Z ming $ */
3
* Copyright (C) 2013 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#ifndef __PJSUA2_ACCOUNT_HPP__
20
#define __PJSUA2_ACCOUNT_HPP__
23
* @file pjsua2/account.hpp
24
* @brief PJSUA2 Account operations
26
#include <pjsua-lib/pjsua.h>
27
#include <pjsua2/persistent.hpp>
28
#include <pjsua2/presence.hpp>
29
#include <pjsua2/siptypes.hpp>
31
/** PJSUA2 API is inside pj namespace */
36
* @defgroup PJSUA2_ACC Account
44
* Account registration config. This will be specified in AccountConfig.
46
struct AccountRegConfig : public PersistentObject
49
* This is the URL to be put in the request URI for the registration,
50
* and will look something like "sip:serviceprovider".
52
* This field should be specified if registration is desired. If the
53
* value is empty, no account registration will be performed.
58
* Specify whether the account should register as soon as it is
59
* added to the UA. Application can set this to PJ_FALSE and control
60
* the registration manually with pjsua_acc_set_registration().
67
* The optional custom SIP headers to be put in the registration
70
SipHeaderVector headers;
73
* Optional interval for registration, in seconds. If the value is zero,
74
* default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
79
* Specify interval of auto registration retry upon registration failure
80
* (including caused by transport problem), in second. Set to 0 to
81
* disable auto re-registration. Note that if the registration retry
82
* occurs because of transport failure, the first retry will be done
83
* after \a firstRetryIntervalSec seconds instead. Also note that
84
* the interval will be randomized slightly by approximately +/- ten
85
* seconds to avoid all clients re-registering at the same time.
87
* See also \a firstRetryIntervalSec setting.
89
* Default: PJSUA_REG_RETRY_INTERVAL
91
unsigned retryIntervalSec;
94
* This specifies the interval for the first registration retry. The
95
* registration retry is explained in \a retryIntervalSec. Note that
96
* the value here will also be randomized by +/- ten seconds.
100
unsigned firstRetryIntervalSec;
103
* Specify the number of seconds to refresh the client registration
104
* before the registration expires.
106
* Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds
108
unsigned delayBeforeRefreshSec;
111
* Specify whether calls of the configured account should be dropped
112
* after registration failure and an attempt of re-registration has
115
* Default: FALSE (disabled)
117
bool dropCallsOnFail;
120
* Specify the maximum time to wait for unregistration requests to
121
* complete during library shutdown sequence.
123
* Default: PJSUA_UNREG_TIMEOUT
125
unsigned unregWaitSec;
128
* Specify how the registration uses the outbound and account proxy
129
* settings. This controls if and what Route headers will appear in
130
* the REGISTER request of this account. The value is bitmask combination
131
* of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
132
* If the value is set to 0, the REGISTER request will not use any proxy
133
* (i.e. it will not have any Route headers).
135
* Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
141
* Read this object from a container node.
143
* @param node Container to read values from.
145
virtual void readObject(const ContainerNode &node) throw(Error);
148
* Write this object to a container node.
150
* @param node Container to write values to.
152
virtual void writeObject(ContainerNode &node) const throw(Error);
156
/** Array of SIP credentials */
157
typedef std::vector<AuthCredInfo> AuthCredInfoVector;
160
* Various SIP settings for the account. This will be specified in
163
struct AccountSipConfig : public PersistentObject
166
* Array of credentials. If registration is desired, normally there should
167
* be at least one credential specified, to successfully authenticate
168
* against the service provider. More credentials can be specified, for
169
* example when the requests are expected to be challenged by the
170
* proxies in the route set.
172
AuthCredInfoVector authCreds;
175
* Array of proxy servers to visit for outgoing requests. Each of the
176
* entry is translated into one Route URI.
178
StringVector proxies;
181
* Optional URI to be put as Contact for this account. It is recommended
182
* that this field is left empty, so that the value will be calculated
183
* automatically based on the transport address.
185
string contactForced;
188
* Additional parameters that will be appended in the Contact header
189
* for this account. This will affect the Contact header in all SIP
190
* messages sent on behalf of this account, including but not limited to
191
* REGISTER, INVITE, and SUBCRIBE requests or responses.
193
* The parameters should be preceeded by semicolon, and all strings must
194
* be properly escaped. Example:
195
* ";my-param=X;another-param=Hi%20there"
197
string contactParams;
200
* Additional URI parameters that will be appended in the Contact URI
201
* for this account. This will affect the Contact URI in all SIP
202
* messages sent on behalf of this account, including but not limited to
203
* REGISTER, INVITE, and SUBCRIBE requests or responses.
205
* The parameters should be preceeded by semicolon, and all strings must
206
* be properly escaped. Example:
207
* ";my-param=X;another-param=Hi%20there"
209
string contactUriParams;
213
* If this flag is set, the authentication client framework will
214
* send an empty Authorization header in each initial request.
217
bool authInitialEmpty;
220
* Specify the algorithm to use when empty Authorization header
221
* is to be sent for each initial request (see above)
223
string authInitialAlgorithm;
226
* Optionally bind this account to specific transport. This normally is
227
* not a good idea, as account should be able to send requests using
228
* any available transports according to the destination. But some
229
* application may want to have explicit control over the transport to
230
* use, so in that case it can set this field.
232
* Default: -1 (PJSUA_INVALID_ID)
234
* @see Account::setTransport()
236
TransportId transportId;
240
* Read this object from a container node.
242
* @param node Container to read values from.
244
virtual void readObject(const ContainerNode &node) throw(Error);
247
* Write this object to a container node.
249
* @param node Container to write values to.
251
virtual void writeObject(ContainerNode &node) const throw(Error);
255
* Account's call settings. This will be specified in AccountConfig.
257
struct AccountCallConfig : public PersistentObject
260
* Specify how to offer call hold to remote peer. Please see the
261
* documentation on pjsua_call_hold_type for more info.
263
* Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
265
pjsua_call_hold_type holdType;
268
* Specify how support for reliable provisional response (100rel/
269
* PRACK) should be used for all sessions in this account. See the
270
* documentation of pjsua_100rel_use enumeration for more info.
272
* Default: PJSUA_100REL_NOT_USED
274
pjsua_100rel_use prackUse;
277
* Specify the usage of Session Timers for all sessions. See the
278
* pjsua_sip_timer_use for possible values.
280
* Default: PJSUA_SIP_TIMER_OPTIONAL
282
pjsua_sip_timer_use timerUse;
285
* Specify minimum Session Timer expiration period, in seconds.
286
* Must not be lower than 90. Default is 90.
288
unsigned timerMinSESec;
291
* Specify Session Timer expiration period, in seconds.
292
* Must not be lower than timerMinSE. Default is 1800.
294
unsigned timerSessExpiresSec;
298
* Read this object from a container node.
300
* @param node Container to read values from.
302
virtual void readObject(const ContainerNode &node) throw(Error);
305
* Write this object to a container node.
307
* @param node Container to write values to.
309
virtual void writeObject(ContainerNode &node) const throw(Error);
313
* Account presence config. This will be specified in AccountConfig.
315
struct AccountPresConfig : public PersistentObject
318
* The optional custom SIP headers to be put in the presence
319
* subscription request.
321
SipHeaderVector headers;
324
* If this flag is set, the presence information of this account will
325
* be PUBLISH-ed to the server where the account belongs.
332
* Specify whether the client publication session should queue the
333
* PUBLISH request should there be another PUBLISH transaction still
334
* pending. If this is set to false, the client will return error
335
* on the PUBLISH request if there is another PUBLISH transaction still
338
* Default: PJSIP_PUBLISHC_QUEUE_REQUEST (TRUE)
343
* Maximum time to wait for unpublication transaction(s) to complete
344
* during shutdown process, before sending unregistration. The library
345
* tries to wait for the unpublication (un-PUBLISH) to complete before
346
* sending REGISTER request to unregister the account, during library
347
* shutdown process. If the value is set too short, it is possible that
348
* the unregistration is sent before unpublication completes, causing
349
* unpublication request to fail.
351
* Value is in milliseconds.
353
* Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC (2000)
355
unsigned publishShutdownWaitMsec;
358
* Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
359
* is not specified, a random string will be used.
365
* Read this object from a container node.
367
* @param node Container to read values from.
369
virtual void readObject(const ContainerNode &node) throw(Error);
372
* Write this object to a container node.
374
* @param node Container to write values to.
376
virtual void writeObject(ContainerNode &node) const throw(Error);
380
* Account MWI (Message Waiting Indication) settings. This will be specified
383
struct AccountMwiConfig : public PersistentObject
386
* Subscribe to message waiting indication events (RFC 3842).
388
* See also UaConfig.mwiUnsolicitedEnabled setting.
395
* Specify the default expiration time (in seconds) for Message
396
* Waiting Indication (RFC 3842) event subscription. This must not
399
* Default: PJSIP_MWI_DEFAULT_EXPIRES (3600)
401
unsigned expirationSec;
405
* Read this object from a container node.
407
* @param node Container to read values from.
409
virtual void readObject(const ContainerNode &node) throw(Error);
412
* Write this object to a container node.
414
* @param node Container to write values to.
416
virtual void writeObject(ContainerNode &node) const throw(Error);
420
* Account's NAT (Network Address Translation) settings. This will be
421
* specified in AccountConfig.
423
struct AccountNatConfig : public PersistentObject
426
* Control the use of STUN for the SIP signaling.
428
* Default: PJSUA_STUN_USE_DEFAULT
430
pjsua_stun_use sipStunUse;
433
* Control the use of STUN for the media transports.
435
* Default: PJSUA_STUN_USE_DEFAULT
437
pjsua_stun_use mediaStunUse;
440
* Enable ICE for the media transport.
447
* Set the maximum number of ICE host candidates.
449
* Default: -1 (maximum not set)
454
* Specify whether to use aggressive nomination.
458
bool iceAggressiveNomination;
461
* For controlling agent if it uses regular nomination, specify the delay
462
* to perform nominated check (connectivity check with USE-CANDIDATE
463
* attribute) after all components have a valid pair.
465
* Default value is PJ_ICE_NOMINATED_CHECK_DELAY.
467
unsigned iceNominatedCheckDelayMsec;
470
* For a controlled agent, specify how long it wants to wait (in
471
* milliseconds) for the controlling agent to complete sending
472
* connectivity check with nominated flag set to true for all components
473
* after the controlled agent has found that all connectivity checks in
474
* its checklist have been completed and there is at least one successful
475
* (but not nominated) check for every component.
477
* Default value for this option is
478
* ICE_CONTROLLED_AGENT_WAIT_NOMINATION_TIMEOUT. Specify -1 to disable
481
int iceWaitNominationTimeoutMsec;
484
* Disable RTCP component.
491
* Always send re-INVITE/UPDATE after ICE negotiation regardless of whether
492
* the default ICE transport address is changed or not. When this is set
493
* to False, re-INVITE/UPDATE will be sent only when the default ICE
494
* transport address is changed.
498
bool iceAlwaysUpdate;
501
* Enable TURN candidate in ICE.
506
* Specify TURN domain name or host name, in in "DOMAIN:PORT" or
507
* "HOST:PORT" format.
512
* Specify the connection type to be used to the TURN server. Valid
513
* values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
515
* Default: PJ_TURN_TP_UDP
517
pj_turn_tp_type turnConnType;
520
* Specify the username to authenticate with the TURN server.
525
* Specify the type of password. Currently this must be zero to
526
* indicate plain-text password will be used in the password.
528
int turnPasswordType;
531
* Specify the password to authenticate with the TURN server.
536
* This option is used to update the transport address and the Contact
537
* header of REGISTER request. When this option is enabled, the library
538
* will keep track of the public IP address from the response of REGISTER
539
* request. Once it detects that the address has changed, it will
540
* unregister current Contact, update the Contact with transport address
541
* learned from Via header, and register a new Contact to the registrar.
542
* This will also update the public name of UDP transport if STUN is
545
* See also contactRewriteMethod field.
549
int contactRewriteUse;
552
* Specify how Contact update will be done with the registration, if
553
* \a contactRewriteEnabled is enabled. The value is bitmask combination of
554
* \a pjsua_contact_rewrite_method. See also pjsua_contact_rewrite_method.
556
* Value PJSUA_CONTACT_REWRITE_UNREGISTER(1) is the legacy behavior.
558
* Default value: PJSUA_CONTACT_REWRITE_METHOD
559
* (PJSUA_CONTACT_REWRITE_NO_UNREG | PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE)
561
int contactRewriteMethod;
564
* This option is used to overwrite the "sent-by" field of the Via header
565
* for outgoing messages with the same interface address as the one in
566
* the REGISTER request, as long as the request uses the same transport
567
* instance as the previous REGISTER request.
574
* This option controls whether the IP address in SDP should be replaced
575
* with the IP address found in Via header of the REGISTER response, ONLY
576
* when STUN and ICE are not used. If the value is FALSE (the original
577
* behavior), then the local IP address will be used. If TRUE, and when
578
* STUN and ICE are disabled, then the IP address found in registration
579
* response will be used.
581
* Default: PJ_FALSE (no)
583
int sdpNatRewriteUse;
586
* Control the use of SIP outbound feature. SIP outbound is described in
587
* RFC 5626 to enable proxies or registrar to send inbound requests back
588
* to UA using the same connection initiated by the UA for its
589
* registration. This feature is highly useful in NAT-ed deployemtns,
590
* hence it is enabled by default.
592
* Note: currently SIP outbound can only be used with TCP and TLS
593
* transports. If UDP is used for the registration, the SIP outbound
594
* feature will be silently ignored for the account.
601
* Specify SIP outbound (RFC 5626) instance ID to be used by this
602
* account. If empty, an instance ID will be generated based on
603
* the hostname of this agent. If application specifies this parameter, the
604
* value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
605
* without the double-quotes.
609
string sipOutboundInstanceId;
612
* Specify SIP outbound (RFC 5626) registration ID. The default value
613
* is empty, which would cause the library to automatically generate
618
string sipOutboundRegId;
621
* Set the interval for periodic keep-alive transmission for this account.
622
* If this value is zero, keep-alive will be disabled for this account.
623
* The keep-alive transmission will be sent to the registrar's address,
624
* after successful registration.
626
* Default: 15 (seconds)
628
unsigned udpKaIntervalSec;
631
* Specify the data to be transmitted as keep-alive packets.
639
* Read this object from a container node.
641
* @param node Container to read values from.
643
virtual void readObject(const ContainerNode &node) throw(Error);
646
* Write this object to a container node.
648
* @param node Container to write values to.
650
virtual void writeObject(ContainerNode &node) const throw(Error);
654
* Account media config (applicable for both audio and video). This will be
655
* specified in AccountConfig.
657
struct AccountMediaConfig : public PersistentObject
660
* Media transport (RTP) configuration.
662
TransportConfig transportConfig;
665
* If remote sends SDP answer containing more than one format or codec in
666
* the media line, send re-INVITE or UPDATE with just one codec to lock
667
* which codec to use.
669
* Default: True (Yes).
671
bool lockCodecEnabled;
674
* Specify whether stream keep-alive and NAT hole punching with
675
* non-codec-VAD mechanism (see PJMEDIA_STREAM_ENABLE_KA) is enabled
680
bool streamKaEnabled;
683
* Specify whether secure media transport should be used for this account.
684
* Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
685
* PJMEDIA_SRTP_MANDATORY.
687
* Default: PJSUA_DEFAULT_USE_SRTP
689
pjmedia_srtp_use srtpUse;
692
* Specify whether SRTP requires secure signaling to be used. This option
693
* is only used when \a use_srtp option above is non-zero.
696
* 0: SRTP does not require secure signaling
697
* 1: SRTP requires secure transport such as TLS
698
* 2: SRTP requires secure end-to-end transport (SIPS)
700
* Default: PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
702
int srtpSecureSignaling;
705
* Specify whether IPv6 should be used on media. Default is not used.
707
pjsua_ipv6_use ipv6Use;
711
* Read this object from a container node.
713
* @param node Container to read values from.
715
virtual void readObject(const ContainerNode &node) throw(Error);
718
* Write this object to a container node.
720
* @param node Container to write values to.
722
virtual void writeObject(ContainerNode &node) const throw(Error);
726
* Account video config. This will be specified in AccountConfig.
728
struct AccountVideoConfig : public PersistentObject
731
* Specify whether incoming video should be shown to screen by default.
732
* This applies to incoming call (INVITE), incoming re-INVITE, and
733
* incoming UPDATE requests.
735
* Regardless of this setting, application can detect incoming video
736
* by implementing \a on_call_media_state() callback and enumerating
737
* the media stream(s) with pjsua_call_get_info(). Once incoming
738
* video is recognised, application may retrieve the window associated
739
* with the incoming video and show or hide it with
740
* pjsua_vid_win_set_show().
744
bool autoShowIncoming;
747
* Specify whether outgoing video should be activated by default when
748
* making outgoing calls and/or when incoming video is detected. This
749
* applies to incoming and outgoing calls, incoming re-INVITE, and
750
* incoming UPDATE. If the setting is non-zero, outgoing video
751
* transmission will be started as soon as response to these requests
752
* is sent (or received).
754
* Regardless of the value of this setting, application can start and
755
* stop outgoing video transmission with pjsua_call_set_vid_strm().
759
bool autoTransmitOutgoing;
762
* Specify video window's flags. The value is a bitmask combination of
763
* pjmedia_vid_dev_wnd_flag.
767
unsigned windowFlags;
770
* Specify the default capture device to be used by this account. If
771
* vidOutAutoTransmit is enabled, this device will be used for
774
* Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
776
pjmedia_vid_dev_index defaultCaptureDevice;
779
* Specify the default rendering device to be used by this account.
781
* Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
783
pjmedia_vid_dev_index defaultRenderDevice;
786
* Rate control method.
788
* Default: PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING.
790
pjmedia_vid_stream_rc_method rateControlMethod;
793
* Upstream/outgoing bandwidth. If this is set to zero, the video stream
794
* will use codec maximum bitrate setting.
796
* Default: 0 (follow codec maximum bitrate).
798
unsigned rateControlBandwidth;
802
* Read this object from a container node.
804
* @param node Container to read values from.
806
virtual void readObject(const ContainerNode &node) throw(Error);
809
* Write this object to a container node.
811
* @param node Container to write values to.
813
virtual void writeObject(ContainerNode &node) const throw(Error);
817
* Account configuration.
819
struct AccountConfig : public PersistentObject
822
* Account priority, which is used to control the order of matching
823
* incoming/outgoing requests. The higher the number means the higher
824
* the priority is, and the account will be matched first.
829
* The Address of Record or AOR, that is full SIP URL that identifies the
830
* account. The value can take name address or URL format, and will look
831
* something like "sip:account@serviceprovider".
833
* This field is mandatory.
838
* Registration settings.
840
AccountRegConfig regConfig;
845
AccountSipConfig sipConfig;
850
AccountCallConfig callConfig;
855
AccountPresConfig presConfig;
858
* MWI (Message Waiting Indication) settings.
860
AccountMwiConfig mwiConfig;
865
AccountNatConfig natConfig;
868
* Media settings (applicable for both audio and video).
870
AccountMediaConfig mediaConfig;
875
AccountVideoConfig videoConfig;
879
* Default constructor will initialize with default values.
884
* This will return a temporary pjsua_acc_config instance, which contents
885
* are only valid as long as this AccountConfig structure remains valid
886
* AND no modifications are done to it AND no further toPj() function call
887
* is made. Any call to toPj() function will invalidate the content of
888
* temporary pjsua_acc_config that was returned by the previous call.
890
void toPj(pjsua_acc_config &cfg) const;
893
* Initialize from pjsip.
895
void fromPj(const pjsua_acc_config &prm, const pjsua_media_config *mcfg);
898
* Read this object from a container node.
900
* @param node Container to read values from.
902
virtual void readObject(const ContainerNode &node) throw(Error);
905
* Write this object to a container node.
907
* @param node Container to write values to.
909
virtual void writeObject(ContainerNode &node) const throw(Error);
914
* Account information. Application can query the account information
915
* by calling Account::getInfo().
925
* Flag to indicate whether this is the default account.
935
* Flag to tell whether this account has registration setting
936
* (reg_uri is not empty).
938
bool regIsConfigured;
941
* Flag to tell whether this account is currently registered
942
* (has active registration session).
947
* An up to date expiration interval for account registration session.
952
* Last registration status code. If status code is zero, the account
953
* is currently not registered. Any other value indicates the SIP
954
* status code of the registration.
956
pjsip_status_code regStatus;
959
* String describing the registration status.
961
string regStatusText;
964
* Last registration error code. When the status field contains a SIP
965
* status code that indicates a registration failure, last registration
966
* error code contains the error code that causes the failure. In any
967
* other case, its value is zero.
969
pj_status_t regLastErr;
972
* Presence online status for this account.
977
* Presence online status text.
979
string onlineStatusText;
982
/** Import from pjsip data */
983
void fromPj(const pjsua_acc_info &pai);
987
* This structure contains parameters for onIncomingCall() account callback.
989
struct OnIncomingCallParam
992
* The library call ID allocated for the new call.
997
* The incoming INVITE request.
1003
* This structure contains parameters for onRegStarted() account callback.
1005
struct OnRegStartedParam
1008
* True for registration and False for unregistration.
1014
* This structure contains parameters for onRegState() account callback.
1016
struct OnRegStateParam
1019
* Registration operation status.
1024
* SIP status code received.
1026
pjsip_status_code code;
1029
* SIP reason phrase received.
1034
* The incoming message.
1039
* Next expiration interval.
1045
* This structure contains parameters for onIncomingSubscribe() callback.
1047
struct OnIncomingSubscribeParam
1050
* Server presence subscription instance. If application delays
1051
* the acceptance of the request, it will need to specify this object
1052
* when calling Account::presNotify().
1062
* The incoming message.
1067
* The status code to respond to the request. The default value is 200.
1068
* Application may set this to other final status code to accept or
1069
* reject the request.
1071
pjsip_status_code code;
1074
* The reason phrase to respond to the request.
1079
* Additional data to be sent with the response, if any.
1081
SipTxOption txOption;
1085
* Parameters for onInstantMessage() account callback.
1087
struct OnInstantMessageParam
1095
* To URI of the request.
1100
* Contact URI of the sender.
1105
* MIME type of the message body.
1115
* The whole message.
1121
* Parameters for onInstantMessageStatus() account callback.
1123
struct OnInstantMessageStatusParam
1126
* Token or a user data that was associated with the pager
1142
* The SIP status code of the transaction.
1144
pjsip_status_code code;
1147
* The reason phrase of the transaction.
1152
* The incoming response that causes this callback to be called.
1153
* If the transaction fails because of time out or transport error,
1154
* the content will be empty.
1160
* Parameters for onTypingIndication() account callback.
1162
struct OnTypingIndicationParam
1180
* Boolean to indicate if sender is typing.
1185
* The whole message buffer.
1191
* Parameters for onMwiInfo() account callback.
1193
struct OnMwiInfoParam
1196
* MWI subscription state.
1198
pjsip_evsub_state state;
1201
* The whole message buffer.
1207
* Parameters for presNotify() account method.
1209
struct PresNotifyParam
1212
* Server presence subscription instance.
1217
* Server presence subscription state to set.
1219
pjsip_evsub_state state;
1222
* Optionally specify the state string name, if state is not "active",
1223
* "pending", or "terminated".
1228
* If the new state is PJSIP_EVSUB_STATE_TERMINATED, optionally specify
1229
* the termination reason.
1234
* If the new state is PJSIP_EVSUB_STATE_TERMINATED, this specifies
1235
* whether the NOTIFY request should contain message body containing
1236
* account's presence information.
1241
* Optional list of headers to be sent with the NOTIFY request.
1243
SipTxOption txOption;
1248
* Wrapper class for Buddy matching algo.
1250
* Default algo is a simple substring lookup of search-token in the
1251
* Buddy URIs, with case sensitive. Application can implement its own
1252
* matching algo by overriding this class and specifying its instance
1253
* in Account::findBuddy().
1255
class FindBuddyMatch
1259
* Default algo implementation.
1261
virtual bool match(const string &token, const Buddy &buddy)
1263
BuddyInfo bi = buddy.getInfo();
1264
return bi.uri.find(token) != string::npos;
1270
virtual ~FindBuddyMatch() {}
1286
* Destructor. Note that if the account is deleted, it will also delete
1287
* the corresponding account in the PJSUA-LIB.
1292
* Create the account.
1294
* @param cfg The account config.
1295
* @param make_default Make this the default account.
1297
void create(const AccountConfig &cfg,
1298
bool make_default=false) throw(Error);
1301
* Modify the account to use the specified account configuration.
1302
* Depending on the changes, this may cause unregistration or
1303
* reregistration on the account.
1305
* @param cfg New account config to be applied to the
1308
void modify(const AccountConfig &cfg) throw(Error);
1311
* Check if this account is still valid.
1313
* @return True if it is.
1315
bool isValid() const;
1318
* Set this as default account to be used when incoming and outgoing
1319
* requests don't match any accounts.
1321
* @return PJ_SUCCESS on success.
1323
void setDefault() throw(Error);
1326
* Check if this account is the default account. Default account will be
1327
* used for incoming and outgoing requests that don't match any other
1330
* @return True if this is the default account.
1332
bool isDefault() const;
1335
* Get PJSUA-LIB account ID or index associated with this account.
1337
* @return Integer greater than or equal to zero.
1342
* Get the Account class for the specified account Id.
1344
* @param acc_id The account ID to lookup
1346
* @return The Account instance or NULL if not found.
1348
static Account *lookup(int acc_id);
1353
* @return Account info.
1355
AccountInfo getInfo() const throw(Error);
1358
* Update registration or perform unregistration. Application normally
1359
* only needs to call this function if it wants to manually update the
1360
* registration or to unregister from the server.
1362
* @param renew If False, this will start unregistration
1365
void setRegistration(bool renew) throw(Error);
1368
* Set or modify account's presence online status to be advertised to
1369
* remote/presence subscribers. This would trigger the sending of
1370
* outgoing NOTIFY request if there are server side presence subscription
1371
* for this account, and/or outgoing PUBLISH if presence publication is
1372
* enabled for this account.
1374
* @param pres_st Presence online status.
1376
void setOnlineStatus(const PresenceStatus &pres_st) throw(Error);
1379
* Lock/bind this account to a specific transport/listener. Normally
1380
* application shouldn't need to do this, as transports will be selected
1381
* automatically by the library according to the destination.
1383
* When account is locked/bound to a specific transport, all outgoing
1384
* requests from this account will use the specified transport (this
1385
* includes SIP registration, dialog (call and event subscription), and
1386
* out-of-dialog requests such as MESSAGE).
1388
* Note that transport id may be specified in AccountConfig too.
1390
* @param tp_id The transport ID.
1392
void setTransport(TransportId tp_id) throw(Error);
1395
* Send NOTIFY to inform account presence status or to terminate server
1396
* side presence subscription. If application wants to reject the incoming
1397
* request, it should set the param \a PresNotifyParam.state to
1398
* PJSIP_EVSUB_STATE_TERMINATED.
1400
* @param prm The sending NOTIFY parameter.
1402
void presNotify(const PresNotifyParam &prm) throw(Error);
1405
* Enumerate all buddies of the account.
1407
* @return The buddy list.
1409
const BuddyVector& enumBuddies() const throw(Error);
1412
* Find a buddy in the buddy list with the specified URI.
1414
* Exception: if buddy is not found, PJ_ENOTFOUND will be thrown.
1416
* @param uri The buddy URI.
1417
* @param buddy_match The buddy match algo.
1419
* @return The pointer to buddy.
1421
Buddy* findBuddy(string uri, FindBuddyMatch *buddy_match = NULL) const
1425
* An internal function to add a Buddy to Account buddy list.
1426
* This function must never be used by application.
1428
void addBuddy(Buddy *buddy);
1431
* An internal function to remove a Buddy from Account buddy list.
1432
* This function must never be used by application.
1434
void removeBuddy(Buddy *buddy);
1441
* Notify application on incoming call.
1443
* @param prm Callback parameter.
1445
virtual void onIncomingCall(OnIncomingCallParam &prm)
1446
{ PJ_UNUSED_ARG(prm); }
1449
* Notify application when registration or unregistration has been
1450
* initiated. Note that this only notifies the initial registration
1451
* and unregistration. Once registration session is active, subsequent
1452
* refresh will not cause this callback to be called.
1454
* @param prm Callback parameter.
1456
virtual void onRegStarted(OnRegStartedParam &prm)
1457
{ PJ_UNUSED_ARG(prm); }
1460
* Notify application when registration status has changed.
1461
* Application may then query the account info to get the
1462
* registration details.
1464
* @param prm Callback parameter.
1466
virtual void onRegState(OnRegStateParam &prm)
1467
{ PJ_UNUSED_ARG(prm); }
1470
* Notification when incoming SUBSCRIBE request is received. Application
1471
* may use this callback to authorize the incoming subscribe request
1472
* (e.g. ask user permission if the request should be granted).
1474
* If this callback is not implemented, all incoming presence subscription
1475
* requests will be accepted.
1477
* If this callback is implemented, application has several choices on
1478
* what to do with the incoming request:
1479
* - it may reject the request immediately by specifying non-200 class
1480
* final response in the IncomingSubscribeParam.code parameter.
1481
* - it may immediately accept the request by specifying 200 as the
1482
* IncomingSubscribeParam.code parameter. This is the default value if
1483
* application doesn't set any value to the IncomingSubscribeParam.code
1484
* parameter. In this case, the library will automatically send NOTIFY
1485
* request upon returning from this callback.
1486
* - it may delay the processing of the request, for example to request
1487
* user permission whether to accept or reject the request. In this
1488
* case, the application MUST set the IncomingSubscribeParam.code
1489
* argument to 202, then IMMEDIATELY calls presNotify() with
1490
* state PJSIP_EVSUB_STATE_PENDING and later calls presNotify()
1491
* again to accept or reject the subscription request.
1493
* Any IncomingSubscribeParam.code other than 200 and 202 will be treated
1496
* Application MUST return from this callback immediately (e.g. it must
1497
* not block in this callback while waiting for user confirmation).
1499
* @param prm Callback parameter.
1501
virtual void onIncomingSubscribe(OnIncomingSubscribeParam &prm)
1502
{ PJ_UNUSED_ARG(prm); }
1505
* Notify application on incoming instant message or pager (i.e. MESSAGE
1506
* request) that was received outside call context.
1508
* @param prm Callback parameter.
1510
virtual void onInstantMessage(OnInstantMessageParam &prm)
1511
{ PJ_UNUSED_ARG(prm); }
1514
* Notify application about the delivery status of outgoing pager/instant
1515
* message (i.e. MESSAGE) request.
1517
* @param prm Callback parameter.
1519
virtual void onInstantMessageStatus(OnInstantMessageStatusParam &prm)
1520
{ PJ_UNUSED_ARG(prm); }
1523
* Notify application about typing indication.
1525
* @param prm Callback parameter.
1527
virtual void onTypingIndication(OnTypingIndicationParam &prm)
1528
{ PJ_UNUSED_ARG(prm); }
1531
* Notification about MWI (Message Waiting Indication) status change.
1532
* This callback can be called upon the status change of the
1533
* SUBSCRIBE request (for example, 202/Accepted to SUBSCRIBE is received)
1534
* or when a NOTIFY reqeust is received.
1536
* @param prm Callback parameter.
1538
virtual void onMwiInfo(OnMwiInfoParam &prm)
1539
{ PJ_UNUSED_ARG(prm); }
1542
friend class Endpoint;
1546
string tmpReason; // for saving response's reason
1547
BuddyVector buddyList;
1556
#endif /* __PJSUA2_ACCOUNT_HPP__ */