Changeset 492 for pjproject/trunk/pjsip-apps/src/activex-pjsua/app.cpp
- Timestamp:
- Jun 6, 2006 6:40:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/activex-pjsua/app.cpp
r487 r492 14 14 { 0x9ce3052a, 0x7a32, 0x4229, { 0xb3, 0x1c, 0x5e, 0x2, 0xe0, 0x66, 0x7a, 0x77 } }; 15 15 16 // {7F6CFF0F-C5B3-41e8-B278-61CD584C1F34} 17 static const GUID IID_Pjsip_Sip_Uri = 18 { 0x7f6cff0f, 0xc5b3, 0x41e8, { 0xb2, 0x78, 0x61, 0xcd, 0x58, 0x4c, 0x1f, 0x34 } }; 19 16 20 // {3B12B04F-6E48-46a7-B9E0-6C4BF1594A96} 17 21 static const GUID IID_Pjsua_Acc_Config = … … 33 37 static const GUID IID_Pjsua_Acc_Info = 34 38 { 0x8d345956, 0x10b7, 0x4450, { 0x8a, 0x6, 0xa8, 0xd, 0x2f, 0x31, 0x9e, 0xfd } }; 39 40 // {0D05907A-3E1F-4c92-9FD0-26CB6E1CC56A} 41 static const GUID IID_Pjsua_Conf_Port_Info = 42 { 0xd05907a, 0x3e1f, 0x4c92, { 0x9f, 0xd0, 0x26, 0xcb, 0x6e, 0x1c, 0xc5, 0x6a } }; 43 35 44 36 45 #define SA_SIZE(lbound,ubound) (ubound-lbound) … … 118 127 *count = 0; 119 128 for (i=0; i<sa->cbElements; ++i) { 120 BSTR str ;129 BSTR str = NULL; 121 130 long rg = lbound + i; 122 131 hr = SafeArrayGetElement(sa, &rg, &str); … … 175 184 Pjsip_Cred_Info cred_info; 176 185 long rg = lbound + i; 186 pj_memset(&cred_info, 0, sizeof(cred_info)); 177 187 hr = SafeArrayGetElement(c1->cred_info, &rg, &cred_info); 178 188 if (FAILED(hr)) … … 245 255 c2->sip_port = c1->sip_port; 246 256 c2->start_rtp_port = c1->rtp_port; 257 c2->msg_logging = c1->msg_logging; 247 258 c2->max_calls = c1->max_calls; 248 259 c2->conf_ports = c1->conf_ports; … … 281 292 Pjsua_Acc_Config acc_config; 282 293 long rg = lbound + i; 294 pj_memset(&acc_config, 0, sizeof(acc_config)); 283 295 hr = SafeArrayGetElement(c1->acc_config, &rg, &acc_config); 284 296 if (FAILED(hr)) … … 312 324 c2->sip_port = c1->sip_port; 313 325 c2->rtp_port = c1->start_rtp_port; 326 c2->msg_logging = c1->msg_logging; 314 327 c2->max_calls = c1->max_calls; 315 328 c2->conf_ports = c1->conf_ports; … … 387 400 c2->connect_duration = c1->connect_duration.sec; 388 401 c2->total_duration = c1->total_duration.sec; 389 c2-> cause = c1->cause;390 Cp(c2-> cause_text, &c1->cause_text);402 c2->last_status = c1->last_status; 403 Cp(c2->last_status_text, &c1->last_status_text); 391 404 c2->has_media = c1->has_media; 392 405 c2->conf_slot = c1->conf_slot; … … 398 411 399 412 info2->index = info1->index; 400 Cp(info2->acc_ id, &info1->acc_id);413 Cp(info2->acc_uri, &info1->acc_id); 401 414 info2->has_registration = info1->has_registration; 402 415 info2->expires = info1->expires; … … 420 433 Cp(info2->status_text, &info1->status_text); 421 434 info2->monitor = info1->monitor; 422 info2->acc_index = info1->acc_index;423 435 } 424 436 … … 464 476 Pjsua_Call_Info *Call_Info = new Pjsua_Call_Info; 465 477 466 pjsua_ get_call_info(call_index, &call_info);478 pjsua_call_get_info(call_index, &call_info); 467 479 callinfo2CallInfo(&call_info, Call_Info); 468 480 … … 470 482 } 471 483 472 static void on_reg_state(int acc_index) 473 { 474 CApp_Instance->Fire_OnRegState(acc_index); 484 static void on_incoming_call(int acc_id, int call_index, 485 pjsip_rx_data *rdata) 486 { 487 CApp_Instance->Fire_OnIncomingCall(call_index); 488 } 489 490 static void on_reg_state(int acc_id) 491 { 492 CApp_Instance->Fire_OnRegState(acc_id); 475 493 } 476 494 … … 513 531 pj_memset(&cb, 0, sizeof(cb)); 514 532 cb.on_call_state = &on_call_state; 533 cb.on_incoming_call = &on_incoming_call; 515 534 cb.on_reg_state = &on_reg_state; 516 535 cb.on_buddy_state = &on_buddy_state; … … 540 559 STDMETHODIMP CApp::call_get_max_count(int *retCount) 541 560 { 542 *retCount = pjsua_ get_max_calls();561 *retCount = pjsua_call_get_max_count(); 543 562 return S_OK; 544 563 } … … 546 565 STDMETHODIMP CApp::call_get_count(int *retCount) 547 566 { 548 *retCount = pjsua_ get_call_count();567 *retCount = pjsua_call_get_count(); 549 568 return S_OK; 550 569 } … … 565 584 { 566 585 pjsua_call_info info; 567 *pRet = pjsua_ get_call_info(call_index, &info);586 *pRet = pjsua_call_get_info(call_index, &info); 568 587 callinfo2CallInfo(&info, pInfo); 569 588 return S_OK; 570 589 } 571 590 572 STDMETHODIMP CApp::call_make_call(int acc_i ndex, Pj_String dst_uri, int *call_index, Pj_Status *pRet)591 STDMETHODIMP CApp::call_make_call(int acc_id, Pj_String dst_uri, int *call_index, Pj_Status *pRet) 573 592 { 574 593 Temp_Pool tp; 575 594 pj_str_t tmp = Pj_str(tp.get_pool(), dst_uri); 576 595 577 *pRet = pjsua_ make_call(acc_index, &tmp, call_index);596 *pRet = pjsua_call_make_call(acc_id, &tmp, call_index); 578 597 return S_OK; 579 598 } … … 581 600 STDMETHODIMP CApp::call_answer(int call_index, int status_code, Pj_Status *pRet) 582 601 { 583 pjsua_call_answer(call_index, status_code); 584 *pRet = PJ_SUCCESS; 602 *pRet = pjsua_call_answer(call_index, status_code); 585 603 return S_OK; 586 604 } … … 602 620 STDMETHODIMP CApp::call_release_hold(int call_index, Pj_Status *pRet) 603 621 { 604 pjsua_call_reinvite(call_index); 605 *pRet = PJ_SUCCESS; 622 *pRet = pjsua_call_reinvite(call_index); 606 623 return S_OK; 607 624 } … … 611 628 Temp_Pool tp; 612 629 pj_str_t tmp = Pj_str(tp.get_pool(), dst_uri); 613 pjsua_call_xfer(call_index, &tmp); 614 *pRet = PJ_SUCCESS; 630 *pRet = pjsua_call_xfer(call_index, &tmp); 615 631 return S_OK; 616 632 } … … 628 644 Temp_Pool tp; 629 645 pj_str_t tmp = Pj_str(tp.get_pool(), text); 630 pjsua_call_send_im(call_index, &tmp); 631 *pRet = PJ_SUCCESS; 646 *pRet = pjsua_call_send_im(call_index, &tmp); 632 647 return S_OK; 633 648 } … … 635 650 STDMETHODIMP CApp::call_typing(int call_index, int is_typing, Pj_Status *pRet) 636 651 { 637 pjsua_call_typing(call_index, is_typing); 638 *pRet = PJ_SUCCESS; 652 *pRet = pjsua_call_send_typing_ind(call_index, is_typing); 639 653 return S_OK; 640 654 } … … 649 663 { 650 664 char buf[1024]; 651 pjsua_ dump_call(call_index, 1, buf, sizeof(buf), "");665 pjsua_call_dump(call_index, 1, buf, sizeof(buf), ""); 652 666 653 667 OLECHAR wbuf[1024]; … … 664 678 } 665 679 666 STDMETHODIMP CApp::acc_get_info(int acc_i ndex, Pjsua_Acc_Info *pInfo, Pj_Status *pRet)680 STDMETHODIMP CApp::acc_get_info(int acc_id, Pjsua_Acc_Info *pInfo, Pj_Status *pRet) 667 681 { 668 682 pjsua_acc_info info; 669 *pRet = pjsua_acc_get_info(acc_i ndex, &info);683 *pRet = pjsua_acc_get_info(acc_id, &info); 670 684 accinfo2AccInfo(&info, pInfo); 671 685 return S_OK; … … 681 695 } 682 696 683 STDMETHODIMP CApp::acc_set_online_status(int acc_i ndex, int is_online, Pj_Status *pRet)684 { 685 *pRet = pjsua_acc_set_online_status(acc_i ndex, is_online);686 return S_OK; 687 } 688 689 STDMETHODIMP CApp::acc_set_registration(int acc_i ndex, int reg_active, Pj_Status *pRet)690 { 691 *pRet = pjsua_acc_set_registration(acc_i ndex, reg_active);697 STDMETHODIMP CApp::acc_set_online_status(int acc_id, int is_online, Pj_Status *pRet) 698 { 699 *pRet = pjsua_acc_set_online_status(acc_id, is_online); 700 return S_OK; 701 } 702 703 STDMETHODIMP CApp::acc_set_registration(int acc_id, int reg_active, Pj_Status *pRet) 704 { 705 *pRet = pjsua_acc_set_registration(acc_id, reg_active); 692 706 return S_OK; 693 707 } … … 718 732 { 719 733 *pRet = pjsua_buddy_subscribe_pres(buddy_index, subscribe); 720 pjsua_pres_refresh(); 721 return S_OK; 722 } 723 724 STDMETHODIMP CApp::im_send_text(int acc_index, Pj_String dst_uri, Pj_String text, Pj_Status *pRet) 734 return S_OK; 735 } 736 737 STDMETHODIMP CApp::im_send_text(int acc_id, Pj_String dst_uri, Pj_String text, Pj_Status *pRet) 725 738 { 726 739 Temp_Pool tp; 727 740 pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); 728 741 pj_str_t tmp_text = Pj_str(tp.get_pool(), text); 729 *pRet = pjsua_im_send(acc_i ndex, &tmp_uri, &tmp_text);730 return S_OK; 731 } 732 733 STDMETHODIMP CApp::im_typing(int acc_i ndex, Pj_URI dst_uri, int is_typing, Pj_Status *pRet)742 *pRet = pjsua_im_send(acc_id, &tmp_uri, &tmp_text); 743 return S_OK; 744 } 745 746 STDMETHODIMP CApp::im_typing(int acc_id, Pj_URI dst_uri, int is_typing, Pj_Status *pRet) 734 747 { 735 748 Temp_Pool tp; 736 749 pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); 737 *pRet = pjsua_im_typing(acc_i ndex, &tmp_uri, is_typing);750 *pRet = pjsua_im_typing(acc_id, &tmp_uri, is_typing); 738 751 return S_OK; 739 752 } … … 803 816 pj_str_t tmp = Pj_str(tp.get_pool(), filename); 804 817 pjsua_default_config(&config); 805 *pRet = pjsua_load_settings(tmp.ptr, &config );818 *pRet = pjsua_load_settings(tmp.ptr, &config, NULL); 806 819 if (*pRet == PJ_SUCCESS) 807 820 *pRet = config2Config(&config, pConfig); … … 826 839 STDMETHODIMP CApp::app_get_current_config(Pjsua_Config *pConfig) 827 840 { 828 pjsua_config *config; 829 config = (pjsua_config*) pjsua_get_config(); 830 return config2Config(config, pConfig); 841 Temp_Pool tp; 842 pjsua_config config; 843 844 pjsua_get_config(tp.get_pool(), &config); 845 return config2Config(&config, pConfig); 831 846 } 832 847 … … 857 872 return S_OK; 858 873 } 874 875 STDMETHODIMP CApp::app_parse_uri(BSTR uriString, Pjsip_Sip_Uri *pSipUri, Pj_Status *pStatus) 876 { 877 Temp_Pool tp; 878 pj_str_t tmp = Pj_str(tp.get_pool(), uriString); 879 pjsip_name_addr *addr; 880 char buf[1024]; 881 pj_str_t s; 882 883 addr = (pjsip_name_addr*) 884 pjsip_parse_uri(tp.get_pool(), tmp.ptr, tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR); 885 if (addr == NULL) { 886 *pStatus = PJSIP_EINVALIDURI; 887 return S_OK; 888 } 889 890 if (!PJSIP_URI_SCHEME_IS_SIP(addr) && !PJSIP_URI_SCHEME_IS_SIPS(addr)) { 891 *pStatus = PJSIP_EINVALIDSCHEME; 892 return S_OK; 893 } 894 895 pjsip_sip_uri *sip = (pjsip_sip_uri*)addr->uri; 896 897 Cp2(&pSipUri->display, &addr->display); 898 Cp2(&pSipUri->user, &sip->user); 899 Cp2(&pSipUri->passwd, &sip->passwd); 900 Cp2(&pSipUri->host, &sip->host); 901 pSipUri->port = sip->port; 902 Cp2(&pSipUri->param_user, &sip->user_param); 903 Cp2(&pSipUri->param_method, &sip->method_param); 904 Cp2(&pSipUri->param_transport, &sip->transport_param); 905 pSipUri->param_ttl = sip->ttl_param; 906 pSipUri->param_lr = sip->lr_param; 907 Cp2(&pSipUri->param_maddr, &sip->maddr_param); 908 909 s.ptr = buf; 910 s.slen = pjsip_param_print_on(&sip->other_param, buf, sizeof(buf), 911 &pjsip_PARAM_CHAR_SPEC, &pjsip_PARAM_CHAR_SPEC, ';'); 912 Cp2(&pSipUri->param_other, &s); 913 914 s.slen = pjsip_param_print_on(&sip->header_param, buf, sizeof(buf), 915 &pjsip_HDR_CHAR_SPEC, &pjsip_HDR_CHAR_SPEC, '?'); 916 Cp2(&pSipUri->param_header, &s); 917 918 *pStatus = PJ_SUCCESS; 919 return S_OK; 920 } 921 922 STDMETHODIMP CApp::app_print_uri(Pjsip_Sip_Uri *pSipURI, Pjsip_Uri_Context context, BSTR *uriText) 923 { 924 Temp_Pool tp; 925 pjsip_name_addr *addr; 926 pj_str_t tmp; 927 char buf[1024]; 928 pjsip_sip_uri *sip; 929 930 addr = pjsip_name_addr_create(tp.get_pool()); 931 sip = pjsip_sip_uri_create(tp.get_pool(), PJ_FALSE); 932 addr->uri = (pjsip_uri*)sip; 933 934 addr->display = Pj_str(tp.get_pool(), pSipURI->display); 935 sip->user = Pj_str(tp.get_pool(), pSipURI->user); 936 sip->passwd = Pj_str(tp.get_pool(), pSipURI->passwd); 937 sip->host = Pj_str(tp.get_pool(), pSipURI->host); 938 sip->port = pSipURI->port; 939 sip->user_param = Pj_str(tp.get_pool(), pSipURI->param_user); 940 sip->method_param = Pj_str(tp.get_pool(), pSipURI->param_method); 941 sip->transport_param = Pj_str(tp.get_pool(), pSipURI->param_transport); 942 sip->ttl_param = pSipURI->param_ttl; 943 sip->lr_param = pSipURI->param_lr; 944 sip->maddr_param = Pj_str(tp.get_pool(), pSipURI->param_maddr); 945 946 /* Unfortunately can't transport params yet (no parsing function) */ 947 948 tmp.ptr = buf; 949 tmp.slen = pjsip_uri_print((pjsip_uri_context_e)context, addr, buf, sizeof(buf)); 950 951 Cp2(uriText, &tmp); 952 return S_OK; 953 } 954 955 STDMETHODIMP CApp::app_compare_uri_string(Pjsip_Uri_Context context, BSTR uri1, BSTR uri2, Pj_Status *pStatus) 956 { 957 Temp_Pool tp; 958 959 pj_str_t tmp_uri1 = Pj_str(tp.get_pool(), uri1); 960 pj_str_t tmp_uri2 = Pj_str(tp.get_pool(), uri2); 961 962 pjsip_uri *u1, *u2; 963 964 u1 = pjsip_parse_uri(tp.get_pool(), tmp_uri1.ptr, tmp_uri1.slen, PJSIP_PARSE_URI_AS_NAMEADDR); 965 if (u1 == NULL) { 966 *pStatus = PJSIP_EINVALIDURI; 967 return S_OK; 968 } 969 970 u2 = pjsip_parse_uri(tp.get_pool(), tmp_uri2.ptr, tmp_uri2.slen, PJSIP_PARSE_URI_AS_NAMEADDR); 971 if (u2 == NULL) { 972 *pStatus = PJSIP_EINVALIDURI; 973 return S_OK; 974 } 975 976 *pStatus = pjsip_uri_cmp((pjsip_uri_context_e)context, u1, u2); 977 return S_OK; 978 } 979 980 STDMETHODIMP CApp::buddy_del(int buddy_index, Pj_Status *pRet) 981 { 982 *pRet = pjsua_buddy_del(buddy_index); 983 return S_OK; 984 } 985 986 STDMETHODIMP CApp::acc_del(int acc_id, Pj_Status *pRet) 987 { 988 *pRet = pjsua_acc_del(acc_id); 989 return S_OK; 990 } 991 992 STDMETHODIMP CApp::acc_find_for_outgoing(BSTR url, int *acc_id) 993 { 994 Temp_Pool tp; 995 996 pj_str_t tmp_uri = Pj_str(tp.get_pool(), url); 997 998 *acc_id = pjsua_acc_find_for_outgoing(&tmp_uri); 999 1000 return S_OK; 1001 } 1002 1003 STDMETHODIMP CApp::acc_enum_id(SAFEARRAY **accIdArray) 1004 { 1005 int id[32]; 1006 unsigned count = PJ_ARRAY_SIZE(id); 1007 unsigned i; 1008 1009 pjsua_acc_enum_id(id, &count); 1010 1011 *accIdArray = SafeArrayCreateVector(VT_INT, 0, count); 1012 1013 for (i=0; i<count; ++i) { 1014 long rg = i; 1015 SafeArrayPutElement(*accIdArray, &rg, &id[i]); 1016 } 1017 1018 return S_OK; 1019 } 1020 1021 STDMETHODIMP CApp::conf_enum_ports(SAFEARRAY **pPortsArray) 1022 { 1023 int id[128]; 1024 unsigned count = PJ_ARRAY_SIZE(id); 1025 unsigned i; 1026 1027 pjsua_conf_enum_port_ids(id, &count); 1028 1029 *pPortsArray = SafeArrayCreateVector(VT_INT, 0, count); 1030 1031 for (i=0; i<count; ++i) { 1032 long rg = i; 1033 SafeArrayPutElement(*pPortsArray, &rg, &id[i]); 1034 } 1035 1036 return S_OK; 1037 } 1038 1039 STDMETHODIMP CApp::conf_get_port_info(int port_id, Pjsua_Conf_Port_Info *pInfo, Pj_Status *pRet) 1040 { 1041 unsigned i; 1042 pjsua_conf_port_info info; 1043 1044 *pRet = pjsua_conf_get_port_info(port_id, &info); 1045 if (*pRet != PJ_SUCCESS) 1046 return S_OK; 1047 1048 pInfo->slot_id = info.slot_id; 1049 Cp2(&pInfo->name, &info.name); 1050 pInfo->clock_rate = info.clock_rate; 1051 pInfo->channel_count = info.channel_count; 1052 pInfo->samples_per_frame = info.samples_per_frame; 1053 pInfo->bits_per_sample = info.bits_per_sample; 1054 1055 1056 pInfo->listeners = SafeArrayCreateVector(VT_INT, 0, info.listener_cnt); 1057 1058 for (i=0; i<info.listener_cnt; ++i) { 1059 long rg = i; 1060 SafeArrayPutElement(pInfo->listeners, &rg, &info.listeners[i]); 1061 } 1062 1063 return S_OK; 1064 } 1065
Note: See TracChangeset
for help on using the changeset viewer.