Ignore:
Timestamp:
Nov 27, 2013 9:37:32 AM (10 years ago)
Author:
nanang
Message:

Re #1519: Added presence API in pjsua2.

File:
1 edited

Legend:

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

    r4644 r4657  
    2626#include <pjsua-lib/pjsua.h> 
    2727#include <pjsua2/persistent.hpp> 
     28#include <pjsua2/presence.hpp> 
    2829#include <pjsua2/siptypes.hpp> 
    2930 
     
    913914}; 
    914915 
    915 /** 
    916  * This describes account presence status. 
    917  */ 
    918 struct AccountPresenceStatus 
    919 { 
    920     /** Basic status. */ 
    921     bool                isOnline; 
    922  
    923     /** Activity type. */ 
    924     pjrpid_activity     activity; 
    925  
    926     /** Optional text describing the person/element. */ 
    927     string              note; 
    928  
    929     /** Optional RPID ID string. */ 
    930     string              rpidId; 
    931  
    932 public: 
    933     AccountPresenceStatus(); 
    934 }; 
    935  
    936916 
    937917/** 
     
    10711051{ 
    10721052    /** 
     1053     * Server presence subscription instance. If application delays 
     1054     * the acceptance of the request, it will need to specify this object 
     1055     * when calling Account::presNotify(). 
     1056     */ 
     1057    void               *srvPres; 
     1058 
     1059    /** 
    10731060     *  Sender URI. 
    10741061     */ 
     
    12201207}; 
    12211208 
     1209/** 
     1210 * Parameters for presNotify() account method. 
     1211 */ 
     1212struct PresNotifyParam 
     1213{ 
     1214    /** 
     1215     * Server presence subscription instance. 
     1216     */ 
     1217    void               *srvPres; 
     1218 
     1219    /** 
     1220     * Server presence subscription state to set. 
     1221     */ 
     1222    pjsip_evsub_state   state; 
     1223     
     1224    /** 
     1225     * Optionally specify the state string name, if state is not "active", 
     1226     * "pending", or "terminated". 
     1227     */ 
     1228    string              stateStr; 
     1229 
     1230    /** 
     1231     * If the new state is PJSIP_EVSUB_STATE_TERMINATED, optionally specify 
     1232     * the termination reason. 
     1233     */ 
     1234    string              reason; 
     1235 
     1236    /** 
     1237     * If the new state is PJSIP_EVSUB_STATE_TERMINATED, this specifies 
     1238     * whether the NOTIFY request should contain message body containing 
     1239     * account's presence information. 
     1240     */ 
     1241    bool                withBody; 
     1242 
     1243    /** 
     1244     * Optional list of headers to be sent with the NOTIFY request. 
     1245     */ 
     1246    SipTxOption         txOption; 
     1247}; 
     1248 
     1249 
     1250/** 
     1251 * Wrapper class for Buddy matching algo. 
     1252 * 
     1253 * Default algo is a simple substring lookup of search-token in the 
     1254 * Buddy URIs, with case sensitive. Application can implement its own 
     1255 * matching algo by overriding this class and specifying its instance 
     1256 * in Account::findBuddy(). 
     1257 */ 
     1258class FindBuddyMatch 
     1259{ 
     1260public: 
     1261    /** 
     1262     * Default algo implementation. 
     1263     */ 
     1264    virtual bool match(const string &token, const Buddy &buddy) 
     1265    { 
     1266        BuddyInfo bi = buddy.getInfo(); 
     1267        return bi.uri.find(token) != string::npos; 
     1268    } 
     1269 
     1270    /** 
     1271     * Destructor. 
     1272     */ 
     1273    virtual ~FindBuddyMatch() {} 
     1274}; 
    12221275 
    12231276/** 
     
    13321385     * @param pres_st           Presence online status. 
    13331386     */ 
    1334     void setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error); 
     1387    void setOnlineStatus(const PresenceStatus &pres_st) throw(Error); 
    13351388 
    13361389    /** 
     
    13501403    void setTransport(TransportId tp_id) throw(Error); 
    13511404 
     1405    /** 
     1406     * Send NOTIFY to inform account presence status or to terminate server 
     1407     * side presence subscription. If application wants to reject the incoming 
     1408     * request, it should set the param \a PresNotifyParam.state to 
     1409     * PJSIP_EVSUB_STATE_TERMINATED. 
     1410     * 
     1411     * @param prm               The sending NOTIFY parameter. 
     1412     */ 
     1413    void presNotify(const PresNotifyParam &prm) throw(Error); 
     1414     
     1415    /** 
     1416     * Enumerate all buddies of the account. 
     1417     * 
     1418     * @return                  The buddy list. 
     1419     */ 
     1420    const BuddyVector& enumBuddies() const throw(Error); 
     1421 
     1422    /** 
     1423     * Find a buddy in the buddy list with the specified URI.  
     1424     * 
     1425     * Exception: if buddy is not found, PJ_ENOTFOUND will be thrown. 
     1426     * 
     1427     * @param uri               The buddy URI. 
     1428     * @param buddy_match       The buddy match algo. 
     1429     * 
     1430     * @return                  The pointer to buddy. 
     1431     */ 
     1432    Buddy* findBuddy(string uri, FindBuddyMatch *buddy_match = NULL) const 
     1433                    throw(Error); 
     1434 
     1435    /** 
     1436     * An internal function to add a Buddy to Account buddy list. 
     1437     * This function must never be used by application. 
     1438     */ 
     1439    void addBuddy(Buddy *buddy); 
     1440 
     1441    /** 
     1442     * An internal function to remove a Buddy from Account buddy list. 
     1443     * This function must never be used by application. 
     1444     */ 
     1445    void removeBuddy(Buddy *buddy); 
     1446 
    13521447public: 
    13531448    /* 
     
    13601455     */ 
    13611456    virtual void onIncomingCall(OnIncomingCallParam &prm) 
    1362     {} 
     1457    { PJ_UNUSED_ARG(prm); } 
    13631458 
    13641459    /** 
     
    13711466     */ 
    13721467    virtual void onRegStarted(OnRegStartedParam &prm) 
    1373     {} 
     1468    { PJ_UNUSED_ARG(prm); } 
    13741469 
    13751470    /** 
     
    13811476     */ 
    13821477    virtual void onRegState(OnRegStateParam &prm) 
    1383     {} 
     1478    { PJ_UNUSED_ARG(prm); } 
    13841479 
    13851480    /** 
     
    14031498     *    user permission whether to accept or reject the request. In this 
    14041499     *    case, the application MUST set the IncomingSubscribeParam.code 
    1405      *    argument to 202, then IMMEDIATELY calls #pjsua_pres_notify() with 
    1406      *    state PJSIP_EVSUB_STATE_PENDING and later calls #pjsua_pres_notify() 
     1500     *    argument to 202, then IMMEDIATELY calls presNotify() with 
     1501     *    state PJSIP_EVSUB_STATE_PENDING and later calls presNotify() 
    14071502     *    again to accept or reject the subscription request. 
    14081503     * 
     
    14161511     */ 
    14171512    virtual void onIncomingSubscribe(OnIncomingSubscribeParam &prm) 
    1418     {} 
     1513    { PJ_UNUSED_ARG(prm); } 
    14191514 
    14201515    /** 
     
    14251520     */ 
    14261521    virtual void onInstantMessage(OnInstantMessageParam &prm) 
    1427     {} 
     1522    { PJ_UNUSED_ARG(prm); } 
    14281523 
    14291524    /** 
     
    14341529     */ 
    14351530    virtual void onInstantMessageStatus(OnInstantMessageStatusParam &prm) 
    1436     {} 
     1531    { PJ_UNUSED_ARG(prm); } 
    14371532 
    14381533    /** 
     
    14421537     */ 
    14431538    virtual void onTypingIndication(OnTypingIndicationParam &prm) 
    1444     {} 
     1539    { PJ_UNUSED_ARG(prm); } 
    14451540 
    14461541    /** 
     
    14531548     */ 
    14541549    virtual void onMwiInfo(OnMwiInfoParam &prm) 
    1455     {} 
     1550    { PJ_UNUSED_ARG(prm); } 
    14561551 
    14571552protected: 
     
    14611556    pjsua_acc_id         id; 
    14621557    string               tmpReason;     // for saving response's reason 
     1558    BuddyVector          buddyList; 
    14631559}; 
    14641560 
Note: See TracChangeset for help on using the changeset viewer.