Example #1
0
static void items_back_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {
    current_list = 0;
    while (items_active_item_count > 0) {
        items_todo_list_delete(0);
    }

    unlock_info();
    hide_info();

    window_stack_remove(&items_window, true);
}
Example #2
0
static void lists_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {

    if (info_on)
    {
        unlock_info();
        hide_info();
        //display_info("LOADING...");
    } else {
        const int index = cell_index->row;

        window_stack_push(&items_window, true);
        //Send first request (INFOS):
        current_list = index;
        //send_request(HTTP_CMD_REQUEST_ITEM, current_list, 0);

        //scroll to top:
        while (menu_layer_get_selected_index(&items_menu_layer).row > 0) {
            menu_layer_set_selected_next(&items_menu_layer, true, MenuRowAlignTop, true);
        }

        //refresh menu layer:
        menu_layer_reload_data(&items_menu_layer);
    }
}
Example #3
0
static void success(int32_t cookie, int http_status, DictionaryIterator* received, void* context) {
    //todo_list_append("_success_");
    if(cookie != LIST_HTTP_COOKIE) {/*todo_list_append("strange_suc");*/ return;}



    //Try to get Infos:
    Tuple* info_tuple = dict_find(received, HTTP_CMD_REQUEST_INFOS);
    if (info_tuple)
    {
        memcpy(&infos, info_tuple->value->cstring, 255);
        display_info(infos);
        lock_info();
        //Send second request (NUM_LISTS):
        send_request(HTTP_CMD_REQUEST_NUM_LISTS, 0, 0);
    }

    //Try to get the Pebble-ID:
    Tuple* id_tuple = dict_find(received, HTTP_CMD_REQUEST_ID);
    if (id_tuple)
    {
        memcpy(&x_pebble_id, id_tuple->value->cstring, 12);
        display_info(x_pebble_id);
    }

    //Try to get the number of lists:
    Tuple* num_lists_tuple = dict_find(received, HTTP_CMD_REQUEST_NUM_LISTS);
    if (num_lists_tuple)
    {
        num_lists = num_lists_tuple->value->int8;
        if (num_lists > 0) {
            //Send third request (first list name):
            counter = 0;
            send_request(HTTP_CMD_REQUEST_LIST, counter, 0);
            counter += 1;
        
        
        } else {
            unlock_info();
            display_info("No lists available.\n\nSee http://goo.gl/su3h4K for instructions.");
            lock_info();
        }
    }

    //Try to get a list name:
    Tuple* list_name_tuple = dict_find(received, HTTP_CMD_REQUEST_LIST);
    if (list_name_tuple)
    {
        lists_todo_list_append(list_name_tuple->value->cstring, 0);

        if (counter < (num_lists))
        {
            send_request(HTTP_CMD_REQUEST_LIST, counter, 0);
            counter+=1;
        } else {
            //todo_list_append("_counter_max_");
            if (num_lists > 0)
            {
                unlock_info();
                hide_info();
            }
            menu_layer_reload_data(&lists_menu_layer);
        }
    }


    //try to get number of items:
    Tuple* num_items_tuple = dict_find(received, HTTP_CMD_REQUEST_NUM_ITEMS);    
    if (num_items_tuple)
    {
        num_items = num_items_tuple->value->int8;
        if (num_items > 0) {
            counter = 1;
            send_request(HTTP_CMD_REQUEST_ITEM, current_list, counter);
            counter += 1;
        } else {
            items_todo_list_append("num_items==0",0);
                unlock_info();
                display_info("No items.\nSee http://goo.gl/su3h4K for instructions.");
                lock_info();
        }
    } 


    //Try to get an item:
    Tuple* data_tuple = dict_find(received, HTTP_CMD_RESPONSE_ITEM);
    Tuple* state_tuple = dict_find(received, HTTP_CMD_RESPONSE_STATE);
    if(data_tuple) {
        items_todo_list_append(data_tuple->value->cstring, state_tuple->value->int8);
        // todo_list_append(itoa(state_tuple->value->int8));      

        if (counter <= (num_items))
        {
            send_request(HTTP_CMD_REQUEST_ITEM, current_list, counter);
            counter+=1;
        } else {
            //todo_list_append("_counter_max_");
            if (num_items > 0)
            {
                unlock_info();
                hide_info();
            } else {

            }
        }
    }

    menu_layer_reload_data(&items_menu_layer);
}
void
receiver_leave (FL_OBJECT *ob, long data)
{
    FILE *fp;
    int pid;


    rcvr_runrun = 0;
    if (data > -1  && (fp = fopen ("receiver.pid", "r")) != NULL)
    {
        fl_hide_form (fd_receiver_main->receiver_main);
        hide_info(NULL, 0);
        hide_interferometer (NULL, 0);
        hide_waterfall (NULL, 0);
        tp_hide (NULL, 0);
        spectrum_hide (NULL, 0);
        dismiss_psr (NULL, 0);

        fl_show_form (fd_receiver_shutdown->receiver_shutdown, FL_PLACE_CENTER, FL_NOBORDER, "IRA Shutdown");
        fl_check_forms ();

        fscanf (fp, "%d", &pid);
        kill (pid, SIGINT);
        sleep (1);
        kill (pid, SIGHUP);
        sleep (1);
        kill (pid, SIGKILL);
        fclose (fp);
    }
    if (data < -1)
    {
        char string[129];

        if (before)
        {
            fprintf (stderr, "Leaving from: %s\n", __FUNCTION__);
            receiver_leave (ob, 0);
        }
        before++;

        fp = fopen ("receiver_py.err", "r");
        fl_set_browser_fontsize(fd_receiver_error->error_browser, 14);
        fl_set_browser_fontstyle(fd_receiver_error->error_browser, FL_BOLD_STYLE);
        if (fp != NULL)
        {

            while (fgets (string, 128, fp) != NULL)
            {
                string[strlen(string)-1] = '\0';
                fl_add_browser_line (fd_receiver_error->error_browser, string);
            }
            fclose (fp);
            if ((fp = fopen ("receiver_py.log", "r"))!= NULL)
            {
                while (fgets (string, 128, fp) != NULL)
                {
                    string[strlen(string)-1] = '\0';
                    fl_add_browser_line (fd_receiver_error->error_browser, string);
                }
            }
        }
        else
        {
            fl_add_browser_line (fd_receiver_error->error_browser, "No Error Information Is Available");
        }
        if (data == -10)
        {
            fl_add_browser_line (fd_receiver_error->error_browser,
                                 "I/O Timeout from Gnu Radio--no data for >30 seconds");
            fprintf (stderr, "I/O timeout--exiting");
        }
        fl_show_form (fd_receiver_error->receiver_error, FL_PLACE_CENTER, FL_FULLBORDER, "IRA Errors");
        fl_check_forms ();
        no_more_input = 1;
        return;
    }
    exit (0);
}