Ignore:
Timestamp:
Oct 23, 2013 5:34:48 AM (11 years ago)
Author:
bennylp
Message:

More re #1519:

  • account API implementation (incomplete, callback is still not called)
  • using callback class design pattern (observer?)
  • after this, it might be changed to use inheritance pattern instead
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/account.hpp

    r4608 r4631  
    799799}; 
    800800 
     801 
    801802/** 
    802803 * Account information. Application can query the account information 
     
    824825     * (reg_uri is not empty). 
    825826     */ 
    826     bool                hasRegistration; 
     827    bool                regIsConfigured; 
    827828 
    828829    /** 
     
    830831     * (has active registration session). 
    831832     */ 
    832     bool                isRegistered; 
     833    bool                regIsActive; 
    833834 
    834835    /** 
    835836     * An up to date expiration interval for account registration session. 
    836837     */ 
    837     int                 expiresSec; 
     838    int                 regExpiresSec; 
    838839 
    839840    /** 
     
    842843     * status code of the registration. 
    843844     */ 
    844     pjsip_status_code   status; 
     845    pjsip_status_code   regStatus; 
    845846 
    846847    /** 
    847848     * String describing the registration status. 
    848849     */ 
    849     string              statusText; 
     850    string              regStatusText; 
    850851 
    851852    /** 
     
    867868    string              onlineStatusText; 
    868869 
     870public: 
     871    void fromPj(const pjsua_acc_info &pai); 
    869872}; 
    870873 
     
    909912     * SIP status code received. 
    910913     */ 
    911     int                 code; 
     914    pjsip_status_code   code; 
    912915 
    913916    /** 
     
    10901093    /** Virtual destructor */ 
    10911094    virtual ~AccountCallback() {} 
     1095 
     1096    /** 
     1097     * Get the account associated with this callback. 
     1098     */ 
     1099    Account *account() 
     1100    { return acc; } 
    10921101 
    10931102    /** 
     
    11911200    virtual void onMwiInfo(OnMwiInfoParam &prm) 
    11921201    {} 
     1202 
     1203protected: 
     1204    AccountCallback() 
     1205    : acc(NULL) 
     1206    {} 
     1207 
     1208private: 
     1209    Account *acc; 
     1210 
     1211    /** Set the account. Must only be called by Account class */ 
     1212    void setAccount(Account *the_acc) 
     1213    { acc = the_acc; } 
     1214 
     1215    friend class Account; 
    11931216}; 
    11941217 
     
    12101233{ 
    12111234public: 
     1235    /** 
     1236     * Constructor. 
     1237     */ 
     1238    Account(AccountCallback *cb, Token user_data); 
     1239 
     1240    /** 
     1241     * Destructor. 
     1242     */ 
     1243    ~Account(); 
     1244 
     1245    /** 
     1246     * Create the account. 
     1247     * 
     1248     * @param cfg               The account config. 
     1249     * @param make_default      Make this the default account. 
     1250     */ 
     1251    void create(const AccountConfig &cfg, 
     1252                bool make_default=false) throw(Error); 
     1253 
     1254    /** 
     1255     * Modify the account to use the specified account configuration. 
     1256     * Depending on the changes, this may cause unregistration or 
     1257     * reregistration on the account. 
     1258     * 
     1259     * @param cfg               New account config to be applied to the account. 
     1260     */ 
     1261    void modify(const AccountConfig &acc) throw(Error); 
     1262 
    12121263    /** 
    12131264     * Check if this account is still valid. 
     
    12601311     * @return                  Account info. 
    12611312     */ 
    1262     AccountInfo getInfo() const; 
    1263  
    1264     /** 
    1265      * Modify the account to use the specified account configuration. 
    1266      * Depending on the changes, this may cause unregistration or 
    1267      * reregistration on the account. 
    1268      * 
    1269      * @param cfg               New account config to be applied to the account. 
    1270      */ 
    1271     void modify(const AccountConfig &acc) throw(Error); 
     1313    AccountInfo getInfo() const throw(Error); 
    12721314 
    12731315    /** 
     
    13111353    friend class Endpoint; 
    13121354 
    1313     Account(); 
     1355private: 
     1356    pjsua_acc_id         id; 
     1357    AccountCallback     *cb; 
     1358    Token                userData; 
    13141359}; 
    13151360 
Note: See TracChangeset for help on using the changeset viewer.