alfred1711287 / siphon

Automatically exported from code.google.com/p/siphon
0 stars 0 forks source link

How to get Missed call type? #595

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I'm getting dialed and received call history, but i need missed calls as 
separate. In Siphon missed call also coming as received call. I discovered the 
missed type with giving below condition which was written in call.m on 
on_call_state method if conditions, but not able to add this type to the 
recents call record.

Here is the code for on_call_state Method:

/* Callback called by the library when call's state has changed */
static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
{
  pjsua_call_info ci;
//  NSNumber *value;

  //PJ_UNUSED_ARG(e);

  pjsua_call_get_info(call_id, &ci);

  PJ_LOG(1,(THIS_FILE, "Call %d state=%.*s", call_id,
    (int)ci.state_text.slen, ci.state_text.ptr));

  if (ci.state == PJSIP_INV_STATE_DISCONNECTED) // Session is terminated.
  {
    ///* FIXME: Stop all ringback for this call */
    sip_ring_stop([appDelegate pjsipConfig]);
    sip_call_deinit_tonegen(call_id);
    if (ci.last_status == PJSIP_SC_DECLINE || ci.last_status == PJSIP_SC_REQUEST_TERMINATED)
    {
        //ci.connect_duration <= 0
        NSLog(@"missed");

    }

  } 
  else if (ci.state == PJSIP_INV_STATE_EARLY) 
  {
    int code;
    pj_str_t reason;
    pjsip_msg *msg;

    /* This can only occur because of TX or RX message */
    pj_assert(e->type == PJSIP_EVENT_TSX_STATE);

    msg = (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG ?
           e->body.tsx_state.src.rdata->msg_info.msg :
           e->body.tsx_state.src.tdata->msg);

    code = msg->line.status.code;
    reason = msg->line.status.reason;

    /* Start ringback for 180 for UAC unless there's SDP in 180 */
    if (ci.role == PJSIP_ROLE_UAC && code == 180 && msg->body == NULL && ci.media_status == PJSUA_CALL_MEDIA_NONE) 
    {
      // FIXME: start ringback
      sip_ringback_start([appDelegate pjsipConfig]);
    }
  }

  if (ci.state != PJSIP_INV_STATE_NULL)
  {
    postCallStateNotification(call_id, &ci);
  }
}

And where should i get the number as missed type in callviewcontroller. I tried 
like below but it not working

- (RecentCall *)createCall:(NSDictionary *)userInfo
{
  RecentCall *call = nil;
  pjsip_name_addr *url;
  pjsip_sip_uri *sip_uri;
  pj_str_t tmp, dst;
  pj_pool_t     *pool;

  int role;
  int missed;
  NSString *remote_info;

  pool = pjsua_pool_create("recentCall", 128, 128);
  if (pool)
  {
    call = [[RecentCall alloc] init];
    role = [[ userInfo objectForKey: @"Role"] intValue];
    call.type = (missed == PJSIP_ROLE_UAS ? Received : Missed);
    call.type = (role == PJSIP_ROLE_UAC ? Dialled : Received);
//    call.type = (missed == PJSIP_ROLE_UAC ? Received : Missed);
    remote_info = [userInfo objectForKey:@"RemoteInfo"];
    pj_strdup2_with_null(pool, &tmp, [remote_info UTF8String]);

    url = (pjsip_name_addr*)pjsip_parse_uri(pool, tmp.ptr, tmp.slen,
                                            PJSIP_PARSE_URI_AS_NAMEADDR);
}
}

What is the expected output? What do you see instead?
I need the missed call type 

What version of the product are you using? On what operating system?
Siphon on iOS

Please provide any additional information below.

Original issue reported on code.google.com by venk...@cemsportal.com on 11 Mar 2015 at 11:02

Attachments: