Ignore:
Timestamp:
Oct 25, 2013 10:34:38 AM (11 years ago)
Author:
bennylp
Message:

Re #1519: Implementation of Account API, with inheritance approach:

  • With small demo app (samples/pjsua2_demo.cpp)
  • Endpoint changed to use inheritance approach too
  • Simple account registration demo and callback works
  • Further tests will be done in high level app (Python GUI?)
  • Temporary build setting fixes (Makefile) to allow linking with pjsua2 and libstdc++
  • Temporary hacks in Makefile to ignore other build targets to speed up build. This should be fixed during integration.

Issues:

  • incomplete Endpoint::on_incoming_subscribe() implementation. There is no Account::presNotify() yet.
  • incomplete Endpoint::on_pager2(), on_pager_status2(), to handle call's pager rather than account's pager
  • some SWIGTYPE (unknown type by Swig) still unresolved
File:
1 edited

Legend:

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

    r4631 r4638  
    878878{ 
    879879    /** 
    880      * The library call index allocated for the new call. 
    881      */ 
    882     int                 callIndex; 
     880     * The library call ID allocated for the new call. 
     881     */ 
     882    int                 callId; 
    883883 
    884884    /** 
     
    917917     * SIP reason phrase received. 
    918918     */ 
    919     pj_str_t            reason; 
     919    string              reason; 
    920920 
    921921    /** 
     
    10851085}; 
    10861086 
    1087 /** 
    1088  * Account callback 
    1089  */ 
    1090 class AccountCallback 
     1087 
     1088/** 
     1089 * @}  // PJSUA2_Acc_Data_Structure 
     1090 */ 
     1091 
     1092/** 
     1093 * @addtogroup PJSUA2_ACC 
     1094 * @{ 
     1095 */ 
     1096 
     1097 
     1098/** 
     1099 * Account. 
     1100 */ 
     1101class Account 
    10911102{ 
    10921103public: 
    1093     /** Virtual destructor */ 
    1094     virtual ~AccountCallback() {} 
    1095  
    1096     /** 
    1097      * Get the account associated with this callback. 
    1098      */ 
    1099     Account *account() 
    1100     { return acc; } 
    1101  
     1104    /** 
     1105     * Constructor. 
     1106     */ 
     1107    Account(); 
     1108 
     1109    /** 
     1110     * Destructor. Note that if the account is deleted, it will also delete 
     1111     * the corresponding account in the PJSUA-LIB. 
     1112     */ 
     1113    virtual ~Account(); 
     1114 
     1115    /** 
     1116     * Create the account. 
     1117     * 
     1118     * @param cfg               The account config. 
     1119     * @param make_default      Make this the default account. 
     1120     */ 
     1121    void create(const AccountConfig &cfg, 
     1122                bool make_default=false) throw(Error); 
     1123 
     1124    /** 
     1125     * Modify the account to use the specified account configuration. 
     1126     * Depending on the changes, this may cause unregistration or 
     1127     * reregistration on the account. 
     1128     * 
     1129     * @param cfg               New account config to be applied to the account. 
     1130     */ 
     1131    void modify(const AccountConfig &acc) throw(Error); 
     1132 
     1133    /** 
     1134     * Check if this account is still valid. 
     1135     * 
     1136     * @return                  True if it is. 
     1137     */ 
     1138    bool isValid() const; 
     1139 
     1140    /** 
     1141     * Set this as default account to be used when incoming and outgoing 
     1142     * requests don't match any accounts. 
     1143     * 
     1144     * @return                  PJ_SUCCESS on success. 
     1145     */ 
     1146    void setDefault() throw(Error); 
     1147 
     1148    /** 
     1149     * Check if this account is the default account. Default account will be 
     1150     * used for incoming and outgoing requests that don't match any other 
     1151     * accounts. 
     1152     * 
     1153     * @return                  True if this is the default account. 
     1154     */ 
     1155    bool isDefault() const; 
     1156 
     1157    /** 
     1158     * Get PJSUA-LIB account ID or index associated with this account. 
     1159     * 
     1160     * @return                  Integer greater than or equal to zero. 
     1161     */ 
     1162    int getId() const; 
     1163 
     1164    /** 
     1165     * Get the Account class for the specified account Id. 
     1166     * 
     1167     * @param acc_id            The account ID to lookup 
     1168     * 
     1169     * @return                  The Account instance or NULL if not found. 
     1170     */ 
     1171    static Account *lookup(int acc_id); 
     1172 
     1173    /** 
     1174     * Get account info. 
     1175     * 
     1176     * @return                  Account info. 
     1177     */ 
     1178    AccountInfo getInfo() const throw(Error); 
     1179 
     1180    /** 
     1181     * Update registration or perform unregistration. Application normally 
     1182     * only needs to call this function if it wants to manually update the 
     1183     * registration or to unregister from the server. 
     1184     * 
     1185     * @param renew             If False, this will start unregistration 
     1186     *                          process. 
     1187     */ 
     1188    void setRegistration(bool renew) throw(Error); 
     1189 
     1190    /** 
     1191     * Set or modify account's presence online status to be advertised to 
     1192     * remote/presence subscribers. This would trigger the sending of 
     1193     * outgoing NOTIFY request if there are server side presence subscription 
     1194     * for this account, and/or outgoing PUBLISH if presence publication is 
     1195     * enabled for this account. 
     1196     * 
     1197     * @param pres_st           Presence online status. 
     1198     */ 
     1199    void setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error); 
     1200 
     1201    /** 
     1202     * Lock/bind this account to a specific transport/listener. Normally 
     1203     * application shouldn't need to do this, as transports will be selected 
     1204     * automatically by the library according to the destination. 
     1205     * 
     1206     * When account is locked/bound to a specific transport, all outgoing 
     1207     * requests from this account will use the specified transport (this 
     1208     * includes SIP registration, dialog (call and event subscription), and 
     1209     * out-of-dialog requests such as MESSAGE). 
     1210     * 
     1211     * Note that transport id may be specified in AccountConfig too. 
     1212     * 
     1213     * @param tp_id             The transport ID. 
     1214     */ 
     1215    void setTransport(TransportId tp_id) throw(Error); 
     1216 
     1217public: 
     1218    /* 
     1219     * Callbacks 
     1220     */ 
    11021221    /** 
    11031222     * Notify application on incoming call. 
     
    12021321 
    12031322protected: 
    1204     AccountCallback() 
    1205     : acc(NULL) 
    1206     {} 
    1207  
    1208 private: 
    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; 
    1216 }; 
    1217  
    1218  
    1219 /** 
    1220  * @}  // PJSUA2_Acc_Data_Structure 
    1221  */ 
    1222  
    1223 /** 
    1224  * @addtogroup PJSUA2_ACC 
    1225  * @{ 
    1226  */ 
    1227  
    1228  
    1229 /** 
    1230  * Account. 
    1231  */ 
    1232 class Account 
    1233 { 
    1234 public: 
    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  
    1263     /** 
    1264      * Check if this account is still valid. 
    1265      * 
    1266      * @return                  True if it is. 
    1267      */ 
    1268     bool isValid() const; 
    1269  
    1270     /** 
    1271      * Set this as default account to be used when incoming and outgoing 
    1272      * requests don't match any accounts. 
    1273      * 
    1274      * @return                  PJ_SUCCESS on success. 
    1275      */ 
    1276     void setDefault() throw(Error); 
    1277  
    1278     /** 
    1279      * Check if this account is the default account. Default account will be 
    1280      * used for incoming and outgoing requests that don't match any other 
    1281      * accounts. 
    1282      * 
    1283      * @return                  True if this is the default account. 
    1284      */ 
    1285     bool isDefault() const; 
    1286  
    1287     /** 
    1288      * Get PJSUA-LIB account ID or index associated with this account. 
    1289      * 
    1290      * @return                  Integer greater than or equal to zero. 
    1291      */ 
    1292     int getIndex() const; 
    1293  
    1294     /** 
    1295      * Set arbitrary data to be associated with the account. 
    1296      * 
    1297      * @param user_data         User/application data. 
    1298      */ 
    1299     void setUserData(Token user_data); 
    1300  
    1301     /** 
    1302      * Get the user data that was associated with the account. 
    1303      * 
    1304      * @return                  The user data. 
    1305      */ 
    1306     Token getUserData() const; 
    1307  
    1308     /** 
    1309      * Get account info. 
    1310      * 
    1311      * @return                  Account info. 
    1312      */ 
    1313     AccountInfo getInfo() const throw(Error); 
    1314  
    1315     /** 
    1316      * Update registration or perform unregistration. Application normally 
    1317      * only needs to call this function if it wants to manually update the 
    1318      * registration or to unregister from the server. 
    1319      * 
    1320      * @param renew             If False, this will start unregistration 
    1321      *                          process. 
    1322      */ 
    1323     void setRegistration(bool renew) throw(Error); 
    1324  
    1325     /** 
    1326      * Set or modify account's presence online status to be advertised to 
    1327      * remote/presence subscribers. This would trigger the sending of 
    1328      * outgoing NOTIFY request if there are server side presence subscription 
    1329      * for this account, and/or outgoing PUBLISH if presence publication is 
    1330      * enabled for this account. 
    1331      * 
    1332      * @param pres_st           Presence online status. 
    1333      */ 
    1334     void setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error); 
    1335  
    1336     /** 
    1337      * Lock/bind this account to a specific transport/listener. Normally 
    1338      * application shouldn't need to do this, as transports will be selected 
    1339      * automatically by the library according to the destination. 
    1340      * 
    1341      * When account is locked/bound to a specific transport, all outgoing 
    1342      * requests from this account will use the specified transport (this 
    1343      * includes SIP registration, dialog (call and event subscription), and 
    1344      * out-of-dialog requests such as MESSAGE). 
    1345      * 
    1346      * Note that transport id may be specified in AccountConfig too. 
    1347      * 
    1348      * @param tp_id             The transport ID. 
    1349      */ 
    1350     void setTransport(TransportId tp_id) throw(Error); 
    1351  
    1352 protected: 
    13531323    friend class Endpoint; 
    13541324 
    13551325private: 
    13561326    pjsua_acc_id         id; 
    1357     AccountCallback     *cb; 
    1358     Token                userData; 
     1327    string               tmpReason;     // for saving response's reason 
    13591328}; 
    13601329 
Note: See TracChangeset for help on using the changeset viewer.