Changeset 4657
- Timestamp:
- Nov 27, 2013 9:37:32 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2
- Files:
-
- 3 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/account.py
r4648 r4657 46 46 self.cfg = pj.AccountConfig() 47 47 self.cfgChanged = False 48 self.buddyList = [] 48 49 49 50 def statusText(self): -
pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/accountsetting.py
r4640 r4657 41 41 self.transient(parent) 42 42 self.parent = parent 43 self.geometry("+100+100") 43 44 self.title('Account settings') 44 45 -
pjproject/branches/projects/pjsua2/pjsip-apps/src/pygui/application.py
r4648 r4657 33 33 import accountsetting 34 34 import account 35 import buddy 35 36 import endpoint 36 37 … … 63 64 self.pack(expand='yes', fill='both') 64 65 self.master.title('pjsua2 Demo') 66 self.master.geometry('500x500+100+100') 65 67 66 68 # Logger … … 72 74 # GUI variables 73 75 self.showLogWindow = tk.IntVar() 74 self.showLogWindow.set( 1)76 self.showLogWindow.set(0) 75 77 self.quitting = False 76 78 … … 100 102 t.cfg.port = 0 101 103 self.transportCfgs.append(t) 104 t = SipTransportConfig() 105 t.type = pj.PJSIP_TRANSPORT_TCP 106 t.cfg.port = 0 107 self.transportCfgs.append(t) 102 108 103 109 … … 116 122 node = json.writeNewArray("accounts") 117 123 for acc in self.accList: 118 node.writeObject(acc.cfg); 124 acc_node = node.writeNewContainer("Account") 125 acc_node.writeObject(acc.cfg); 126 127 # Write buddy configs 128 buddy_node = acc_node.writeNewArray("buddies") 129 for bud in acc.buddyList: 130 buddy_node.writeObject(bud.cfg) 131 119 132 json.saveFile(filename) 120 133 … … 141 154 node = json.readArray("accounts") 142 155 while node.hasUnread(): 143 cfg = pj.AccountConfig() 144 cfg.readObject(node) 145 acc_cfgs.append(cfg) 146 156 acc_node = node.readContainer("Account") 157 acc_cfg = pj.AccountConfig() 158 acc_cfg.readObject(acc_node) 159 160 # Load buddy configs 161 buddy_cfgs = [] 162 buddy_node = acc_node.readArray("buddies") 163 while buddy_node.hasUnread(): 164 buddy_cfg = pj.BuddyConfig() 165 buddy_cfg.readObject(buddy_node) 166 buddy_cfgs.append(buddy_cfg) 167 168 acc_cfgs.append((acc_cfg, buddy_cfgs)) 169 170 147 171 # Initialize library 148 172 self.epCfg.uaConfig.userAgent = "pygui-" + self.ep.libVersion().full; … … 155 179 156 180 # Add accounts 157 for cfg in acc_cfgs:181 for cfg, buddy_cfgs in acc_cfgs: 158 182 self._createAcc(cfg) 159 183 acc = self.accList[-1] 184 for buddy_cfg in buddy_cfgs: 185 self._createBuddy(acc, buddy_cfg) 186 160 187 # Start library 161 188 self.ep.libStart() … … 173 200 self.tv.item(iid, text=text, values=values) 174 201 else: 175 self.tv.insert('', 0, iid, open=True, text=text, values=values) 176 self.tv.insert(iid, 0, '', open=True, text='Buddy 1', values=('Online',)) 177 self.tv.insert(iid, 1, '', open=True, text='Buddy 2', values=('Online',)) 202 self.tv.insert('', 'end', iid, open=True, text=text, values=values) 203 204 def updateBuddy(self, bud): 205 iid = 'buddy' + str(bud.randId) 206 text = bud.cfg.uri 207 status = bud.statusText() 208 209 values = (status,) 210 if self.tv.exists(iid): 211 self.tv.item(iid, text=text, values=values) 212 else: 213 self.tv.insert(str(bud.account.randId), 'end', iid, open=True, text=text, values=values) 178 214 179 215 def _createAcc(self, acc_cfg): … … 186 222 self.updateAccount(acc) 187 223 224 def _createBuddy(self, acc, buddy_cfg): 225 bud = buddy.Buddy(self) 226 bud.cfg = buddy_cfg 227 bud.account = acc 228 bud.create(acc, bud.cfg) 229 self.updateBuddy(bud) 230 acc.buddyList.append(bud) 231 188 232 def _createWidgets(self): 189 233 self._createAppMenu() … … 222 266 def _createContextMenu(self): 223 267 top = self.winfo_toplevel() 268 269 # Create Account context menu 224 270 self.accMenu = tk.Menu(top, tearoff=False) 225 271 # Labels, must match with _onAccContextMenu() 226 labels = ['Unregister', 'Reregister', '-', 'Online', 'Invisible', 'Away', 'Busy', '-', 'Settings...', '-', 'Delete...'] 272 labels = ['Unregister', 'Reregister', 'Add buddy...', '-', 273 'Online', 'Invisible', 'Away', 'Busy', '-', 274 'Settings...', '-', 275 'Delete...'] 227 276 for label in labels: 228 277 if label=='-': … … 232 281 self.accMenu.add_command(label=label, command=cmd) 233 282 283 # Create Buddy context menu 284 # Labels, must match with _onAccContextMenu() 285 self.buddyMenu = tk.Menu(top, tearoff=False) 286 labels = ['Video call', 'Audio call', 'Send instant message', '-', 287 'Settings...', '-', 288 'Delete...'] 289 290 for label in labels: 291 if label=='-': 292 self.buddyMenu.add_separator() 293 else: 294 cmd = lambda arg=label: self._onBuddyContextMenu(arg) 295 self.buddyMenu.add_command(label=label, command=cmd) 296 234 297 if (top.tk.call('tk', 'windowingsystem')=='aqua'): 235 298 self.tv.bind('<2>', self._onTvRightClick) … … 251 314 return accs[0] 252 315 316 def _getSelectedBuddy(self): 317 items = self.tv.selection() 318 if not items: 319 return None 320 try: 321 iid = int(items[0][5:]) 322 iid_parent = int(self.tv.parent(items[0])) 323 except: 324 return None 325 326 accs = [acc for acc in self.accList if acc.randId==iid_parent] 327 if not accs: 328 return None 329 330 buds = [b for b in accs[0].buddyList if b.randId==iid] 331 if not buds: 332 return None 333 334 return buds[0] 335 253 336 def _onTvRightClick(self, event): 254 iid = self.tv.identify('item', event.x, event.y) 337 iid = self.tv.identify_row(event.y) 338 #iid = self.tv.identify('item', event.x, event.y) 255 339 if iid: 256 self.tv.selection_ add( (iid,) )340 self.tv.selection_set( (iid,) ) 257 341 acc = self._getSelectedAccount() 258 342 if acc: … … 260 344 else: 261 345 # A buddy is selected 262 pass346 self.buddyMenu.post(event.x_root, event.y_root) 263 347 264 348 def _onAccContextMenu(self, label): … … 272 356 acc.setRegistration(True) 273 357 elif label=='Online': 274 ps = pj. AccountPresenceStatus()358 ps = pj.PresenceStatus() 275 359 ps.isOnline = True 276 360 acc.setOnlineStatus(ps) 277 361 elif label=='Invisible': 278 ps = pj. AccountPresenceStatus()362 ps = pj.PresenceStatus() 279 363 ps.isOnline = False 280 364 acc.setOnlineStatus(ps) 281 365 elif label=='Away': 282 ps = pj. AccountPresenceStatus()366 ps = pj.PresenceStatus() 283 367 ps.isOnline = True 284 368 ps.activity = pj.PJRPID_ACTIVITY_AWAY … … 286 370 acc.setOnlineStatus(ps) 287 371 elif label=='Busy': 288 ps = pj. AccountPresenceStatus()372 ps = pj.PresenceStatus() 289 373 ps.isOnline = True 290 374 ps.activity = pj.PJRPID_ACTIVITY_BUSY … … 305 389 del acc 306 390 self.tv.delete( (iid,) ) 391 elif label=='Add buddy...': 392 cfg = pj.BuddyConfig() 393 dlg = buddy.SettingDialog(self.master, cfg) 394 if dlg.doModal(): 395 self._createBuddy(acc, cfg) 307 396 else: 308 397 assert not ("Unknown menu " + label) 309 398 399 def _onBuddyContextMenu(self, label): 400 bud = self._getSelectedBuddy() 401 if not bud: 402 return 403 acc = bud.account 404 405 if label=='Video call': 406 pass 407 elif label=='Audio call': 408 pass 409 elif label=='Send instant message': 410 pass 411 elif label=='Settings...': 412 subs = bud.cfg.subscribe 413 uri = bud.cfg.uri 414 dlg = buddy.SettingDialog(self.master, bud.cfg) 415 if dlg.doModal(): 416 self.updateBuddy(bud) 417 # URI updated? 418 if uri != bud.cfg.uri: 419 cfg = bud.cfg 420 # del old 421 iid = 'buddy' + str(bud.randId) 422 acc.buddyList.remove(bud) 423 del bud 424 self.tv.delete( (iid,) ) 425 # add new 426 self._createBuddy(acc, cfg) 427 # presence subscribe setting updated 428 elif subs != bud.cfg.subscribe: 429 bud.subscribePresence(bud.cfg.subscribe) 430 elif label=='Delete...': 431 msg = "Do you really want to delete buddy '%s'?" % bud.cfg.uri 432 if msgbox.askquestion('Delete buddy?', msg, default=msgbox.NO) != u'yes': 433 return 434 iid = 'buddy' + str(bud.randId) 435 acc.buddyList.remove(bud) 436 del bud 437 self.tv.delete( (iid,) ) 438 else: 439 assert not ("Unknown menu " + label) 440 310 441 def _onTimer(self): 311 442 if not self.quitting: -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/importsym.py
r4639 r4657 30 30 return os.path.isfile(fpath) and os.access(fpath, os.X_OK) 31 31 32 if sys.platform == 'win32' and not program.endswith(".exe"): 33 program += ".exe" 34 32 35 fpath, fname = os.path.split(program) 33 36 if fpath: … … 66 69 C_HEADING_SECTION = """ 67 70 #define PJ_AUTOCONF 1 68 #define CC_DUMMY69 71 #define jmp_buf int 70 72 #define __attribute__(x) -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/pjsua2.i
r4646 r4657 37 37 %feature("director") Endpoint; 38 38 %feature("director") Account; 39 %feature("director") Buddy; 40 %feature("director") FindBuddyMatch; 39 41 40 42 … … 60 62 %include "pjsua2/types.hpp" 61 63 64 %ignore pj::ContainerNode::op; 65 %ignore pj::ContainerNode::data; 62 66 %ignore container_node_op; 67 %ignore container_node_internal_data; 63 68 %include "pjsua2/persistent.hpp" 64 69 70 %ignore pj::TransportInfo::TransportInfo(const pjsua_transport_info &info); 65 71 %include "pjsua2/siptypes.hpp" 66 72 … … 68 74 %template(AuthCredInfoVector) std::vector<pj::AuthCredInfo>; 69 75 %template(SipMultipartPartVector) std::vector<pj::SipMultipartPart>; 76 %template(BuddyVector) std::vector<pj::Buddy*>; 70 77 71 78 %include "pjsua2/endpoint.hpp" 79 %include "pjsua2/presence.hpp" 72 80 %include "pjsua2/account.hpp" 73 81 74 %ignore JsonDocument::allocElement();75 %ignore JsonDocument::getPool();82 %ignore pj::JsonDocument::allocElement; 83 %ignore pj::JsonDocument::getPool; 76 84 %include "pjsua2/json.hpp" -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.i
r4639 r4657 55 55 typedef enum pjrpid_activity {PJRPID_ACTIVITY_UNKNOWN, PJRPID_ACTIVITY_AWAY, PJRPID_ACTIVITY_BUSY} pjrpid_activity; 56 56 57 typedef enum pjsip_evsub_state {PJSIP_EVSUB_STATE_NULL, PJSIP_EVSUB_STATE_SENT, PJSIP_EVSUB_STATE_ACCEPTED, PJSIP_EVSUB_STATE_PENDING, PJSIP_EVSUB_STATE_ACTIVE, PJSIP_EVSUB_STATE_TERMINATED, PJSIP_EVSUB_STATE_UNKNOWN} pjsip_evsub_state; 58 57 59 enum pjsua_invalid_id_const_ {PJSUA_INVALID_ID = -1}; 58 60 … … 73 75 typedef enum pjsua_ipv6_use {PJSUA_IPV6_DISABLED, PJSUA_IPV6_ENABLED} pjsua_ipv6_use; 74 76 77 typedef enum pjsua_buddy_status {PJSUA_BUDDY_STATUS_UNKNOWN, PJSUA_BUDDY_STATUS_ONLINE, PJSUA_BUDDY_STATUS_OFFLINE} pjsua_buddy_status; 78 -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.lst
r4639 r4657 18 18 19 19 pjsip-simple/rpid.h pjrpid_activity 20 pjsip-simple/evsub.h pjsip_evsub_state 20 21 21 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use 22 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_buddy_status -
pjproject/branches/projects/pjsua2/pjsip/build/Makefile
r4644 r4657 91 91 export PJSUA2_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 92 92 account.o endpoint.o json.o persistent.o types.o \ 93 siptypes.o 93 siptypes.o presence.o 94 94 export PJSUA2_LIB_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS) 95 95 export PJSUA2_LIB_CXXFLAGS = $(PJSUA2_LIB_CFLAGS) -
pjproject/branches/projects/pjsua2/pjsip/include/pjsip-simple/evsub.h
r3553 r4657 59 59 * in state_str member of the susbcription structure. 60 60 */ 61 enum pjsip_evsub_state61 typedef enum pjsip_evsub_state 62 62 { 63 63 PJSIP_EVSUB_STATE_NULL, /**< State is NULL. */ … … 71 71 Application can query the state by 72 72 calling #pjsip_evsub_get_state_name().*/ 73 }; 74 75 /** 76 * @see pjsip_evsub_state 77 */ 78 typedef enum pjsip_evsub_state pjsip_evsub_state; 73 } pjsip_evsub_state; 79 74 80 75 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2.hpp
r4644 r4657 22 22 #include <pjsua2/endpoint.hpp> 23 23 #include <pjsua2/account.hpp> 24 #include <pjsua2/presence.hpp> 24 25 #include <pjsua2/json.hpp> 25 26 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/account.hpp
r4644 r4657 26 26 #include <pjsua-lib/pjsua.h> 27 27 #include <pjsua2/persistent.hpp> 28 #include <pjsua2/presence.hpp> 28 29 #include <pjsua2/siptypes.hpp> 29 30 … … 913 914 }; 914 915 915 /**916 * This describes account presence status.917 */918 struct AccountPresenceStatus919 {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 936 916 937 917 /** … … 1071 1051 { 1072 1052 /** 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 /** 1073 1060 * Sender URI. 1074 1061 */ … … 1220 1207 }; 1221 1208 1209 /** 1210 * Parameters for presNotify() account method. 1211 */ 1212 struct 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 */ 1258 class FindBuddyMatch 1259 { 1260 public: 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 }; 1222 1275 1223 1276 /** … … 1332 1385 * @param pres_st Presence online status. 1333 1386 */ 1334 void setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error);1387 void setOnlineStatus(const PresenceStatus &pres_st) throw(Error); 1335 1388 1336 1389 /** … … 1350 1403 void setTransport(TransportId tp_id) throw(Error); 1351 1404 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 1352 1447 public: 1353 1448 /* … … 1360 1455 */ 1361 1456 virtual void onIncomingCall(OnIncomingCallParam &prm) 1362 { }1457 { PJ_UNUSED_ARG(prm); } 1363 1458 1364 1459 /** … … 1371 1466 */ 1372 1467 virtual void onRegStarted(OnRegStartedParam &prm) 1373 { }1468 { PJ_UNUSED_ARG(prm); } 1374 1469 1375 1470 /** … … 1381 1476 */ 1382 1477 virtual void onRegState(OnRegStateParam &prm) 1383 { }1478 { PJ_UNUSED_ARG(prm); } 1384 1479 1385 1480 /** … … 1403 1498 * user permission whether to accept or reject the request. In this 1404 1499 * case, the application MUST set the IncomingSubscribeParam.code 1405 * argument to 202, then IMMEDIATELY calls #pjsua_pres_notify() with1406 * 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() 1407 1502 * again to accept or reject the subscription request. 1408 1503 * … … 1416 1511 */ 1417 1512 virtual void onIncomingSubscribe(OnIncomingSubscribeParam &prm) 1418 { }1513 { PJ_UNUSED_ARG(prm); } 1419 1514 1420 1515 /** … … 1425 1520 */ 1426 1521 virtual void onInstantMessage(OnInstantMessageParam &prm) 1427 { }1522 { PJ_UNUSED_ARG(prm); } 1428 1523 1429 1524 /** … … 1434 1529 */ 1435 1530 virtual void onInstantMessageStatus(OnInstantMessageStatusParam &prm) 1436 { }1531 { PJ_UNUSED_ARG(prm); } 1437 1532 1438 1533 /** … … 1442 1537 */ 1443 1538 virtual void onTypingIndication(OnTypingIndicationParam &prm) 1444 { }1539 { PJ_UNUSED_ARG(prm); } 1445 1540 1446 1541 /** … … 1453 1548 */ 1454 1549 virtual void onMwiInfo(OnMwiInfoParam &prm) 1455 { }1550 { PJ_UNUSED_ARG(prm); } 1456 1551 1457 1552 protected: … … 1461 1556 pjsua_acc_id id; 1462 1557 string tmpReason; // for saving response's reason 1558 BuddyVector buddyList; 1463 1559 }; 1464 1560 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp
r4644 r4657 960 960 virtual void onNatDetectionComplete( 961 961 const OnNatDetectionCompleteParam &prm) 962 { }962 { PJ_UNUSED_ARG(prm); } 963 963 964 964 /** … … 970 970 virtual void onNatCheckStunServersComplete( 971 971 const OnNatCheckStunServersCompleteParam &prm) 972 { }972 { PJ_UNUSED_ARG(prm); } 973 973 974 974 /** … … 979 979 virtual void onTransportState( 980 980 const OnTransportStateParam &prm) 981 { }981 { PJ_UNUSED_ARG(prm); } 982 982 983 983 /** … … 988 988 */ 989 989 virtual void onTimer(const OnTimerParam &prm) 990 { }990 { PJ_UNUSED_ARG(prm); } 991 991 992 992 /** … … 1006 1006 */ 1007 1007 virtual void onSelectAccount(OnSelectAccountParam &prm) 1008 { }1008 { PJ_UNUSED_ARG(prm); } 1009 1009 1010 1010 … … 1071 1071 static void on_mwi_info(pjsua_acc_id acc_id, 1072 1072 pjsua_mwi_info *mwi_info); 1073 static void on_buddy_state(pjsua_buddy_id buddy_id); 1074 1073 1075 }; 1074 1076 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/persistent.hpp
r4644 r4657 334 334 throw(Error); 335 335 }; 336 337 338 /** 339 * Forward declaration of container_node_op. 340 */ 341 struct container_node_op; 342 343 344 /** 345 * Internal data for ContainerNode. See ContainerNode implementation notes 346 * for more info. 347 */ 348 struct container_node_internal_data 349 { 350 void *doc; 351 void *data1; 352 void *data2; 353 }; 354 355 /** 356 * A container node is a placeholder for storing other data elements, which 357 * could be boolean, number, string, array of strings, or another container. 358 * Each data in the container is basically a name/value pair, with a type 359 * internally associated with it so that written data can be read in the 360 * correct type. Data is read and written serially, hence the order of 361 * reading must be the same as the order of writing. 362 * 363 * Application can read data from it by using the various read methods, and 364 * write data to it using the various write methods. Alternatively, it 365 * may be more convenient to use the provided macros below to read and write 366 * the data, because these macros set the name automatically: 367 * - NODE_READ_BOOL(node,item) 368 * - NODE_READ_UNSIGNED(node,item) 369 * - NODE_READ_INT(node,item) 370 * - NODE_READ_FLOAT(node,item) 371 * - NODE_READ_NUM_T(node,type,item) 372 * - NODE_READ_STRING(node,item) 373 * - NODE_READ_STRINGV(node,item) 374 * - NODE_READ_OBJ(node,item) 375 * - NODE_WRITE_BOOL(node,item) 376 * - NODE_WRITE_UNSIGNED(node,item) 377 * - NODE_WRITE_INT(node,item) 378 * - NODE_WRITE_FLOAT(node,item) 379 * - NODE_WRITE_NUM_T(node,type,item) 380 * - NODE_WRITE_STRING(node,item) 381 * - NODE_WRITE_STRINGV(node,item) 382 * - NODE_WRITE_OBJ(node,item) 383 * 384 * Implementation notes: 385 * 386 * The ContainerNode class is subclass-able, but not in the usual C++ way. 387 * With the usual C++ inheritance, some methods will be made pure virtual 388 * and must be implemented by the actual class. However, doing so will 389 * require dynamic instantiation of the ContainerNode class, which means 390 * we will need to pass around the class as pointer, for example as the 391 * return value of readContainer() and writeNewContainer() methods. Then 392 * we will need to establish who needs or how to delete these objects, or 393 * use shared pointer mechanism, each of which is considered too inconvenient 394 * or complicated for the purpose. 395 * 396 * So hence we use C style "inheritance", where the methods are declared in 397 * container_node_op and the data in container_node_internal_data structures. 398 * An implementation of ContainerNode class will need to set up these members 399 * with values that makes sense to itself. The methods in container_node_op 400 * contains the pointer to the actual implementation of the operation, which 401 * would be specific according to the format of the document. The methods in 402 * this ContainerNode class are just thin wrappers which call the 403 * implementation in the container_node_op structure. 404 * 405 */ 406 class ContainerNode 407 { 408 public: 409 /** 410 * Determine if there is unread element. If yes, then app can use one of 411 * the readXxx() functions to read it. 412 */ 413 bool hasUnread() const; 414 415 /** 416 * Get the name of the next unread element. 417 */ 418 string unreadName() const throw(Error); 419 420 /** 421 * Read an integer value from the document and return the value. 422 * This will throw Error if the current element is not a number. 423 * The read position will be advanced to the next element. 424 * 425 * @param name If specified, then the function will check if the 426 * name of the next element matches the specified 427 * name and throw Error if it doesn't match. 428 * 429 * @return The value. 430 */ 431 int readInt(const string &name="") const throw(Error); 432 433 /** 434 * Read a number value from the document and return the value. 435 * This will throw Error if the current element is not a number. 436 * The read position will be advanced to the next element. 437 * 438 * @param name If specified, then the function will check if the 439 * name of the next element matches the specified 440 * name and throw Error if it doesn't match. 441 * 442 * @return The value. 443 */ 444 float readNumber(const string &name="") const throw(Error); 445 446 /** 447 * Read a boolean value from the container and return the value. 448 * This will throw Error if the current element is not a boolean. 449 * The read position will be advanced to the next element. 450 * 451 * @param name If specified, then the function will check if the 452 * name of the next element matches the specified 453 * name and throw Error if it doesn't match. 454 * 455 * @return The value. 456 */ 457 bool readBool(const string &name="") const throw(Error); 458 459 /** 460 * Read a string value from the container and return the value. 461 * This will throw Error if the current element is not a string. 462 * The read position will be advanced to the next element. 463 * 464 * @param name If specified, then the function will check if the 465 * name of the next element matches the specified 466 * name and throw Error if it doesn't match. 467 * 468 * @return The value. 469 */ 470 string readString(const string &name="") const throw(Error); 471 472 /** 473 * Read a string array from the container. This will throw Error 474 * if the current element is not a string array. The read position 475 * will be advanced to the next element. 476 * 477 * @param name If specified, then the function will check if the 478 * name of the next element matches the specified 479 * name and throw Error if it doesn't match. 480 * 481 * @return The value. 482 */ 483 StringVector readStringVector(const string &name="") const 484 throw(Error); 485 486 /** 487 * Read the specified object from the container. This is equal to 488 * calling PersistentObject.readObject(ContainerNode); 489 * 490 * @param obj The object to read. 491 */ 492 void readObject(PersistentObject &obj) const throw(Error); 493 494 /** 495 * Read a container from the container. This will throw Error if the 496 * current element is not a container. The read position will be advanced 497 * to the next element. 498 * 499 * @param name If specified, then the function will check if the 500 * name of the next element matches the specified 501 * name and throw Error if it doesn't match. 502 * 503 * @return Container object. 504 */ 505 ContainerNode readContainer(const string &name="") const 506 throw(Error); 507 508 /** 509 * Read array container from the container. This will throw Error if the 510 * current element is not an array. The read position will be advanced 511 * to the next element. 512 * 513 * @param name If specified, then the function will check if the 514 * name of the next element matches the specified 515 * name and throw Error if it doesn't match. 516 * 517 * @return Container object. 518 */ 519 ContainerNode readArray(const string &name="") const 520 throw(Error); 521 522 /** 523 * Write a number value to the container. 524 * 525 * @param name The name for the value in the container. 526 * @param value The value to be written. 527 */ 528 void writeNumber(const string &name, 529 float num) throw(Error); 530 531 /** 532 * Write a number value to the container. 533 * 534 * @param name The name for the value in the container. 535 * @param value The value to be written. 536 */ 537 void writeInt(const string &name, 538 int num) throw(Error); 539 540 /** 541 * Write a boolean value to the container. 542 * 543 * @param name The name for the value in the container. 544 * @param value The value to be written. 545 */ 546 void writeBool(const string &name, 547 bool value) throw(Error); 548 549 /** 550 * Write a string value to the container. 551 * 552 * @param name The name for the value in the container. 553 * @param value The value to be written. 554 */ 555 void writeString(const string &name, 556 const string &value) throw(Error); 557 558 /** 559 * Write string vector to the container. 560 * 561 * @param name The name for the value in the container. 562 * @param array The vector to be written. 563 */ 564 void writeStringVector(const string &name, 565 const StringVector &value) 566 throw(Error); 567 568 /** 569 * Write an object to the container. This is equal to calling 570 * PersistentObject.writeObject(ContainerNode); 571 * 572 * @param obj The object to be written 573 */ 574 void writeObject(const PersistentObject &obj) throw(Error); 575 576 /** 577 * Create and write an empty Object node that can be used as parent 578 * for subsequent write operations. 579 * 580 * @param name The name for the new container in the container. 581 * 582 * @return A sub-container. 583 */ 584 ContainerNode writeNewContainer(const string &name) 585 throw(Error); 586 587 /** 588 * Create and write an empty array node that can be used as parent 589 * for subsequent write operations. 590 * 591 * @param name The name for the array. 592 * 593 * @return A sub-container. 594 */ 595 ContainerNode writeNewArray(const string &name) 596 throw(Error); 597 598 public: 599 /* internal data */ 600 container_node_op *op; 601 container_node_internal_data data; 602 }; 603 336 604 337 605 /** … … 387 655 }; 388 656 389 /**390 * Internal data for ContainerNode. See ContainerNode implementation notes391 * for more info.392 */393 struct container_node_internal_data394 {395 void *doc;396 void *data1;397 void *data2;398 };399 400 /**401 * A container node is a placeholder for storing other data elements, which402 * could be boolean, number, string, array of strings, or another container.403 * Each data in the container is basically a name/value pair, with a type404 * internally associated with it so that written data can be read in the405 * correct type. Data is read and written serially, hence the order of406 * reading must be the same as the order of writing.407 *408 * Application can read data from it by using the various read methods, and409 * write data to it using the various write methods. Alternatively, it410 * may be more convenient to use the provided macros below to read and write411 * the data, because these macros set the name automatically:412 * - NODE_READ_BOOL(node,item)413 * - NODE_READ_UNSIGNED(node,item)414 * - NODE_READ_INT(node,item)415 * - NODE_READ_FLOAT(node,item)416 * - NODE_READ_NUM_T(node,type,item)417 * - NODE_READ_STRING(node,item)418 * - NODE_READ_STRINGV(node,item)419 * - NODE_READ_OBJ(node,item)420 * - NODE_WRITE_BOOL(node,item)421 * - NODE_WRITE_UNSIGNED(node,item)422 * - NODE_WRITE_INT(node,item)423 * - NODE_WRITE_FLOAT(node,item)424 * - NODE_WRITE_NUM_T(node,type,item)425 * - NODE_WRITE_STRING(node,item)426 * - NODE_WRITE_STRINGV(node,item)427 * - NODE_WRITE_OBJ(node,item)428 *429 * Implementation notes:430 *431 * The ContainerNode class is subclass-able, but not in the usual C++ way.432 * With the usual C++ inheritance, some methods will be made pure virtual433 * and must be implemented by the actual class. However, doing so will434 * require dynamic instantiation of the ContainerNode class, which means435 * we will need to pass around the class as pointer, for example as the436 * return value of readContainer() and writeNewContainer() methods. Then437 * we will need to establish who needs or how to delete these objects, or438 * use shared pointer mechanism, each of which is considered too inconvenient439 * or complicated for the purpose.440 *441 * So hence we use C style "inheritance", where the methods are declared in442 * container_node_op and the data in container_node_internal_data structures.443 * An implementation of ContainerNode class will need to set up these members444 * with values that makes sense to itself. The methods in container_node_op445 * contains the pointer to the actual implementation of the operation, which446 * would be specific according to the format of the document. The methods in447 * this ContainerNode class are just thin wrappers which call the448 * implementation in the container_node_op structure.449 *450 */451 class ContainerNode452 {453 public:454 /**455 * Determine if there is unread element. If yes, then app can use one of456 * the readXxx() functions to read it.457 */458 bool hasUnread() const;459 460 /**461 * Get the name of the next unread element.462 */463 string unreadName() const throw(Error);464 465 /**466 * Read an integer value from the document and return the value.467 * This will throw Error if the current element is not a number.468 * The read position will be advanced to the next element.469 *470 * @param name If specified, then the function will check if the471 * name of the next element matches the specified472 * name and throw Error if it doesn't match.473 *474 * @return The value.475 */476 int readInt(const string &name="") const throw(Error);477 478 /**479 * Read a number value from the document and return the value.480 * This will throw Error if the current element is not a number.481 * The read position will be advanced to the next element.482 *483 * @param name If specified, then the function will check if the484 * name of the next element matches the specified485 * name and throw Error if it doesn't match.486 *487 * @return The value.488 */489 float readNumber(const string &name="") const throw(Error);490 491 /**492 * Read a boolean value from the container and return the value.493 * This will throw Error if the current element is not a boolean.494 * The read position will be advanced to the next element.495 *496 * @param name If specified, then the function will check if the497 * name of the next element matches the specified498 * name and throw Error if it doesn't match.499 *500 * @return The value.501 */502 bool readBool(const string &name="") const throw(Error);503 504 /**505 * Read a string value from the container and return the value.506 * This will throw Error if the current element is not a string.507 * The read position will be advanced to the next element.508 *509 * @param name If specified, then the function will check if the510 * name of the next element matches the specified511 * name and throw Error if it doesn't match.512 *513 * @return The value.514 */515 string readString(const string &name="") const throw(Error);516 517 /**518 * Read a string array from the container. This will throw Error519 * if the current element is not a string array. The read position520 * will be advanced to the next element.521 *522 * @param name If specified, then the function will check if the523 * name of the next element matches the specified524 * name and throw Error if it doesn't match.525 *526 * @return The value.527 */528 StringVector readStringVector(const string &name="") const529 throw(Error);530 531 /**532 * Read the specified object from the container. This is equal to533 * calling PersistentObject.readObject(ContainerNode);534 *535 * @param obj The object to read.536 */537 void readObject(PersistentObject &obj) const throw(Error);538 539 /**540 * Read a container from the container. This will throw Error if the541 * current element is not a container. The read position will be advanced542 * to the next element.543 *544 * @param name If specified, then the function will check if the545 * name of the next element matches the specified546 * name and throw Error if it doesn't match.547 *548 * @return Container object.549 */550 ContainerNode readContainer(const string &name="") const551 throw(Error);552 553 /**554 * Read array container from the container. This will throw Error if the555 * current element is not an array. The read position will be advanced556 * to the next element.557 *558 * @param name If specified, then the function will check if the559 * name of the next element matches the specified560 * name and throw Error if it doesn't match.561 *562 * @return Container object.563 */564 ContainerNode readArray(const string &name="") const565 throw(Error);566 567 /**568 * Write a number value to the container.569 *570 * @param name The name for the value in the container.571 * @param value The value to be written.572 */573 void writeNumber(const string &name,574 float num) throw(Error);575 576 /**577 * Write a number value to the container.578 *579 * @param name The name for the value in the container.580 * @param value The value to be written.581 */582 void writeInt(const string &name,583 int num) throw(Error);584 585 /**586 * Write a boolean value to the container.587 *588 * @param name The name for the value in the container.589 * @param value The value to be written.590 */591 void writeBool(const string &name,592 bool value) throw(Error);593 594 /**595 * Write a string value to the container.596 *597 * @param name The name for the value in the container.598 * @param value The value to be written.599 */600 void writeString(const string &name,601 const string &value) throw(Error);602 603 /**604 * Write string vector to the container.605 *606 * @param name The name for the value in the container.607 * @param array The vector to be written.608 */609 void writeStringVector(const string &name,610 const StringVector &value)611 throw(Error);612 613 /**614 * Write an object to the container. This is equal to calling615 * PersistentObject.writeObject(ContainerNode);616 *617 * @param obj The object to be written618 */619 void writeObject(const PersistentObject &obj) throw(Error);620 621 /**622 * Create and write an empty Object node that can be used as parent623 * for subsequent write operations.624 *625 * @param name The name for the new container in the container.626 *627 * @return A sub-container.628 */629 ContainerNode writeNewContainer(const string &name)630 throw(Error);631 632 /**633 * Create and write an empty array node that can be used as parent634 * for subsequent write operations.635 *636 * @param name The name for the array.637 *638 * @return A sub-container.639 */640 ContainerNode writeNewArray(const string &name)641 throw(Error);642 643 public:644 /* internal data */645 container_node_op *op;646 container_node_internal_data data;647 };648 657 649 658 /* … … 660 669 661 670 #define NODE_WRITE_BOOL(node,item) node.writeBool(#item, item) 662 #define NODE_WRITE_UNSIGNED(node,item) node.writeNumber(#item, item)663 #define NODE_WRITE_INT(node,item) node.writeNumber(#item, item)664 #define NODE_WRITE_NUM_T(node,T,item) node.writeNumber(#item, ( int)item)671 #define NODE_WRITE_UNSIGNED(node,item) node.writeNumber(#item, (float)item) 672 #define NODE_WRITE_INT(node,item) node.writeNumber(#item, (float)item) 673 #define NODE_WRITE_NUM_T(node,T,item) node.writeNumber(#item, (float)item) 665 674 #define NODE_WRITE_FLOAT(node,item) node.writeNumber(#item, item) 666 675 #define NODE_WRITE_STRING(node,item) node.writeString(#item, item) -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/siptypes.hpp
r4655 r4657 589 589 */ 590 590 void toPj(pjsua_msg_data &msg_data) const; 591 }; 592 593 594 /** 595 * This structure contains parameters for sending instance message methods, 596 * e.g: Buddy::sendInstantMessage(), Call:sendInstantMessage(). 597 */ 598 struct SendInstantMessageParam 599 { 600 /** 601 * MIME type. Default is "text/plain". 602 */ 603 string contentType; 604 605 /** 606 * The message content. 607 */ 608 string content; 609 610 /** 611 * List of headers etc to be included in outgoing request. 612 */ 613 SipTxOption txOption; 614 615 /** 616 * User data, which will be given back when the IM callback is called. 617 */ 618 Token userData; 619 }; 620 621 622 /** 623 * This structure contains parameters for sending typing indication methods, 624 * e.g: Buddy::sendTypingIndication(), Call:sendTypingIndication(). 625 */ 626 struct SendTypingIndicationParam 627 { 628 /** 629 * True to indicate to remote that local person is currently typing an IM. 630 */ 631 bool isTyping; 632 633 /** 634 * List of headers etc to be included in outgoing request. 635 */ 636 SipTxOption txOption; 591 637 }; 592 638 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/types.hpp
r4644 r4657 20 20 #define __PJSUA2_TYPES_HPP__ 21 21 22 #ifdef _MSC_VER 23 # pragma warning( disable : 4290 ) // exception spec ignored 24 #endif 25 22 26 /** 23 27 * @file pjsua2/types.hpp -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/account.cpp
r4644 r4657 19 19 #include <pjsua2/account.hpp> 20 20 #include <pjsua2/endpoint.hpp> 21 #include <pjsua2/presence.hpp> 21 22 #include <pj/ctype.h> 22 23 #include "util.hpp" … … 446 447 regConfig.firstRetryIntervalSec = prm.reg_first_retry_interval; 447 448 regConfig.delayBeforeRefreshSec = prm.reg_delay_before_refresh; 448 regConfig.dropCallsOnFail = prm.drop_calls_on_reg_fail;449 regConfig.dropCallsOnFail = PJ2BOOL(prm.drop_calls_on_reg_fail); 449 450 regConfig.unregWaitSec = prm.unreg_timeout; 450 451 regConfig.proxyUse = prm.reg_use_proxy; … … 484 485 sipConfig.contactParams = pj2Str(prm.contact_params); 485 486 sipConfig.contactUriParams = pj2Str(prm.contact_uri_params); 486 sipConfig.authInitialEmpty = prm.auth_pref.initial_auth;487 sipConfig.authInitialEmpty = PJ2BOOL(prm.auth_pref.initial_auth); 487 488 sipConfig.authInitialAlgorithm = pj2Str(prm.auth_pref.algorithm); 488 489 sipConfig.transportId = prm.transport_id; … … 504 505 hdr = hdr->next; 505 506 } 506 presConfig.publishEnabled = prm.publish_enabled;507 presConfig.publishQueue = prm.publish_opt.queue_request;507 presConfig.publishEnabled = PJ2BOOL(prm.publish_enabled); 508 presConfig.publishQueue = PJ2BOOL(prm.publish_opt.queue_request); 508 509 presConfig.publishShutdownWaitMsec = prm.unpublish_max_wait_time_msec; 509 510 presConfig.pidfTupleId = pj2Str(prm.pidf_tuple_id); 510 511 511 512 // AccountMwiConfig 512 mwiConfig.enabled = prm.mwi_enabled;513 mwiConfig.enabled = PJ2BOOL(prm.mwi_enabled); 513 514 mwiConfig.expirationSec = prm.mwi_expires; 514 515 … … 517 518 natConfig.mediaStunUse = prm.media_stun_use; 518 519 if (prm.ice_cfg_use == PJSUA_ICE_CONFIG_USE_CUSTOM) { 519 natConfig.iceEnabled = prm.ice_cfg.enable_ice;520 natConfig.iceEnabled = PJ2BOOL(prm.ice_cfg.enable_ice); 520 521 natConfig.iceMaxHostCands = prm.ice_cfg.ice_max_host_cands; 521 natConfig.iceAggressiveNomination = prm.ice_cfg.ice_opt.aggressive;522 natConfig.iceAggressiveNomination = PJ2BOOL(prm.ice_cfg.ice_opt.aggressive); 522 523 natConfig.iceNominatedCheckDelayMsec = prm.ice_cfg.ice_opt.nominated_check_delay; 523 524 natConfig.iceWaitNominationTimeoutMsec = prm.ice_cfg.ice_opt.controlled_agent_want_nom_timeout; 524 natConfig.iceNoRtcp = prm.ice_cfg.ice_no_rtcp;525 natConfig.iceAlwaysUpdate = prm.ice_cfg.ice_always_update;525 natConfig.iceNoRtcp = PJ2BOOL(prm.ice_cfg.ice_no_rtcp); 526 natConfig.iceAlwaysUpdate = PJ2BOOL(prm.ice_cfg.ice_always_update); 526 527 } else { 527 528 pjsua_media_config default_mcfg; … … 530 531 mcfg = &default_mcfg; 531 532 } 532 natConfig.iceEnabled = mcfg->enable_ice;533 natConfig.iceEnabled = PJ2BOOL(mcfg->enable_ice); 533 534 natConfig.iceMaxHostCands= mcfg->ice_max_host_cands; 534 natConfig.iceAggressiveNomination = mcfg->ice_opt.aggressive;535 natConfig.iceAggressiveNomination = PJ2BOOL(mcfg->ice_opt.aggressive); 535 536 natConfig.iceNominatedCheckDelayMsec = mcfg->ice_opt.nominated_check_delay; 536 537 natConfig.iceWaitNominationTimeoutMsec = mcfg->ice_opt.controlled_agent_want_nom_timeout; 537 natConfig.iceNoRtcp = mcfg->ice_no_rtcp;538 natConfig.iceAlwaysUpdate = mcfg->ice_always_update;538 natConfig.iceNoRtcp = PJ2BOOL(mcfg->ice_no_rtcp); 539 natConfig.iceAlwaysUpdate = PJ2BOOL(mcfg->ice_always_update); 539 540 } 540 541 541 542 if (prm.turn_cfg_use == PJSUA_TURN_CONFIG_USE_CUSTOM) { 542 natConfig.turnEnabled = prm.turn_cfg.enable_turn;543 natConfig.turnEnabled = PJ2BOOL(prm.turn_cfg.enable_turn); 543 544 natConfig.turnServer = pj2Str(prm.turn_cfg.turn_server); 544 545 natConfig.turnConnType = prm.turn_cfg.turn_conn_type; … … 552 553 mcfg = &default_mcfg; 553 554 } 554 natConfig.turnEnabled = mcfg->enable_turn;555 natConfig.turnEnabled = PJ2BOOL(mcfg->enable_turn); 555 556 natConfig.turnServer = pj2Str(mcfg->turn_server); 556 557 natConfig.turnConnType = mcfg->turn_conn_type; … … 571 572 // AccountMediaConfig 572 573 mediaConfig.transportConfig.fromPj(prm.rtp_cfg); 573 mediaConfig.lockCodecEnabled= prm.lock_codec;574 mediaConfig.lockCodecEnabled= PJ2BOOL(prm.lock_codec); 574 575 #if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0) 575 mediaConfig.streamKaEnabled = prm.use_stream_ka;576 mediaConfig.streamKaEnabled = PJ2BOOL(prm.use_stream_ka); 576 577 #else 577 578 mediaConfig.streamKaEnabled = false; … … 582 583 583 584 // AccountVideoConfig 584 videoConfig.autoShowIncoming = prm.vid_in_auto_show;585 videoConfig.autoTransmitOutgoing = prm.vid_out_auto_transmit;585 videoConfig.autoShowIncoming = PJ2BOOL(prm.vid_in_auto_show); 586 videoConfig.autoTransmitOutgoing = PJ2BOOL(prm.vid_out_auto_transmit); 586 587 videoConfig.windowFlags = prm.vid_wnd_flags; 587 588 videoConfig.defaultCaptureDevice = prm.vid_cap_dev; … … 623 624 } 624 625 625 626 ///////////////////////////////////////////////////////////////////////////////627 628 AccountPresenceStatus::AccountPresenceStatus()629 : isOnline(false), activity(PJRPID_ACTIVITY_UNKNOWN)630 {631 }632 626 633 627 /////////////////////////////////////////////////////////////////////////////// … … 662 656 */ 663 657 if (isValid() && pjsua_get_state() < PJSUA_STATE_CLOSING) { 658 // Cleanup buddies in the buddy list 659 while(buddyList.size() > 0) { 660 Buddy *b = buddyList[0]; 661 delete b; 662 } 663 664 664 PJSUA2_CHECK_EXPR( pjsua_acc_set_user_data(id, NULL) ); 665 665 PJSUA2_CHECK_EXPR( pjsua_acc_del(id) ); … … 724 724 725 725 void 726 Account::setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error)726 Account::setOnlineStatus(const PresenceStatus &pres_st) throw(Error) 727 727 { 728 728 pjrpid_element pj_rpid; … … 734 734 pj_rpid.note = str2Pj(pres_st.note); 735 735 736 PJSUA2_CHECK_EXPR( pjsua_acc_set_online_status2(id, pres_st.isOnline, 737 &pj_rpid) ); 736 PJSUA2_CHECK_EXPR( pjsua_acc_set_online_status2( 737 id, pres_st.status == PJSUA_BUDDY_STATUS_ONLINE, 738 &pj_rpid) ); 738 739 } 739 740 … … 743 744 } 744 745 746 void Account::presNotify(const PresNotifyParam &prm) throw(Error) 747 { 748 pj_str_t pj_state_str = str2Pj(prm.stateStr); 749 pj_str_t pj_reason = str2Pj(prm.reason); 750 pjsua_msg_data msg_data; 751 prm.txOption.toPj(msg_data); 752 753 PJSUA2_CHECK_EXPR( pjsua_pres_notify(id, (pjsua_srv_pres*)prm.srvPres, 754 prm.state, &pj_state_str, 755 &pj_reason, prm.withBody, 756 &msg_data) ); 757 } 758 759 const BuddyVector& Account::enumBuddies() const throw(Error) 760 { 761 return buddyList; 762 } 763 764 Buddy* Account::findBuddy(string uri, FindBuddyMatch *buddy_match) const 765 throw(Error) 766 { 767 if (!buddy_match) { 768 static FindBuddyMatch def_bm; 769 buddy_match = &def_bm; 770 } 771 772 for (unsigned i = 0; i < buddyList.size(); i++) { 773 if (buddy_match->match(uri, *buddyList[i])) 774 return buddyList[i]; 775 } 776 PJSUA2_RAISE_ERROR(PJ_ENOTFOUND); 777 } 778 779 void Account::addBuddy(Buddy *buddy) 780 { 781 pj_assert(buddy); 782 783 buddyList.push_back(buddy); 784 } 785 786 void Account::removeBuddy(Buddy *buddy) 787 { 788 pj_assert(buddy); 789 790 BuddyVector::iterator it; 791 for (it = buddyList.begin(); it != buddyList.end(); it++) { 792 if (*it == buddy) { 793 buddyList.erase(it); 794 return; 795 } 796 } 797 798 pj_assert(!"Bug! Buddy to be removed is not in the buddy list!"); 799 } -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp
r4644 r4657 19 19 #include <pjsua2/endpoint.hpp> 20 20 #include <pjsua2/account.hpp> 21 #include <pjsua2/presence.hpp> 21 22 #include "util.hpp" 22 23 … … 63 64 } 64 65 65 this->stunIgnoreFailure = ua_cfg.stun_ignore_failure;66 this->stunIgnoreFailure = PJ2BOOL(ua_cfg.stun_ignore_failure); 66 67 this->natTypeInSdp = ua_cfg.nat_type_in_sdp; 67 this->mwiUnsolicitedEnabled = ua_cfg.enable_unsolicited_mwi;68 this->mwiUnsolicitedEnabled = PJ2BOOL(ua_cfg.enable_unsolicited_mwi); 68 69 } 69 70 … … 205 206 this->audioFramePtime = mc.audio_frame_ptime; 206 207 this->maxMediaPorts = mc.max_media_ports; 207 this->hasIoqueue = mc.has_ioqueue;208 this->hasIoqueue = PJ2BOOL(mc.has_ioqueue); 208 209 this->threadCnt = mc.thread_cnt; 209 210 this->quality = mc.quality; 210 211 this->ptime = mc.ptime; 211 this->noVad = mc.no_vad;212 this->noVad = PJ2BOOL(mc.no_vad); 212 213 this->ilbcMode = mc.ilbc_mode; 213 214 this->txDropPct = mc.tx_drop_pct; … … 222 223 this->jbMax = mc.jb_max; 223 224 this->sndAutoCloseTime = mc.snd_auto_close_time; 224 this->vidPreviewEnableNative = mc.vid_preview_enable_native;225 this->vidPreviewEnableNative = PJ2BOOL(mc.vid_preview_enable_native); 225 226 } 226 227 … … 362 363 } catch (Error &err) { 363 364 // Ignore 365 PJ_UNUSED_ARG(err); 364 366 } 365 367 delete writer; … … 412 414 pj_timer_entry *entry) 413 415 { 416 PJ_UNUSED_ARG(timer_heap); 417 414 418 Endpoint &ep = Endpoint::instance(); 415 419 UserTimer *ut = (UserTimer*) entry->user_data; … … 505 509 506 510 OnRegStartedParam prm; 507 prm.renew = renew;511 prm.renew = PJ2BOOL(renew); 508 512 acc->onRegStarted(prm); 509 513 } … … 536 540 pjsua_msg_data *msg_data) 537 541 { 542 PJ_UNUSED_ARG(buddy_id); 543 PJ_UNUSED_ARG(srv_pres); 544 538 545 Account *acc = lookupAcc(acc_id, "on_incoming_subscribe()"); 539 546 if (!acc) { … … 543 550 544 551 OnIncomingSubscribeParam prm; 552 prm.srvPres = srv_pres; 545 553 prm.fromUri = pj2Str(*from); 546 554 prm.rdata.fromPj(*rdata); 547 555 prm.code = *code; 548 556 prm.reason = pj2Str(*reason); 557 prm.txOption.fromPj(*msg_data); 549 558 550 559 acc->onIncomingSubscribe(prm); … … 553 562 acc->tmpReason = prm.reason; 554 563 *reason = str2Pj(acc->tmpReason); 555 // TODO: 556 // apply msg_data 564 prm.txOption.toPj(*msg_data); 557 565 } 558 566 … … 599 607 pjsua_acc_id acc_id) 600 608 { 609 PJ_UNUSED_ARG(tdata); 610 601 611 OnInstantMessageStatusParam prm; 602 612 prm.userData = user_data; … … 667 677 } 668 678 679 void Endpoint::on_buddy_state(pjsua_buddy_id buddy_id) 680 { 681 Buddy *buddy = (Buddy*)pjsua_buddy_get_user_data(buddy_id); 682 if (!buddy || !buddy->isValid()) { 683 /* Ignored */ 684 return; 685 } 686 687 buddy->onBuddyState(); 688 } 689 669 690 670 691 /////////////////////////////////////////////////////////////////////////////// … … 723 744 ua_cfg.cb.on_typing2 = &Endpoint::on_typing2; 724 745 ua_cfg.cb.on_mwi_info = &Endpoint::on_mwi_info; 746 ua_cfg.cb.on_buddy_state = &Endpoint::on_buddy_state; 725 747 726 748 /* Init! */ -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/json.cpp
r4644 r4657 124 124 PJSUA2_RAISE_ERROR(PJ_ENOTFOUND); 125 125 126 pj_ssize_t size = pj_file_size(filename.c_str());126 pj_ssize_t size = (pj_ssize_t)pj_file_size(filename.c_str()); 127 127 pj_status_t status; 128 128 … … 359 359 json_verify(jdat, "readBool()", name, PJ_JSON_VAL_BOOL); 360 360 jdat->childPtr = jdat->childPtr->next; 361 return jdat->childPtr->prev->value.is_true;361 return PJ2BOOL(jdat->childPtr->prev->value.is_true); 362 362 } 363 363 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/persistent.cpp
r4644 r4657 85 85 int num) throw(Error) 86 86 { 87 getRootContainer().writeNumber(name, num);87 getRootContainer().writeNumber(name, (float)num); 88 88 } 89 89 … … 188 188 int num) throw(Error) 189 189 { 190 return op->writeNumber(this, name, num);190 return op->writeNumber(this, name, (float)num); 191 191 } 192 192 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/siptypes.cpp
r4655 r4657 46 46 ContainerNode array_node = node.writeNewArray(array_name); 47 47 for (unsigned i=0; i<v.size(); ++i) { 48 array_node.writeNumber("", v[i]);48 array_node.writeNumber("", (float)v[i]); 49 49 } 50 50 } … … 190 190 pj_assert(sizeof(prm.ciphers[0]) == sizeof(int)); 191 191 this->ciphers = IntVector(prm.ciphers, prm.ciphers+prm.ciphers_num); 192 this->verifyServer = prm.verify_server;193 this->verifyClient = prm.verify_client;194 this->requireClientCert = prm.require_client_cert;192 this->verifyServer = PJ2BOOL(prm.verify_server); 193 this->verifyClient = PJ2BOOL(prm.verify_client); 194 this->requireClientCert = PJ2BOOL(prm.require_client_cert); 195 195 this->msecTimeout = PJ_TIME_VAL_MSEC(prm.timeout); 196 196 this->qosType = prm.qos_type; 197 197 this->qosParams = prm.qos_params; 198 this->qosIgnoreError = prm.qos_ignore_error;198 this->qosIgnoreError = PJ2BOOL(prm.qos_ignore_error); 199 199 } 200 200 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/util.hpp
r4644 r4657 21 21 #include <string> 22 22 23 #define PJ2BOOL(var) ((var) != PJ_FALSE) 24 23 25 namespace pj 24 26 {
Note: See TracChangeset
for help on using the changeset viewer.