コード例 #1
0
void tertiary_text_chosen(char *text) {
  if (s_state == BEGINNING_STATE) {
    snprintf(dictated_name, sizeof(dictated_name), "%s", text);

    snprintf(instruction_text, sizeof(instruction_text), "%s", "Loading Contact...");
    snprintf(primary_text, sizeof(primary_text), "%s", dictated_name);
    text_layer_set_text(s_instruction_layer, instruction_text);
    text_layer_set_text(s_primary_layer, primary_text);

    change_state(CHECKING_CONTACT_STATE);

    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_SELECT, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, NULL);

    get_contact();
  }

  if (s_state == CREATING_FINAL_MESSAGE_STATE) {
    change_state(CONFIRMING_FINAL_MESSAGE_STATE);
    snprintf(dictated_message, sizeof(dictated_message), "%s", text);

    snprintf(instruction_text, sizeof(instruction_text), "%s", contact_name);
    snprintf(primary_text, sizeof(primary_text), "%s", dictated_message);
    text_layer_set_text(s_instruction_layer, instruction_text);
    text_layer_set_text(s_primary_layer, primary_text);
  }
}
コード例 #2
0
ファイル: select_core.c プロジェクト: adubovikov/kamailio
int select_contact_params_spec(str* res, select_t* s, struct sip_msg* msg)
{
	contact_t* c;
	
	if (s->params[s->n-1].type != SEL_PARAM_DIV) {
		BUG("Last parameter should have type DIV (converted)\n");
		return -1;
	}
	
	if (parse_contact_header(msg)<0)
		return -1;
	
	c = get_contact(msg)->contacts;
	if (!c)
		return 1;
	
	switch (s->params[s->n-1].v.i) {
	case SEL_PARAM_Q:
		TEST_RET_res_body(c->q);
	case SEL_PARAM_EXPIRES:
		TEST_RET_res_body(c->expires);
	case SEL_PARAM_METHODS:
		TEST_RET_res_body(c->methods);
	case SEL_PARAM_RECEIVED:
		TEST_RET_res_body(c->received);
	case SEL_PARAM_INSTANCE:
		TEST_RET_res_body(c->instance);
	default:
		BUG("Unexpected parameter value \"%d\"\n", s->params[s->n-1].v.i);
		return -1;
	}
	return -1;
}
コード例 #3
0
ファイル: QuoteInfoDlg.cpp プロジェクト: Seldom/miranda-ng
static INT_PTR CALLBACK QuoteInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	MCONTACT hContact = NULL;
	MWindowList hWL;

	switch (msg) {
	case WM_INITDIALOG:
		hContact = MCONTACT(lParam);
		hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false);
		assert(hWL);
		WindowList_Add(hWL, hdlg, hContact);

		::SetWindowLongPtr(hdlg, GWLP_USERDATA, hContact);
		Utils_RestoreWindowPositionNoSize(hdlg, hContact, QUOTES_MODULE_NAME, WINDOW_PREFIX_INFO);
		::ShowWindow(hdlg, SW_SHOW);
		break;

	case WM_CLOSE:
		DestroyWindow(hdlg);
		return FALSE;

	case WM_DESTROY:
		hContact = get_contact(hdlg);
		if (hContact) {
			SetWindowLongPtr(hdlg, GWLP_USERDATA, 0);

			hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false);
			assert(hWL);
			WindowList_Remove(hWL, hdlg);
			Utils_SaveWindowPosition(hdlg, hContact, QUOTES_MODULE_NAME, WINDOW_PREFIX_INFO);
		}
		return FALSE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK) {
			::DestroyWindow(hdlg);
			return FALSE;
		}

	default:
		hContact = get_contact(hdlg);
		break;
	}

	return QuoteInfoDlgProcImpl(hContact, hdlg, msg, wParam, lParam);
}
コード例 #4
0
ファイル: select_core.c プロジェクト: adubovikov/kamailio
int select_contact_name(str* res, select_t* s, struct sip_msg* msg)
{
	contact_t* c;
	if (parse_contact_header(msg)<0)
		return -1;
	
	c = get_contact(msg)->contacts;
	if (!c)
		return 1;
	RETURN0_res(c->name);
}
コード例 #5
0
/**
 * Creates conference.
 */
