Пример #1
0
/*
 * Ask user for a window definition.
 */
static bool
getwindow(WINDOW *parent, PAIR * ul, PAIR * lr)
{
    int min_col = (parent == stdscr) ? COL_MIN : 0;
    int max_col = (parent == stdscr) ? COL_MAX : getmaxx(parent);
    int min_line = (parent == stdscr) ? LINE_MIN : 0;
    int max_line = (parent == stdscr) ? LINE_MAX : getmaxy(parent);
    PAIR *tmp;
    bool result = FALSE;

    head_line("Use arrows to move cursor, anything else to mark corner 1");
    if ((tmp = selectcell(parent, min_line, min_col, max_line, max_col)) != 0) {
	*ul = *tmp;
	mvwaddch(parent, ul->y, ul->x, '*');

	head_line("Use arrows to move cursor, anything else to mark corner 2");
	if ((tmp = selectcell(parent, ul->y, ul->x, max_line, max_col)) != 0) {
	    *lr = *tmp;
	    mvwaddch(parent, lr->y, lr->x, '*');
	    wmove(parent, lr->y, lr->x);
	    wsyncdown(parent);
	    wrefresh(parent);
	    result = (lr->y != ul->y && lr->x != ul->x);
	}
    }
    head_line("done");
    return result;
}
Пример #2
0
/*
 * test mvwin().
 */
static bool
move_window(WINDOW *win, bool recur)
{
    WINDOW *parent = parent_of(win);
    bool result = FALSE;

    if (parent != 0) {
	bool top = (parent == stdscr);
	int min_col = top ? COL_MIN : 0;
	int max_col = top ? COL_MAX : getmaxx(parent);
	int min_line = top ? LINE_MIN : 0;
	int max_line = top ? LINE_MAX : getmaxy(parent);
	PAIR *tmp;
	bool more;

	head_line("Select new position for %swindow", top ? "" : "sub");

	while ((tmp = selectcell(parent,
				 win,
				 min_line, min_col,
				 max_line, max_col,
				 FALSE,
				 &more)) != 0) {
	    int y0, x0;
	    getbegyx(parent, y0, x0);
	    /*
	     * Moving a subwindow has the effect of moving a viewport around
	     * the screen.  The parent window retains the contents of the
	     * subwindow in the original location, but the viewport will show
	     * the contents (again) at the new location.  So it will look odd
	     * when testing.
	     */
	    if (mvwin(win, y0 + tmp->y, x0 + tmp->x) != ERR) {
		if (recur) {
		    recur_move_window(win, tmp->y, tmp->x);
		}
		refresh_all(win);
		doupdate();
		result = TRUE;
	    } else {
		result = FALSE;
	    }
	    if (!more)
		break;
	}
    }
    head_line("done");
    return result;
}
Пример #3
0
/*
 * test mvderwin().
 */
static bool
move_subwin(WINDOW *win)
{
    WINDOW *parent = parent_of(win);
    bool result = FALSE;

    if (parent != 0) {
	bool top = (parent == stdscr);
	if (!top) {
	    int min_col = top ? COL_MIN : 0;
	    int max_col = top ? COL_MAX : getmaxx(parent);
	    int min_line = top ? LINE_MIN : 0;
	    int max_line = top ? LINE_MAX : getmaxy(parent);
	    PAIR *tmp;

	    head_line("Select new position for subwindow");

	    if ((tmp = selectcell(parent,
				  min_line, min_col,
				  max_line, max_col)) != 0) {
		int y0, x0;
		getbegyx(parent, y0, x0);
		if (mvderwin(win, y0 + tmp->y, x0 + tmp->x) != ERR) {
		    refresh_all(win);
		    doupdate();
		    result = TRUE;
		}
	    }
	}
    }
    return result;
}
Пример #4
0
        void SIPBuilder::CameraInfoAck(osip_message_t* msg,
                char** rtmsg, size_t* rtlen)
        {
            string head_line("SIP/2.0 200 OK\r\n");

            osip_via_t *via;
            char* via_c = NULL; 
            if( !osip_list_eol (&msg->vias, 0))
            {
                via = (osip_via_t *) osip_list_get (&msg->vias, 0);
                osip_via_to_str( via, &via_c);
            }else{
                return;
            }
            string via_header(via_c);
            via_header = string("Via: ")+via_header+string("\r\n");
            
            char* from_tag_c;
            osip_from_to_str( msg->from, &from_tag_c );
            string from_header(from_tag_c);
            from_header = string("From: ")+from_header+string("\r\n");

            char* to_tag_c;
            osip_to_to_str( msg->to, &to_tag_c );
            string to_header(to_tag_c);
            string to_tag_num = _RandomNum();
            to_header = to_header + ";tag="+to_tag_num;
            to_header = string("To: ")+to_header+string("\r\n");


            string call_id_num = string(msg->call_id->number);
            string call_header = string("Call-ID: ")+call_id_num+("\r\n");

            string cseq_num = string(msg->cseq->number);
            string cseq_header = string("Cseq: ")+cseq_num+string(" MESSAGE\r\n");
            string content_type_header = "Content-Type: APPLICATION/SDP\r\n";

            string forwords = string("Max-Forwards: 70\r\n");
            string expires = string("Expires: 3000\r\n");
            string contentlenth = string("Content-Length: 0")+string("\r\n");
            string cflr = string("\r\n");

            string sip_msg_str = head_line + via_header + to_header + from_header
                + call_header + cseq_header  + content_type_header + 
                forwords + expires + contentlenth + cflr;
            
#ifdef DEBUG
            cout<<"check 200ok camerainfoack:"<<endl;
            cout<<sip_msg_str<<endl;
#endif
            size_t sip_len = sip_msg_str.length();
            char* sip_msg_c = (char*)malloc(sizeof(char)* sip_len);
            memcpy( sip_msg_c, sip_msg_str.c_str(), sip_len);
            *rtmsg = sip_msg_c;
            *rtlen = sip_len;
            /*send 200ok, wait ack*/
            return;
        }
