DbLock BerkeleyQ::acquire_lock(const string& name, const db_lockmode_t lock_mode) { DbLock lock; Dbt lock_info((void*)name.c_str(), (uint)name.size()+1); switch (int ret = db->get_env()->lock_get(locker_id, 0, &lock_info, lock_mode, &lock)) { case 0: //q_log("berkeley [%s] lock acquired", queue_name.c_str()); break; default: q_error("berkeley lock_get: unknown error"); } return lock; }
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); }