void
sipe_conf_add(struct sipe_core_private *sipe_private,
	      const gchar* who)
{
	gchar *hdr;
	gchar *conference_id;
	gchar *contact;
	gchar *body;
	gchar *self;
	struct transaction *trans;
	struct sip_dialog *dialog = NULL;
	time_t expiry = time(NULL) + 7*60*60; /* 7 hours */
	char *expiry_time;
	struct transaction_payload *payload;

	contact = get_contact(sipe_private);
	hdr = g_strdup_printf(
		"Supported: ms-sender\r\n"
		"Contact: %s\r\n"
		"Content-Type: application/cccp+xml\r\n",
		contact);
	g_free(contact);

	expiry_time = sipe_utils_time_to_str(expiry);
	self = sip_uri_self(sipe_private);
	conference_id = genconfid();
	body = g_strdup_printf(
		SIPE_SEND_CONF_ADD,
		sipe_private->focus_factory_uri,
		self,
		rand(),
		conference_id,
		expiry_time);
	g_free(self);
	g_free(conference_id);
	g_free(expiry_time);

	trans = sip_transport_service(sipe_private,
				      sipe_private->focus_factory_uri,
				      hdr,
				      body,
				      process_conf_add_response);

	payload = g_new0(struct transaction_payload, 1);
	payload->destroy = g_free;
	payload->data = g_strdup(who);
	trans->payload = payload;

	sipe_dialog_free(dialog);
	g_free(body);
	g_free(hdr);
}
コード例 #6
0
/**
 * Invites counterparty to join conference.
 */