Пример #5
0
static void
show_derwin(WINDOW *win)
{
    int pary, parx, maxy, maxx;

    getmaxyx(win, maxy, maxx);
    getparyx(win, pary, parx);

    head_line("Select new position for derived window at %d,%d (%d,%d)",
	      pary, parx, maxy, maxx);
}
Пример #6
0
/*
 * test mvderwin().
 */
static bool
move_derwin(WINDOW *win)
{
    WINDOW *parent = parent_of(win);
    bool result = FALSE;

    if (parent != 0) {
	bool top = (parent == stdscr);
	int min_col = top ? COL_MIN : 0;
	int max_col = top ? COL_MAX : getmaxx(parent);
	int min_line = top ? LINE_MIN : 0;
	int max_line = top ? LINE_MAX : getmaxy(parent);
	PAIR *tmp;
	bool more;

	show_derwin(win);
	while ((tmp = selectcell(parent,
				 win,
				 min_line, min_col,
				 max_line, max_col,
				 TRUE,
				 &more)) != 0) {
	    if (mvderwin(win, tmp->y, tmp->x) != ERR) {
		refresh_all(win);
		doupdate();
		repaint_one(win);
		doupdate();
		result = TRUE;
		show_derwin(win);
	    } else {
		flash();
	    }
	    if (!more)
		break;
	}
    }
    head_line("done");
    return result;
}
Пример #7
0
        void SIPBuilder::BeenInvited( osip_message_t* msg, string port,char** rtmsg,
                size_t *rtlen, int*state, struct DialogInfo &dlg_info)
        {
            string uac_ip = _local_ip_str_;
            string uac_listen_port_str = _local_port_str_;
            string local_dev_name = _dev_name_;

            string head_line("SIP/2.0 200 OK\r\n");

            osip_via_t *via;
            char* via_c = NULL; 
            if( !osip_list_eol (&msg->vias, 0))
            {
                via = (osip_via_t *) osip_list_get (&msg->vias, 0);
                osip_via_to_str( via, &via_c);
            }else{
                *state = -1;
                return;
            }
            string via_header(via_c);
            via_header = string("Via: ")+via_header+string("\r\n");
            
            char* from_tag_c;
            osip_from_to_str( msg->from, &from_tag_c );
            string from_header(from_tag_c);
            from_header = string("From: ")+from_header+string("\r\n");

            char* to_tag_c;
            osip_to_to_str( msg->to, &to_tag_c );
            string to_header(to_tag_c);
            string to_tag_num = _RandomNum();
            to_header = to_header + ";tag="+to_tag_num;
            to_header = string("To: ")+to_header+string("\r\n");
            dlg_info.to_tag_num = to_tag_num;

            string contact_header;
            stringstream stream_contact_header;
            stream_contact_header<<"Contact: <sip:" << local_dev_name << "@" << uac_ip << ":"<< uac_listen_port_str<<">\r\n";
            contact_header = stream_contact_header.str();

            string call_id_num = string(msg->call_id->number);
            string call_header = string("Call-ID: ")+call_id_num+("\r\n");

            string cseq_num = string(msg->cseq->number);
            string cseq_header = string("Cseq: ")+cseq_num+string(" INVITE\r\n");
            string content_type_header = "Content-Type: APPLICATION/SDP\r\n";

            string forwords = string("Max-Forwards: 70\r\n");
            string expires = string("Expires: 3000\r\n");
            string sdp_msg = _sdp_builder_.toString( string("##2015"), port);
            stringstream sdp_msg_length; 
            sdp_msg_length<< sdp_msg.length();
            string contentlenth = string("Content-Length: ")+sdp_msg_length.str()+string("\r\n");
            string cflr = string("\r\n");

            string sip_msg_str = head_line + via_header + to_header + from_header
                + call_header + cseq_header  + contact_header  +  content_type_header + 
                forwords + expires + contentlenth + cflr + sdp_msg;
#ifdef DEBUG
            cout<<"check Been Invite:"<<endl;
            cout<<sip_msg_str<<endl;
#endif
            size_t sip_len = sip_msg_str.length();
            char* sip_msg_c = (char*)malloc(sizeof(char)* sip_len);
            memcpy( sip_msg_c, sip_msg_str.c_str(), sip_len);
            *rtmsg = sip_msg_c;
            *rtlen = sip_len;
            /*send 200ok, wait ack*/
            *state = 0;
            return;
        }