Changeset 201


Ignore:
Timestamp:
Feb 19, 2006 3:37:19 PM (18 years ago)
Author:
bennylp
Message:

SIMPLE test with FWD, and added more info in UI

Location:
pjproject/trunk/pjsip
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h

    r167 r201  
    6060    void                *token; 
    6161    int                  code; 
     62    pj_status_t          status; 
    6263    pj_str_t             reason; 
    6364    pjsip_rx_data       *rdata; 
     
    7172typedef void pjsip_regc_cb(struct pjsip_regc_cbparam *param); 
    7273 
     74/** 
     75 * Client registration information. 
     76 */ 
     77struct pjsip_regc_info 
     78{ 
     79    pj_str_t    server_uri; /**< Server URI,                                */ 
     80    pj_str_t    client_uri; /**< Client URI (From header).                  */ 
     81    pj_bool_t   is_busy;    /**< Have pending transaction?                  */ 
     82    pj_bool_t   auto_reg;   /**< Will register automatically?               */ 
     83    int         interval;   /**< Registration interval (seconds).           */ 
     84    int         next_reg;   /**< Time until next registration (seconds).    */ 
     85}; 
     86 
     87/** 
     88 * @see pjsip_regc_info 
     89 */ 
     90typedef struct pjsip_regc_info pjsip_regc_info; 
     91 
    7392 
    7493/** 
     
    105124 */ 
    106125PJ_DECL(pj_status_t) pjsip_regc_destroy(pjsip_regc *regc); 
     126 
     127/** 
     128 * Get registration info. 
     129 * 
     130 * @param regc      The client registration structure. 
     131 * @param info      Client registration info. 
     132 * 
     133 * @return          PJ_SUCCESS on success. 
     134 */ 
     135PJ_DECL(pj_status_t) pjsip_regc_get_info( pjsip_regc *regc, 
     136                                          pjsip_regc_info *info ); 
     137 
    107138 
    108139/** 
  • pjproject/trunk/pjsip/src/pjsip-simple/evsub.c

    r198 r201  
    128128    TIMER_TYPE_UAC_WAIT_NOTIFY, 
    129129 
     130    /* Max nb of timer types. */ 
     131    TIMER_TYPE_MAX 
    130132}; 
    131133 
     
    137139    "UAC_TERMINATE", 
    138140    "UAC_WAIT_NOTIFY", 
     141    "INVALID_TIMER" 
    139142}; 
    140143 
     
    250253{ 
    251254    pj_status_t status; 
     255    pj_str_t method_tags[] = { 
     256        { "SUBSCRIBE", 9}, 
     257        { "NOTIFY", 6} 
     258    }; 
    252259 
    253260    PJ_ASSERT_RETURN(endpt != NULL, PJ_EINVAL); 
     
    276283    pjsip_evsub_init_parser(); 
    277284 
     285    /* Register new methods SUBSCRIBE and NOTIFY in Allow-ed header */ 
     286    pjsip_endpt_add_capability(endpt, &mod_evsub.mod, PJSIP_H_ALLOW, NULL, 
     287                               2, method_tags); 
     288 
     289    /* Done. */ 
    278290    return PJ_SUCCESS; 
    279291 
     
    437449 
    438450        PJ_ASSERT_ON_FAIL(seconds > 0, return); 
     451        PJ_ASSERT_ON_FAIL(timer_id>TIMER_TYPE_NONE && timer_id<TIMER_TYPE_MAX, 
     452                          return); 
    439453 
    440454        timeout.sec = seconds; 
  • pjproject/trunk/pjsip/src/pjsip-simple/xpidf.c

    r197 r201  
    3030static pj_str_t ATOM = { "atom", 4 }; 
    3131static pj_str_t ATOMID = { "atomid", 6 }; 
     32static pj_str_t ID = { "id", 2 }; 
    3233static pj_str_t ADDRESS = { "address", 7 }; 
    3334static pj_str_t SUBSCRIBE_PARAM = { ";method=SUBSCRIBE", 17 }; 
     
    127128    if (pj_stricmp(&pres->name, &PRESENCE) != 0) 
    128129        return NULL; 
    129     if (pj_xml_find_attr(pres, &URI, NULL) == NULL) 
    130         return NULL; 
    131130 
    132131    /* Validate <presentity> */ 
     
    134133    if (node == NULL) 
    135134        return NULL; 
     135    if (pj_xml_find_attr(node, &URI, NULL) == NULL) 
     136        return NULL; 
    136137 
    137138    /* Validate <atom> */ 
     
    139140    if (node == NULL) 
    140141        return NULL; 
    141     if (pj_xml_find_attr(node, &ATOMID, NULL) == NULL) 
    142         return NULL; 
     142    if (pj_xml_find_attr(node, &ATOMID, NULL) == NULL &&  
     143        pj_xml_find_attr(node, &ID, NULL) == NULL) 
     144    { 
     145        return NULL; 
     146    } 
    143147 
    144148    /* Address */ 
     
    247251        return PJ_FALSE; 
    248252    } 
    249     status = pj_xml_find_node(atom, &STATUS); 
     253    status = pj_xml_find_node(addr, &STATUS); 
    250254    if (!status) { 
    251255        pj_assert(0); 
     
    258262    } 
    259263 
    260     return pj_stricmp(&attr->value, &OPEN) ? PJ_TRUE : PJ_FALSE; 
     264    return pj_stricmp(&attr->value, &OPEN)==0 ? PJ_TRUE : PJ_FALSE; 
    261265} 
    262266 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c

    r167 r201  
    2626#include <pjsip/sip_auth_msg.h> 
    2727#include <pjsip/sip_errno.h> 
     28#include <pj/assert.h> 
     29#include <pj/guid.h> 
     30#include <pj/os.h> 
    2831#include <pj/pool.h> 
     32#include <pj/log.h> 
    2933#include <pj/string.h> 
    30 #include <pj/guid.h> 
    31 #include <pj/log.h> 
    32 #include <pj/assert.h> 
    3334 
    3435 
     
    5455    pjsip_cid_hdr               *cid_hdr; 
    5556    pjsip_cseq_hdr              *cseq_hdr; 
     57    pj_str_t                     from_uri; 
    5658    pjsip_from_hdr              *from_hdr; 
    5759    pjsip_to_hdr                *to_hdr; 
     
    6971    /* Auto refresh registration. */ 
    7072    pj_bool_t                    auto_reg; 
     73    pj_time_val                  last_reg; 
     74    pj_time_val                  next_reg; 
    7175    pj_timer_entry               timer; 
    7276}; 
     
    111115PJ_DEF(pj_status_t) pjsip_regc_destroy(pjsip_regc *regc) 
    112116{ 
     117    PJ_ASSERT_RETURN(regc, PJ_EINVAL); 
     118 
    113119    if (regc->pending_tsx) { 
    114120        regc->_delete_flag = 1; 
     
    116122    } else { 
    117123        pjsip_endpt_release_pool(regc->endpt, regc->pool); 
     124    } 
     125 
     126    return PJ_SUCCESS; 
     127} 
     128 
     129 
     130PJ_DEF(pj_status_t) pjsip_regc_get_info( pjsip_regc *regc, 
     131                                         pjsip_regc_info *info ) 
     132{ 
     133    PJ_ASSERT_RETURN(regc && info, PJ_EINVAL); 
     134 
     135    info->server_uri = regc->str_srv_url; 
     136    info->client_uri = regc->from_uri; 
     137    info->is_busy = (regc->pending_tsx != 0); 
     138    info->auto_reg = regc->auto_reg; 
     139    info->interval = regc->expires; 
     140     
     141    if (regc->pending_tsx) 
     142        info->next_reg = 0; 
     143    else if (regc->auto_reg == 0) 
     144        info->next_reg = 0; 
     145    else if (regc->expires < 0) 
     146        info->next_reg = regc->expires; 
     147    else { 
     148        pj_time_val now, next_reg; 
     149 
     150        next_reg = regc->next_reg; 
     151        pj_gettimeofday(&now); 
     152        PJ_TIME_VAL_SUB(next_reg, now); 
     153        info->next_reg = next_reg.sec; 
    118154    } 
    119155 
     
    195231 
    196232    /* Set "From" header. */ 
    197     pj_strdup_with_null(regc->pool, &tmp, from_url); 
     233    pj_strdup_with_null(regc->pool, &regc->from_uri, from_url); 
     234    tmp = regc->from_uri; 
    198235    regc->from_hdr = pjsip_from_hdr_create(regc->pool); 
    199236    regc->from_hdr->uri = pjsip_parse_uri(regc->pool, tmp.ptr, tmp.slen,  
     
    326363    pjsip_tx_data *tdata; 
    327364 
     365    PJ_ASSERT_RETURN(regc && p_tdata, PJ_EINVAL); 
     366 
    328367    status = create_request(regc, &tdata); 
    329368    if (status != PJ_SUCCESS) 
     
    356395    pj_status_t status; 
    357396 
     397    PJ_ASSERT_RETURN(regc && p_tdata, PJ_EINVAL); 
     398 
    358399    if (regc->timer.id != 0) { 
    359400        pjsip_endpt_cancel_timer(regc->endpt, &regc->timer); 
     
    378419                                                const pj_str_t contact[] ) 
    379420{ 
     421    PJ_ASSERT_RETURN(regc, PJ_EINVAL); 
    380422    return set_contact( regc, contact_cnt, contact ); 
    381423} 
     
    385427                                                pj_uint32_t expires ) 
    386428{ 
     429    PJ_ASSERT_RETURN(regc, PJ_EINVAL); 
    387430    set_expires( regc, expires ); 
    388431    return PJ_SUCCESS; 
     
    390433 
    391434 
    392 static void call_callback(pjsip_regc *regc, int status, const pj_str_t *reason, 
     435static void call_callback(pjsip_regc *regc, pj_status_t status, int st_code,  
     436                          const pj_str_t *reason, 
    393437                          pjsip_rx_data *rdata, pj_int32_t expiration, 
    394438                          int contact_cnt, pjsip_contact_hdr *contact[]) 
     
    399443    cbparam.regc = regc; 
    400444    cbparam.token = regc->token; 
    401     cbparam.code = status; 
     445    cbparam.status = status; 
     446    cbparam.code = st_code; 
    402447    cbparam.reason = *reason; 
    403448    cbparam.rdata = rdata; 
     
    428473        char errmsg[PJ_ERR_MSG_SIZE]; 
    429474        pj_str_t reason = pj_strerror(status, errmsg, sizeof(errmsg)); 
    430         call_callback(regc, -1, &reason, NULL, -1, 0, NULL); 
     475        call_callback(regc, status, 400, &reason, NULL, -1, 0, NULL); 
    431476    } 
    432477} 
     
    438483    pjsip_transaction *tsx = event->body.tsx_state.tsx; 
    439484     
     485    /* Decrement pending transaction counter. */ 
     486    --regc->pending_tsx; 
     487 
    440488    /* If registration data has been deleted by user then remove registration  
    441489     * data from transaction's callback, and don't call callback. 
    442490     */ 
    443491    if (regc->_delete_flag) { 
    444         --regc->pending_tsx; 
     492 
     493        /* Nothing to do */ 
     494        ; 
    445495 
    446496    } else if (tsx->status_code == PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED || 
     
    456506 
    457507        if (status == PJ_SUCCESS) { 
    458             --regc->pending_tsx; 
    459508            pjsip_regc_send(regc, tdata); 
    460509            return; 
    461510        } else { 
    462             call_callback(regc, tsx->status_code, &rdata->msg_info.msg->line.status.reason, 
     511            call_callback(regc, status, tsx->status_code,  
     512                          &rdata->msg_info.msg->line.status.reason, 
    463513                          rdata, -1, 0, NULL); 
    464             --regc->pending_tsx; 
    465514        } 
    466515    } else { 
     
    513562                regc->timer.user_data = regc; 
    514563                pjsip_endpt_schedule_timer( regc->endpt, &regc->timer, &delay); 
     564                pj_gettimeofday(&regc->last_reg); 
     565                regc->next_reg = regc->last_reg; 
     566                regc->next_reg.sec += delay.sec; 
    515567            } 
    516568 
     
    523575        /* Call callback. */ 
    524576        if (expiration == 0xFFFF) expiration = -1; 
    525         call_callback(regc, tsx->status_code,  
     577        call_callback(regc, PJ_SUCCESS, tsx->status_code,  
    526578                      (rdata ? &rdata->msg_info.msg->line.status.reason  
    527579                        : pjsip_get_status_text(tsx->status_code)), 
     
    529581                      contact_cnt, contact); 
    530582 
    531         --regc->pending_tsx; 
    532583    } 
    533584 
     
    544595    /* Make sure we don't have pending transaction. */ 
    545596    if (regc->pending_tsx) { 
    546         pj_str_t reason = pj_str("Transaction in progress"); 
    547         call_callback(regc, -1, &reason, NULL, -1, 0, NULL); 
    548597        pjsip_tx_data_dec_ref( tdata ); 
    549         return PJ_EINVALIDOP; 
     598        return PJSIP_EBUSY; 
    550599    } 
    551600 
     
    560609    if (status==PJ_SUCCESS) 
    561610        ++regc->pending_tsx; 
    562     else { 
    563         char errmsg[PJ_ERR_MSG_SIZE]; 
    564         pj_str_t reason = pj_strerror(status, errmsg, sizeof(errmsg)); 
    565         call_callback(regc, status, &reason, NULL, -1, 0, NULL); 
    566     } 
    567611 
    568612    return status; 
  • pjproject/trunk/pjsip/src/pjsua/main.c

    r197 r201  
    9999static void keystroke_help(void) 
    100100{ 
    101  
    102     printf(">>>>\nOnline status: %s\n",  
     101    char reg_status[128]; 
     102 
     103    if (pjsua.regc == NULL) { 
     104        pj_ansi_strcpy(reg_status, " -not registered to server-"); 
     105    } else if (pjsua.regc_last_err != PJ_SUCCESS) { 
     106        pj_strerror(pjsua.regc_last_err, reg_status, sizeof(reg_status)); 
     107    } else if (pjsua.regc_last_code>=200 && pjsua.regc_last_code<=699) { 
     108 
     109        pjsip_regc_info info; 
     110 
     111        pjsip_regc_get_info(pjsua.regc, &info); 
     112 
     113        pj_snprintf(reg_status, sizeof(reg_status), 
     114                    "%s (%.*s;expires=%d)", 
     115                    pjsip_get_status_text(pjsua.regc_last_code)->ptr, 
     116                    (int)info.server_uri.slen, 
     117                    info.server_uri.ptr, 
     118                    info.next_reg); 
     119 
     120    } else { 
     121        pj_sprintf(reg_status, "in progress (%d)", pjsua.regc_last_code); 
     122    } 
     123 
     124    printf(">>>>\nRegistration status: %s\n", reg_status); 
     125    printf("Online status: %s\n",  
    103126           (pjsua.online_status ? "Online" : "Invisible")); 
    104127    print_buddy_list(); 
     
    109132    puts("|                              |                          |                   |"); 
    110133    puts("|  m  Make new call            |  i  Send IM              |  o  Send OPTIONS  |"); 
    111     puts("|  a  Answer call              |  s  Subscribe presence   |  d  Dump status  |"); 
    112     puts("|  h  Hangup call              |  u  Unsubscribe presence |  d1 Dump detailed |"); 
    113     puts("|  ]  Select next dialog       |  t  Toggle Online status |                   |"); 
     134    puts("|  a  Answer call              |  s  Subscribe presence   |  R  (Re-)register |"); 
     135    puts("|  h  Hangup call              |  u  Unsubscribe presence |  r  Unregister    |"); 
     136    puts("|  ]  Select next dialog       |  t  Toggle Online status |  d  Dump status   |"); 
    114137    puts("|  [  Select previous dialog   |                          |                   |"); 
    115138    puts("+-----------------------------------------------------------------------------+"); 
     
    224247 
    225248        if ((status=pjsua_verify_sip_url(buf)) != PJ_SUCCESS) { 
    226             pjsua_perror("Invalid URL", status); 
     249            pjsua_perror(THIS_FILE, "Invalid URL", status); 
    227250            return; 
    228251        } 
     
    291314 
    292315                if (status != PJ_SUCCESS) 
    293                     pjsua_perror("Unable to create/send response", status); 
     316                    pjsua_perror(THIS_FILE, "Unable to create/send response",  
     317                                 status); 
    294318            } 
    295319 
     
    311335                                               PJSIP_SC_DECLINE, NULL, &tdata); 
    312336                if (status != PJ_SUCCESS) { 
    313                     pjsua_perror("Failed to create end session message", status); 
     337                    pjsua_perror(THIS_FILE,  
     338                                 "Failed to create end session message",  
     339                                 status); 
    314340                    continue; 
    315341                } 
     
    317343                status = pjsip_inv_send_msg(inv_session->inv, tdata, NULL); 
    318344                if (status != PJ_SUCCESS) { 
    319                     pjsua_perror("Failed to send end session message", status); 
     345                    pjsua_perror(THIS_FILE,  
     346                                 "Failed to send end session message",  
     347                                 status); 
    320348                    continue; 
    321349                } 
     
    353381            } 
    354382 
     383            break; 
     384 
     385        case 'R': 
     386            pjsua_regc_update(PJ_TRUE); 
     387            break; 
     388             
     389        case 'r': 
     390            pjsua_regc_update(PJ_FALSE); 
    355391            break; 
    356392 
     
    501537 * Display error message for the specified error code. 
    502538 */ 
    503 void pjsua_perror(const char *title, pj_status_t status) 
     539void pjsua_perror(const char *sender, const char *title,  
     540                  pj_status_t status) 
    504541{ 
    505542    char errmsg[PJ_ERR_MSG_SIZE]; 
     
    507544    pj_strerror(status, errmsg, sizeof(errmsg)); 
    508545 
    509     PJ_LOG(1,(THIS_FILE, "%s: %s [code=%d]", title, errmsg, status)); 
     546    PJ_LOG(1,(sender, "%s: %s [code=%d]", title, errmsg, status)); 
    510547} 
    511548 
  • pjproject/trunk/pjsip/src/pjsua/pjsua.h

    r197 r201  
    128128    pj_int32_t       reg_timeout; 
    129129    pj_timer_entry   regc_timer; 
     130    pj_status_t      regc_last_err; /**< Last registration error.       */ 
    130131    int              regc_last_code;/**< Last status last register.     */ 
    131132 
     
    200201 * Display error message for the specified error code. 
    201202 */ 
    202 void pjsua_perror(const char *title, pj_status_t status); 
     203void pjsua_perror(const char *sender, const char *title,  
     204                  pj_status_t status); 
    203205 
    204206 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_core.c

    r197 r201  
    7373    pjsua.local_uri = pj_str(PJSUA_LOCAL_URI); 
    7474 
     75    /* Default registration timeout: */ 
     76 
     77    pjsua.reg_timeout = 55; 
     78 
    7579    /* Init route set list: */ 
    7680 
     
    156160    status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[SIP_SOCK]); 
    157161    if (status != PJ_SUCCESS) { 
    158         pjsua_perror("socket() error", status); 
     162        pjsua_perror(THIS_FILE, "socket() error", status); 
    159163        goto on_error; 
    160164    } 
     
    162166    status = pj_sock_bind_in(sock[SIP_SOCK], 0, pjsua.sip_port); 
    163167    if (status != PJ_SUCCESS) { 
    164         pjsua_perror("bind() error", status); 
     168        pjsua_perror(THIS_FILE, "bind() error", status); 
    165169        goto on_error; 
    166170    } 
     
    175179        status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[RTP_SOCK]); 
    176180        if (status != PJ_SUCCESS) { 
    177             pjsua_perror("socket() error", status); 
     181            pjsua_perror(THIS_FILE, "socket() error", status); 
    178182            goto on_error; 
    179183        } 
     
    189193        status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[RTCP_SOCK]); 
    190194        if (status != PJ_SUCCESS) { 
    191             pjsua_perror("socket() error", status); 
     195            pjsua_perror(THIS_FILE, "socket() error", status); 
    192196            goto on_error; 
    193197        } 
     
    218222            status = pj_sockaddr_in_set_str_addr( &addr, hostname); 
    219223            if (status != PJ_SUCCESS) { 
    220                 pjsua_perror("Unresolvable local hostname", status); 
     224                pjsua_perror(THIS_FILE, "Unresolvable local hostname",  
     225                             status); 
    221226                goto on_error; 
    222227            } 
     
    235240                                              mapped_addr); 
    236241            if (status != PJ_SUCCESS) { 
    237                 pjsua_perror("STUN error", status); 
     242                pjsua_perror(THIS_FILE, "STUN error", status); 
    238243                goto on_error; 
    239244            } 
     
    311316                                    &pjsua.endpt); 
    312317        if (status != PJ_SUCCESS) { 
    313             pjsua_perror("Unable to create SIP endpoint", status); 
     318            pjsua_perror(THIS_FILE, "Unable to create SIP endpoint", status); 
    314319            return status; 
    315320        } 
     
    321326    status = pjsip_tsx_layer_init(pjsua.endpt); 
    322327    if (status != PJ_SUCCESS) { 
    323         pjsua_perror("Transaction layer initialization error", status); 
     328        pjsua_perror(THIS_FILE, "Transaction layer initialization error",  
     329                     status); 
    324330        goto on_error; 
    325331    } 
     
    329335    status = pjsip_ua_init( pjsua.endpt, NULL ); 
    330336    if (status != PJ_SUCCESS) { 
    331         pjsua_perror("UA layer initialization error", status); 
     337        pjsua_perror(THIS_FILE, "UA layer initialization error", status); 
    332338        goto on_error; 
    333339    } 
     
    358364        status = pjsip_endpt_register_module(pjsua.endpt, &pjsua.mod); 
    359365        if (status != PJ_SUCCESS) { 
    360             pjsua_perror("Unable to register pjsua module", status); 
     366            pjsua_perror(THIS_FILE, "Unable to register pjsua module",  
     367                         status); 
    361368            goto on_error; 
    362369        } 
     
    378385        status = pjsip_inv_usage_init(pjsua.endpt, &pjsua.mod, &inv_cb); 
    379386        if (status != PJ_SUCCESS) { 
    380             pjsua_perror("Invite usage initialization error", status); 
     387            pjsua_perror(THIS_FILE, "Invite usage initialization error",  
     388                         status); 
    381389            goto on_error; 
    382390        } 
     
    428436    status = pj_init(); 
    429437    if (status != PJ_SUCCESS) { 
    430         pjsua_perror("pj_init() error", status); 
     438        pjsua_perror(THIS_FILE, "pj_init() error", status); 
    431439        return status; 
    432440    } 
     
    446454    if (status != PJ_SUCCESS) { 
    447455        pj_caching_pool_destroy(&pjsua.cp); 
    448         pjsua_perror("Stack initialization has returned error", status); 
     456        pjsua_perror(THIS_FILE, "Stack initialization has returned error",  
     457                     status); 
    449458        return status; 
    450459    } 
     
    470479    if (status != PJ_SUCCESS) { 
    471480        pj_caching_pool_destroy(&pjsua.cp); 
    472         pjsua_perror("Media stack initialization has returned error", status); 
     481        pjsua_perror(THIS_FILE,  
     482                     "Media stack initialization has returned error",  
     483                     status); 
    473484        return status; 
    474485    } 
     
    479490    if (status != PJ_SUCCESS) { 
    480491        pj_caching_pool_destroy(&pjsua.cp); 
    481         pjsua_perror("Media codec initialization has returned error", status); 
     492        pjsua_perror(THIS_FILE,  
     493                     "Media codec initialization has returned error",  
     494                     status); 
    482495        return status; 
    483496    } 
     
    504517    status = init_sockets(); 
    505518    if (status != PJ_SUCCESS) { 
    506         pjsua_perror("init_sockets() has returned error", status); 
     519        pjsua_perror(THIS_FILE, "init_sockets() has returned error",  
     520                     status); 
    507521        return status; 
    508522    } 
     
    528542                                             &udp_transport); 
    529543        if (status != PJ_SUCCESS) { 
    530             pjsua_perror("Unable to start UDP transport", status); 
     544            pjsua_perror(THIS_FILE, "Unable to start UDP transport",  
     545                         status); 
    531546            return status; 
    532547        } 
     
    553568                              pjsua.local_uri.slen, 0); 
    554569        if (uri == NULL) { 
    555             pjsua_perror("Invalid local URI", PJSIP_EINVALIDURI); 
     570            pjsua_perror(THIS_FILE, "Invalid local URI",  
     571                         PJSIP_EINVALIDURI); 
    556572            return PJSIP_EINVALIDURI; 
    557573        } 
     
    561577 
    562578        if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) { 
    563             pjsua_perror("Invalid local URI", PJSIP_EINVALIDSCHEME); 
     579            pjsua_perror(THIS_FILE, "Invalid local URI",  
     580                         PJSIP_EINVALIDSCHEME); 
    564581            return PJSIP_EINVALIDSCHEME; 
    565582        } 
     
    595612 
    596613        if (len < 1 || len >= sizeof(contact)) { 
    597             pjsua_perror("Invalid Contact", PJSIP_EURITOOLONG); 
     614            pjsua_perror(THIS_FILE, "Invalid Contact", PJSIP_EURITOOLONG); 
    598615            return PJSIP_EURITOOLONG; 
    599616        } 
     
    618635                                   &parsed_len); 
    619636        if (route == NULL) { 
    620             pjsua_perror("Invalid outbound proxy URL", PJSIP_EINVALIDURI); 
     637            pjsua_perror(THIS_FILE, "Invalid outbound proxy URL",  
     638                         PJSIP_EINVALIDURI); 
    621639            return PJSIP_EINVALIDURI; 
    622640        } 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_inv.c

    r197 r201  
    5454                                   &dlg); 
    5555    if (status != PJ_SUCCESS) { 
    56         pjsua_perror("Dialog creation failed", status); 
     56        pjsua_perror(THIS_FILE, "Dialog creation failed", status); 
    5757        return status; 
    5858    } 
     
    6363                                       1, &pjsua.med_skinfo, &offer); 
    6464    if (status != PJ_SUCCESS) { 
    65         pjsua_perror("pjmedia unable to create SDP", status); 
     65        pjsua_perror(THIS_FILE, "pjmedia unable to create SDP", status); 
    6666        goto on_error; 
    6767    } 
     
    7171    status = pjsip_inv_create_uac( dlg, offer, 0, &inv); 
    7272    if (status != PJ_SUCCESS) { 
    73         pjsua_perror("Invite session creation failed", status); 
     73        pjsua_perror(THIS_FILE, "Invite session creation failed", status); 
    7474        goto on_error; 
    7575    } 
     
    100100    status = pjsip_inv_invite(inv, &tdata); 
    101101    if (status != PJ_SUCCESS) { 
    102         pjsua_perror("Unable to create initial INVITE request", status); 
     102        pjsua_perror(THIS_FILE, "Unable to create initial INVITE request",  
     103                     status); 
    103104        goto on_error; 
    104105    } 
     
    109110    status = pjsip_inv_send_msg(inv, tdata, NULL); 
    110111    if (status != PJ_SUCCESS) { 
    111         pjsua_perror("Unable to send initial INVITE request", status); 
     112        pjsua_perror(THIS_FILE, "Unable to send initial INVITE request",  
     113                     status); 
    112114        goto on_error; 
    113115    } 
     
    302304    if (status != PJ_SUCCESS) { 
    303305 
    304         pjsua_perror("SDP negotiation has failed", status); 
     306        pjsua_perror(THIS_FILE, "SDP negotiation has failed", status); 
    305307        return; 
    306308 
     
    319321    status = pjmedia_sdp_neg_get_active_local(inv->neg, &local_sdp); 
    320322    if (status != PJ_SUCCESS) { 
    321         pjsua_perror("Unable to retrieve currently active local SDP", status); 
     323        pjsua_perror(THIS_FILE,  
     324                     "Unable to retrieve currently active local SDP",  
     325                     status); 
    322326        return; 
    323327    } 
     
    326330    status = pjmedia_sdp_neg_get_active_remote(inv->neg, &remote_sdp); 
    327331    if (status != PJ_SUCCESS) { 
    328         pjsua_perror("Unable to retrieve currently active remote SDP", status); 
     332        pjsua_perror(THIS_FILE,  
     333                     "Unable to retrieve currently active remote SDP",  
     334                     status); 
    329335        return; 
    330336    } 
     
    341347                                         &inv_data->session ); 
    342348        if (status != PJ_SUCCESS) { 
    343             pjsua_perror("Unable to create media session", status); 
     349            pjsua_perror(THIS_FILE, "Unable to create media session",  
     350                         status); 
    344351            return; 
    345352        } 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_pres.c

    r197 r201  
    9999                                   &pjsua.contact_uri, &dlg); 
    100100    if (status != PJ_SUCCESS) { 
    101         pjsua_perror("Unable to create UAS dialog for subscription", status); 
     101        pjsua_perror(THIS_FILE,  
     102                     "Unable to create UAS dialog for subscription",  
     103                     status); 
    102104        return PJ_FALSE; 
    103105    } 
     
    111113    if (status != PJ_SUCCESS) { 
    112114        PJ_TODO(DESTROY_DIALOG); 
    113         pjsua_perror("Unable to create server subscription", status); 
     115        pjsua_perror(THIS_FILE, "Unable to create server subscription",  
     116                     status); 
    114117        return PJ_FALSE; 
    115118    } 
     
    135138    status = pjsip_pres_accept(sub, rdata, 200, NULL); 
    136139    if (status != PJ_SUCCESS) { 
    137         pjsua_perror("Unable to accept presence subscription", status); 
     140        pjsua_perror(THIS_FILE, "Unable to accept presence subscription",  
     141                     status); 
    138142        pj_list_erase(uapres); 
    139143        return PJ_FALSE; 
     
    158162 
    159163    if (status != PJ_SUCCESS) { 
    160         pjsua_perror("Unable to create/send NOTIFY", status); 
     164        pjsua_perror(THIS_FILE, "Unable to create/send NOTIFY",  
     165                     status); 
    161166        pj_list_erase(uapres); 
    162167        return PJ_FALSE; 
     
    305310                                   NULL, &dlg); 
    306311    if (status != PJ_SUCCESS) { 
    307         pjsua_perror("Unable to create dialog", status); 
     312        pjsua_perror(THIS_FILE, "Unable to create dialog",  
     313                     status); 
    308314        return; 
    309315    } 
     
    313319    if (status != PJ_SUCCESS) { 
    314320        pjsua.buddies[index].sub = NULL; 
    315         pjsua_perror("Unable to create presence client", status); 
     321        pjsua_perror(THIS_FILE, "Unable to create presence client",  
     322                     status); 
    316323        return; 
    317324    } 
     
    323330    if (status != PJ_SUCCESS) { 
    324331        pjsua.buddies[index].sub = NULL; 
    325         pjsua_perror("Unable to create initial SUBSCRIBE", status); 
     332        pjsua_perror(THIS_FILE, "Unable to create initial SUBSCRIBE",  
     333                     status); 
    326334        return; 
    327335    } 
     
    330338    if (status != PJ_SUCCESS) { 
    331339        pjsua.buddies[index].sub = NULL; 
    332         pjsua_perror("Unable to send initial SUBSCRIBE", status); 
     340        pjsua_perror(THIS_FILE, "Unable to send initial SUBSCRIBE",  
     341                     status); 
    333342        return; 
    334343    } 
     
    365374 
    366375    } else { 
    367         pjsua_perror("Unable to unsubscribe presence", status); 
     376        pjsua_perror(THIS_FILE, "Unable to unsubscribe presence",  
     377                     status); 
    368378    } 
    369379} 
     
    397407    status = pjsip_endpt_register_module( pjsua.endpt, &mod_pjsua_pres); 
    398408    if (status != PJ_SUCCESS) { 
    399         pjsua_perror("Unable to register pjsua presence module", status); 
     409        pjsua_perror(THIS_FILE, "Unable to register pjsua presence module",  
     410                     status); 
    400411    } 
    401412 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_reg.c

    r184 r201  
    3838     * Print registration status. 
    3939     */ 
    40     if (param->code < 0 || param->code >= 300) { 
     40    if (param->status!=PJ_SUCCESS) { 
     41        pjsua_perror(THIS_FILE, "SIP registration error",  
     42                     param->status); 
     43        pjsua.regc = NULL; 
     44         
     45    } else if (param->code < 0 || param->code >= 300) { 
    4146        PJ_LOG(2, (THIS_FILE, "SIP registration failed, status=%d (%s)",  
    42                    param->code, pjsip_get_status_text(param->code)->ptr)); 
     47                   param->code,  
     48                   pjsip_get_status_text(param->code)->ptr)); 
    4349        pjsua.regc = NULL; 
    4450 
     
    5460    } 
    5561 
     62    pjsua.regc_last_err = param->status; 
    5663    pjsua.regc_last_code = param->code; 
    5764 
     
    6976 
    7077    if (renew) { 
    71         PJ_LOG(3,(THIS_FILE, "Performing SIP registration...")); 
     78        if (pjsua.regc == NULL) { 
     79            status = pjsua_regc_init(); 
     80            if (status != PJ_SUCCESS) { 
     81                pjsua_perror(THIS_FILE, "Unable to create registration",  
     82                             status); 
     83                return; 
     84            } 
     85        } 
    7286        status = pjsip_regc_register(pjsua.regc, 1, &tdata); 
    7387    } else { 
    74         PJ_LOG(3,(THIS_FILE, "Performing SIP unregistration...")); 
     88        if (pjsua.regc == NULL) { 
     89            PJ_LOG(3,(THIS_FILE, "Currently not registered")); 
     90            return; 
     91        } 
    7592        status = pjsip_regc_unregister(pjsua.regc, &tdata); 
    7693    } 
    7794 
     95    if (status == PJ_SUCCESS) 
     96        status = pjsip_regc_send( pjsua.regc, tdata ); 
     97 
    7898    if (status != PJ_SUCCESS) { 
    79         pjsua_perror("Unable to create REGISTER request", status); 
    80         return; 
     99        pjsua_perror(THIS_FILE, "Unable to create/send REGISTER",  
     100                     status); 
     101    } else { 
     102        PJ_LOG(3,(THIS_FILE, "%s sent", 
     103                 (renew? "Registration" : "Unregistration"))); 
    81104    } 
    82  
    83     pjsip_regc_send( pjsua.regc, tdata ); 
    84105} 
    85106 
     
    97118 
    98119        if (status != PJ_SUCCESS) { 
    99             pjsua_perror("Unable to create client registration", status); 
     120            pjsua_perror(THIS_FILE, "Unable to create client registration",  
     121                         status); 
    100122            return status; 
    101123        } 
     
    108130                                  pjsua.reg_timeout); 
    109131        if (status != PJ_SUCCESS) { 
    110             pjsua_perror("Client registration initialization error", status); 
     132            pjsua_perror(THIS_FILE,  
     133                         "Client registration initialization error",  
     134                         status); 
    111135            return status; 
    112136        } 
Note: See TracChangeset for help on using the changeset viewer.