void
sipe_invite_conf(struct sipe_core_private *sipe_private,
		 struct sip_session *session,
		 const gchar* who)
{
	gchar *hdr;
	gchar *contact;
	gchar *body;
	struct sip_dialog *dialog = NULL;

	/* It will be short lived special dialog.
	 * Will not be stored in session.
	 */
	dialog = g_new0(struct sip_dialog, 1);
	dialog->callid = gencallid();
	dialog->with = g_strdup(who);
	dialog->ourtag = gentag();

	contact = get_contact(sipe_private);
	hdr = g_strdup_printf(
		"Supported: ms-sender\r\n"
		"Contact: %s\r\n"
		"Content-Type: application/ms-conf-invite+xml\r\n",
		contact);
	g_free(contact);

	body = g_strdup_printf(
		SIPE_SEND_CONF_INVITE,
		session->chat_session->id,
		session->subject ? session->subject : ""
		);

	sip_transport_invite(sipe_private,
			     hdr,
			     body,
			     dialog,
			     process_invite_conf_response);

	sipe_dialog_free(dialog);
	g_free(body);
	g_free(hdr);
}
コード例 #7
0
ファイル: select_core.c プロジェクト: adubovikov/kamailio
int select_contact_params(str* res, select_t* s, struct sip_msg* msg)
{
	contact_t* c;
	param_t* p;
	if (parse_contact_header(msg)<0)
		return -1;
	
	c = get_contact(msg)->contacts;
	if (!c)
		return 1;
	p = c->params;
	while (p) {
		if ((p->name.len==s->params[s->n-1].v.s.len)
		    && !strncasecmp(p->name.s, s->params[s->n-1].v.s.s,p->name.len)) {
			RETURN0_res(p->body)
		}
		p = p->next;
	}
	return 1;
}
コード例 #8
0
static void dictation_session_callback(DictationSession *session, DictationSessionStatus status, 
                                       char *transcription, void *context) {
  // Print the results of a transcription attempt                                     
  // APP_LOG(APP_LOG_LEVEL_INFO, "Dictation status: %d", (int)status);

  if(status == DictationSessionStatusSuccess) {
    // just dictated name
    if (s_state == BEGINNING_STATE) {
      snprintf(dictated_name, sizeof(dictated_name), "%s", transcription);

      snprintf(instruction_text, sizeof(instruction_text), "%s", "Loading Contact...");
      snprintf(primary_text, sizeof(primary_text), "%s", dictated_name);
      text_layer_set_text(s_instruction_layer, instruction_text);
      text_layer_set_text(s_primary_layer, primary_text);

      change_state(CHECKING_CONTACT_STATE);

      action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, NULL);
      action_bar_layer_set_icon(s_actionbar, BUTTON_ID_SELECT, NULL);
      action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, NULL);

      get_contact();
    }

    // just dictated message
    if (s_state == CREATING_FINAL_MESSAGE_STATE) {
      change_state(CONFIRMING_FINAL_MESSAGE_STATE);
      snprintf(dictated_message, sizeof(dictated_message), "%s", transcription);

      snprintf(instruction_text, sizeof(instruction_text), "%s", contact_name);
      snprintf(primary_text, sizeof(primary_text), "%s", dictated_message);
      text_layer_set_text(s_instruction_layer, instruction_text);
      text_layer_set_text(s_primary_layer, primary_text);
    }
  }
}
コード例 #9
0
/** Create new session with Focus URI */
struct sip_session *
sipe_conf_create(struct sipe_core_private *sipe_private,
		 struct sipe_chat_session *chat_session,
		 const gchar *focus_uri)
{
	gchar *hdr;
	gchar *contact;
	gchar *body;
	gchar *self;
	struct sip_session *session = sipe_session_add_chat(sipe_private,
							    chat_session,
							    FALSE,
							    focus_uri);

	session->focus_dialog = g_new0(struct sip_dialog, 1);
	session->focus_dialog->callid = gencallid();
	session->focus_dialog->with = g_strdup(session->chat_session->id);
	session->focus_dialog->endpoint_GUID = rand_guid();
	session->focus_dialog->ourtag = gentag();

	contact = get_contact(sipe_private);
	hdr = g_strdup_printf(
		"Supported: ms-sender\r\n"
		"Contact: %s\r\n"
		"Content-Type: application/cccp+xml\r\n",
		contact);
	g_free(contact);

	/* @TODO put request_id to queue to further compare with incoming one */
	/* focus_URI, from, request_id, focus_URI, from, endpoint_GUID */
	self = sip_uri_self(sipe_private);
	body = g_strdup_printf(
		SIPE_SEND_CONF_ADD_USER,
		session->focus_dialog->with,
		self,
		session->request_id++,
		session->focus_dialog->with,
		self,
		session->focus_dialog->endpoint_GUID);

	session->focus_dialog->outgoing_invite =
		sip_transport_invite(sipe_private,
				     hdr,
				     body,
				     session->focus_dialog,
				     process_invite_conf_focus_response);
	g_free(body);
	g_free(hdr);

	/* Rejoin existing session? */
	if (chat_session) {
		SIPE_DEBUG_INFO("sipe_conf_create: rejoin '%s' (%s)",
				chat_session->title,
				chat_session->id);
		sipe_backend_chat_rejoin(SIPE_CORE_PUBLIC,
					 chat_session->backend,
					 self,
					 chat_session->title);
	}
	g_free(self);

	return(session);
}
コード例 #10
0
void trans_layer::send_200_ack(sip_msg* reply, sip_trans* t)
{
    // Set request URI
    // TODO: use correct R-URI instead of just 'Contact'
    if(!get_contact(reply)) {
	DBG("Sorry, reply has no Contact header: could not send ACK\n");
	return;
    }
    
    sip_nameaddr na;
    const char* c = get_contact(reply)->value.s;
    if(parse_nameaddr(&na,&c,get_contact(reply)->value.len) < 0){
	DBG("Sorry, reply's Contact parsing failed: could not send ACK\n");
	return;
    }
    
    cstring r_uri = na.addr;
    list<sip_header*> route_hdrs;

    if(t && !t->msg->route.empty()){
	for(list<sip_header*>::iterator it = t->msg->route.begin();
	    it != t->msg->route.end(); ++it) {
	    
	    route_hdrs.push_back(new sip_header(0,"Route",(*it)->value));
	}
    }
    else {
	for(list<sip_header*>::reverse_iterator it = reply->record_route.rbegin();
	    it != reply->record_route.rend(); ++it) {
	    
	    route_hdrs.push_back(new sip_header(0,"Route",(*it)->value));
	}
    }

    sockaddr_storage remote_ip;
    set_next_hop(route_hdrs,r_uri,&remote_ip);

    int request_len = request_line_len(cstring("ACK",3),r_uri);
   
    char branch_buf[BRANCH_BUF_LEN];
    compute_branch(branch_buf,reply->callid->value,reply->cseq->value);
    cstring branch(branch_buf,BRANCH_BUF_LEN);

    sip_header* max_forward = new sip_header(0,cstring("Max-Forwards"),cstring("10"));

    cstring via((char*)transport->get_local_ip()); 

    request_len += via_len(via,branch);

    request_len += copy_hdrs_len(route_hdrs);

    request_len += copy_hdr_len(reply->to);
    request_len += copy_hdr_len(reply->from);
    request_len += copy_hdr_len(reply->callid);
    request_len += copy_hdr_len(max_forward);
    request_len += cseq_len(get_cseq(reply)->num_str,cstring("ACK",3));
    request_len += 2/* CRLF end-of-headers*/;

    // Allocate new message
    char* ack_buf = new char[request_len];

    // generate it
    char* msg = ack_buf;

    request_line_wr(&msg,cstring("ACK",3),r_uri);
    via_wr(&msg,via,branch);

    copy_hdrs_wr(&msg,route_hdrs);
    // clear route headers list
    for (list<sip_header*>::iterator it=route_hdrs.begin(); 
	 it!= route_hdrs.end(); it++)
	delete *it;
    
    copy_hdr_wr(&msg,reply->from);
    copy_hdr_wr(&msg,reply->to);
    copy_hdr_wr(&msg,reply->callid);
    copy_hdr_wr(&msg,max_forward);
    delete max_forward;
    cseq_wr(&msg,get_cseq(reply)->num_str,cstring("ACK",3));

    *msg++ = CR;
    *msg++ = LF;

    DBG("About to send 200 ACK\n");
    //    DBG("About to send 200 ACK: \n<%.*s>\n",request_len,ack_buf);

    assert(transport);
    int send_err = transport->send(&remote_ip,ack_buf,request_len);
    if(send_err < 0){
	ERROR("Error from transport layer\n");
	delete [] ack_buf;
    }
    else if(t){
	delete [] t->retr_buf;
	t->retr_buf = ack_buf;
	t->retr_len = request_len;
	memcpy(&t->retr_addr,&remote_ip,sizeof(sockaddr_storage));
    }
}