Exemple #1
0
void
handle_display_list(json_t * display_list)
{
    int i, j, count;
    json_t *jwrap, *jobj;
    void *iter;
    const char *key;

    if (!json_is_array(display_list)) {
        print_error("Invalid display list data type.");
        return;
    }

    count = json_array_size(display_list);
    for (i = 0; i < count; i++) {
        jwrap = json_array_get(display_list, i);
        iter = json_object_iter(jwrap);
        if (!iter) {
            print_error("Odd: Empty display list entry.");
            continue;
        }

        key = json_object_iter_key(iter);
        jobj = json_object_iter_value(iter);

        key = switch_windowprocs(key);

        for (j = 0; netcmd_list[j].name; j++) {
            if (!strcmp(key, netcmd_list[j].name)) {
                netcmd_list[j].func(jobj, TRUE);
                break;
            }
        }

        if (json_object_iter_next(jwrap, iter))
            print_error("Unsupported: more than one command in a"
                        " single display list entry.");

        if (!netcmd_list[j].name)
            print_error("Unknown display list entry type.");
    }
}
Exemple #2
0
json_t *handle_netcmd(const char *key, json_t *jmsg)
{
    int i;
    json_t *ret_msg = NULL;
    
    switch_windowprocs(key);
    
    for (i = 0; netcmd_list[i].name; i++) {
	if (!strcmp(key, netcmd_list[i].name)) {
	    ret_msg = netcmd_list[i].func(jmsg, FALSE);
	    break;
	}
    }
    json_decref(jmsg);
    
    if (!netcmd_list[i].name)
	print_error("Unknown command received from server");
    
    return ret_msg;
}