Ejemplo n.º 1
0
int window_new_call_run_command(gui_t* gui, int c)
{
	ogmp_curses_t* ocui = gui->topui;

	int max = 3;

	switch (c)
    {
		case KEY_DC:
		{
			editline_remove_char(newcall_edit[cursor_newcall]);
			
			delch();

			break;
		}
		case '\b':
		{
			if (editline_move_pos(newcall_edit[cursor_newcall], -1) >= 0)
				editline_remove_char(newcall_edit[cursor_newcall]);
			else
				beep();

			break;
		}
		case '\n':
		case '\r':
		case KEY_ENTER:
		case KEY_DOWN:
		{
			cursor_newcall++;
			cursor_newcall %= max;

			break;
		}
		case KEY_UP:
		{
			cursor_newcall += max-1;
			cursor_newcall %= max;

			break;
		}
		case KEY_RIGHT:
		{
			if (editline_move_pos(newcall_edit[cursor_newcall], 1) < 0)
				beep();

			break;
		}
		case KEY_LEFT:
		{
			if (editline_move_pos(newcall_edit[cursor_newcall], -1) < 0)
				beep();

			break;
		}
		case 1: /* Ctrl-A */
		{
			/* if (_josua_start_call(cfg.identity, to, subject, route) != 0) beep(); */
			sipua_set_t* call = ocui->sipua->new_call(ocui->sipua, newcall_inputs[NEWCALL_SUBJ], strlen(newcall_inputs[NEWCALL_SUBJ]), newcall_inputs[NEWCALL_MSG], strlen(newcall_inputs[NEWCALL_MSG]));
			
			if(call)
				ocui->sipua->call(ocui->sipua, call, newcall_inputs[NEWCALL_TO]);

			gui_activate_window(gui, GUI_SESSION);

			break;
		}
		case 3:  /* Ctrl-C */
		{
			gui_hide_window(gui);

			break;
		}
		case 4:  /* Ctrl-D */
		{
			editline_clear(newcall_edit[cursor_newcall]);
	
			break;
		}
		case 15: /* Ctrl-O */
		{
			/* if (_josua_start_options(cfg.identity, to, route) != 0) beep(); */
			break;
		}
		case 19: /* Ctrl-S */
		{
			/* if (_josua_start_subscribe(cfg.identity, to, route) != 0) beep(); */
			break;
		}
		default:
		{
			if(editline_append(newcall_edit[cursor_newcall], (char*)&c, 1) == 0)
				beep();
	
			return -1;
		}
	}

	return 0;
}
Ejemplo n.º 2
0
/*------------------------------------------------------------------------------------
 * 函数:    start()
 *
 * 描述:    应用程序启始例程
**----------------------------------------------------------------------------------*/
void __task start(void * data)
{
    data = data;

    /*
    TaskCreate(demo_task, (void *)1, "demo1", NULL, 512, 1, TASK_CREATE_OPT_NONE);
    TaskCreate(demo_task, (void *)2, "demo2", NULL, 512, 2, TASK_CREATE_OPT_NONE);
    TaskCreate(demo_task, (void *)3, "demo3", NULL, 512, 3, TASK_CREATE_OPT_NONE);
    TaskCreate(demo_task, (void *)4, "demo4", NULL, 512, 4, TASK_CREATE_OPT_NONE);
    TaskCreate(demo_task, (void *)5, "demo5", NULL, 512, 5, TASK_CREATE_OPT_NONE);
    TaskCreate(demo_task, (void *)6, "demo6", NULL, 512, 6, TASK_CREATE_OPT_NONE);
    TaskCreate(demo_task, (void *)7, "demo7", NULL, 512, 7, TASK_CREATE_OPT_NONE);
    TaskCreate(demo_task, (void *)8, "demo8", NULL, 512, 8, TASK_CREATE_OPT_NONE);
    */

    demo_init_gui();
    TaskCreate(refresh_task, NULL, "refresh", NULL, 2048, 8, TASK_CREATE_OPT_NONE);

    OpenConsole();

    RegisterSpecialKey('x', move_button);

    for(;;){
        KEYCODE key;
        char buf[64] = {0, };

        key = gui_edit_input(test, buf, 32, 0);
        /* use superkey alt-x-k to quit! */
        switch(key){
            case UP:
                gui_view_move_up(view);
                break;
            case DOWN:
                gui_view_move_down(view);
                break;
            case PGUP:
                gui_view_page_up(view);
                break;
            case PGDN:
                gui_view_page_down(view);
                break;
        }
        switch(buf[0]){
            default:
                break;
            case 'c':
            case 'C':
                color = atoi(&buf[1]);
                gui_set_widget_color(edit, color);
                break;
            case 'b':
            case 'B':
                bkcolor = atoi(&buf[1]);
                gui_set_widget_bkcolor(edit, bkcolor);
                break;
            case 's':
            case 'S':
                style = STRtoINT16(&buf[1], 0);
                gui_set_widget_style(edit, style);
                break;
            case 'p':
            case 'P':
                /*
                gui_progress_set_value(progress1, atoi(&buf[1]));
                */
                break;
            case 'a':
            case 'A':
                {
                     struct student * t;

                     t = mem_alloc(sizeof(*t));
                     if(!t)
                        break;
                     sprintf(t->name, "Name");
                     t->sex = '-';
                     t->old = 0;
                     sprintf(t->comment, "");
                     lock_kernel();
                     t->next = all_students;
                     all_students = t;
                     unlock_kernel();
                }
                break;
            case 'd':
            case 'D':
                /*gui_show_window(window2);*/
                input_dialog_method(&abcde, dialog_prepare, dialog_finish, NULL, 1);
                {
                    static COLOR tmp = 67;
                    gui_desktop_set_color(tmp);
                    tmp += 77;
                }
                TaskSleep(10);
                /*gui_hide_window(window2);*/
                break;
            case 'h':
            case 'H':
                gui_hide_window(window3);
                break;
            case 'f':
            case 'F':
                gui_show_window(window3);
                break;
            case 'm':
            case 'M':
                while (1) {
                    gui_window_t * w;
                    KEYCODE move;
                    if (buf[0] == 'm')
                        w = window2;
                    else
                        w = window3;
                    move = getkey();
                    switch (move) {
                        case ESC:
                            goto out_while;
                        case LEFT:
                            gui_window_move(w, -23, 0);
                            break;
                        case RIGHT:
                            gui_window_move(w, 13, 0);
                            break;
                        case UP:
                            gui_window_move(w, 0, -11);
                            break;
                        case DOWN:
                            gui_window_move(w, 0, 23);
                            break;
                        case CTRL_LEFT:
                            gui_window_resize(w, -23, 0);
                            break;
                        case CTRL_RIGHT:
                            gui_window_resize(w, 13, 0);
                            break;
                        case CTRL_UP:
                            gui_window_resize(w, 0, -11);
                            break;
                        case CTRL_DOWN:
                            gui_window_resize(w, 0, 23);
                            break;
                    }
                }
                out_while:
                break;
            case 'e':
            case 'E':
                while(1){
                    key = gui_view_editing(view, 0);
                    if(key == ESC)
                        break;
                    switch(key){
                        case UP:
                            gui_view_move_up(view);
                            break;
                        case DOWN:
                            gui_view_move_down(view);
                            break;
                        default:
                            break;
                    }
                }
                break;
        }
    }
}
Ejemplo n.º 3
0
int window_new_identity_run_command(gui_t* gui, int c)
{
    ogmp_curses_t* ocui = gui->topui;

    int max = 5;

    switch (c)
    {
    case KEY_DC:
    {
        editline_remove_char(newid_edit[cursor_newid]);

        delch();

        break;
    }
    case '\b':
    {
        if (editline_move_pos(newid_edit[cursor_newid], -1) >= 0)
            editline_remove_char(newid_edit[cursor_newid]);
        else
            beep();

        break;
    }
    case '\n':
    case '\r':
    case KEY_ENTER:
    case KEY_DOWN:
    {
        cursor_newid++;
        cursor_newid %= max;

        break;
    }
    case KEY_UP:
    {
        cursor_newid += max-1;
        cursor_newid %= max;

        break;
    }
    case KEY_RIGHT:
    {
        if (editline_move_pos(newid_edit[cursor_newid], 1) < 0)
            beep();

        break;
    }
    case KEY_LEFT:
    {
        if (editline_move_pos(newid_edit[cursor_newid], -1) < 0)
            beep();

        break;
    }
    case 1:  /* Ctrl-A */
    {
        int sec = 0;

        if(newid_regsec[0])
            sec = strtol(newid_regsec, NULL, 10);

        if(sec <= 0)
            break;

        if(newid_fullname[0] && newid_registary[0] && newid_regname[0])
        {
            if(!ocui->edit_profile)
                user_add_profile(ocui->user, newid_fullname, strlen(newid_fullname),
                                 newid_bookloc, newid_registary, newid_regname, sec);
            else
                user_set_profile(ocui->user, ocui->edit_profile, newid_fullname, strlen(newid_fullname),
                                 newid_bookloc, newid_registary, newid_regname, sec);

            gui_hide_window(gui);
        }

        break;
    }
    case 3:  /* Ctrl-C */
    {
        gui_hide_window(gui);

        break;
    }
    case 4:  /* Ctrl-D */
    {
        editline_clear(newid_edit[cursor_newid]);

        break;
    }
    default:
    {
        if(editline_append(newid_edit[cursor_newid], (char*)&c, 1) == 0)
        {
            beep();

            return -1;
        }
    }
    }

    gui_update(gui);

    return 0;
}
Ejemplo n.º 4
0
int window_sessions_list_run_command(gui_t* gui, int c)
{
	int busylines[MAX_SIPUA_LINES];
	int nbusy;

	ogmp_curses_t* ocui = gui->topui;

	ocui->sipua->lock_lines(ocui->sipua);
	nbusy = ocui->sipua->busylines(ocui->sipua, busylines, MAX_SIPUA_LINES);
	ocui->sipua->unlock_lines(ocui->sipua);

	curseson(); cbreak(); noecho(); nonl(); keypad(stdscr,TRUE);
	/*
	i = jcall_get_number_of_pending_calls();
	if (i<max) 
		max=i;
	*/
	switch (c)
    {
		sipua_set_t* call;

		case KEY_DOWN:
		{
			int n = 0;
			while(busylines[n] != calllist_line) n++;

			if(n+1==nbusy)
			{
				beep();
				break;
			}

			calllist_line = busylines[++n];
			break;
		}
		case KEY_UP:
		{
			int n = 0;
			while(busylines[n] != calllist_line) n++;

			if(n==0)
			{
				beep();
				break;
			}

			calllist_line = busylines[--n];
			break;
		}
		case 3:  /* Ctrl-C */
		{
			gui_hide_window(gui);

			break;
		}
		case 'c':
		{
			int n = 0;

			call = ocui->sipua->session(ocui->sipua);

			ocui->sipua->bye(ocui->sipua, call);
			
			while(busylines[n] != calllist_line) 
				n++;

			if(n > 0)
				calllist_line = busylines[--n];
			else
			{
				if(nbusy > 1)
					calllist_line = busylines[++n];
				else
					calllist_line = -1;
			}
/*
			eXosip_lock();
			i = eXosip_terminate_call(ca->cid, ca->did);
			if (i==0) jcall_remove(ca);
			eXosip_unlock();
*/
			gui->gui_print(gui, gui->parent);
			break;
		}
		case 'a':
		{
			call = ocui->sipua->pick(ocui->sipua, calllist_line);
			if (!call) 
			{ 
				beep(); 
				break; 
			}

			ocui->sipua->answer(ocui->sipua, call, SIPUA_STATUS_ANSWER);
/*
			eXosip_lock();
			eXosip_answer_call(ca->did, 200, 0);
			eXosip_unlock();
*/
			break;
		}
		case 'r':
		{
			int n = 0;

			call = ocui->sipua->pick(ocui->sipua, calllist_line);
			if (!call) 
			{ 
				beep(); 
				break; 
			}

			ocui->sipua->answer(ocui->sipua, call, SIPUA_STATUS_REJECT);

			while(busylines[n] != calllist_line) 
				n++;

			if(n > 0)
				calllist_line = busylines[--n];
			else
			{
				if(nbusy > 1)
					calllist_line = busylines[++n];
				else
					calllist_line = -1;
			}
/*
			eXosip_lock();
			i = eXosip_answer_call(ca->did, 480, 0);
			if (i==0) jcall_remove(ca);
			eXosip_unlock();
*/
			gui->gui_print(gui, gui->parent);
			break;
		}
		case 'd':
		{
			int n = 0;

			call = ocui->sipua->pick(ocui->sipua, calllist_line);
			if (!call) 
			{ 
				beep(); 
				break; 
			}

			ocui->sipua->answer(ocui->sipua, call, SIPUA_STATUS_DECLINE);
			
			while(busylines[n] != calllist_line) 
				n++;

			if(n > 0)
				calllist_line = busylines[--n];
			else
			{
				if(nbusy > 1)
					calllist_line = busylines[++n];
				else
					calllist_line = -1;
			}
/*
			eXosip_lock();
			i = eXosip_answer_call(ca->did, 603, 0);
			if (i==0) jcall_remove(ca);
			eXosip_unlock();
*/
			gui->gui_print(gui, gui->parent);
			break;
		}
		case 'b':
		{
			int n = 0;

			call = ocui->sipua->pick(ocui->sipua, calllist_line);
			if (!call) 
			{ 
				beep(); 
				break; 
			}

			ocui->sipua->answer(ocui->sipua, call, SIPUA_STATUS_BUSY);
			
			while(busylines[n] != calllist_line) 
				n++;

			if(n > 0)
				calllist_line = busylines[--n];
			else
			{
				if(nbusy > 1)
					calllist_line = busylines[++n];
				else
					calllist_line = -1;
			}
/*
			eXosip_lock();
			i = eXosip_answer_call(ca->did, 486, 0);
			if (i==0) jcall_remove(ca);
			eXosip_unlock();
*/
			gui->gui_print(gui, gui->parent);
			break;
		}
		case 'h':
		{
			call = ocui->sipua->session(ocui->sipua);

			calllist_line = ocui->sipua->hold(ocui->sipua, call);
/*
			eXosip_lock();
			eXosip_on_hold_call(ca->did);
			eXosip_unlock();
*/
			break;
		}
		case 'u':
		{
			call = ocui->sipua->pick(ocui->sipua, calllist_line);
			if (!call) 
			{ 
				beep(); 
				break; 
			}

			ocui->sipua->answer(ocui->sipua, call, SIPUA_STATUS_ANSWER);
/*
			eXosip_lock();
			eXosip_off_hold_call(ca->did);
			eXosip_unlock();
*/
			break;
		}
		case 'o':
		{
			call = ocui->sipua->pick(ocui->sipua, calllist_line);
			if (!call) 
			{ 
				beep(); 
				break; 
			}

			ocui->sipua->options_call(ocui->sipua, call);
/*
			eXosip_lock();
			eXosip_options_call(ca->did);
			eXosip_unlock();
*/
			break;
		}
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
		case '#':
		case '*':
		{
			char dtmf_body[1000];

			call = ocui->sipua->pick(ocui->sipua, calllist_line);
			if (!call) 
			{ 
				beep(); 
				break; 
			}

			snprintf(dtmf_body, 999, "Signal=%c\r\nDuration=250\r\n", c);

			ocui->sipua->info_call(ocui->sipua, call, "application/dtmf-relay", dtmf_body);
/*
			eXosip_lock();
			eXosip_info_call(ca->did, "application/dtmf-relay", dtmf_body);
			eXosip_unlock();
*/
			break;
		}
		default:
			beep();
			return -1;
    }

	gui->gui_print(gui, gui->parent);

	return 0;
}