void MppShortcutTab :: handle_record_event(const uint8_t *data) { uint32_t x; uint8_t match[3] = {(uint8_t)(data[1] & 0xF0),data[2],data[3]}; for (x = 0; x != MPP_SHORTCUT_MAX; x++) { if (but_rec[x]->isFlat()) break; } if (x == MPP_SHORTCUT_MAX) return; /* remove amplitude from key-presses */ if (match[0] == 0x90) match[2] = 0x7e; led_cmd[x]->setText(QString("%1 %2 %3") .arg(match[0], 2, 16, QChar('0')) .arg(match[1], 2, 16, QChar('0')) .arg(match[2], 2, 16, QChar('0'))); but_rec[x]->setFlat(0); handle_update(); }
void MppShortcutTab :: handle_set_all_flat() { uint32_t x; for (x = 0; x != MPP_SHORTCUT_MAX; x++) but_rec[x]->setFlat(1); handle_update(); }
static void message_handler(char* operation, char* data) { if (strcmp(operation, "UPDATE") == 0) { handle_update(data); } else if (strcmp(operation, "DETAILS") == 0) { handle_details(data); } }
box2d<double> group_layout_manager::offset_box_at(size_t i) { handle_update(); pixel_position const& offset = member_offsets_.at(i); bound_box const& box = member_boxes_.at(i); return box2d<double>(box.minx() + offset.x, box.miny() + offset.y, box.maxx() + offset.x, box.maxy() + offset.y); }
void MppShortcutTab :: handle_record(int x) { if (but_rec[x]->isFlat()) { but_rec[x]->setFlat(0); } else { but_rec[x]->setFlat(1); } handle_update(); }
void handle_main_window_load(Window *window) { // Create GBitmap, then set to created BitmapLayer s_background_bitmap = gbitmap_create_with_resource(IMAGE_RESOURCE_IDS_BACKGROUNDS[4]); s_point_bitmap = gbitmap_create_with_resource(IMAGE_RESOURCE_IDS_HANDS[1]); s_background_layer = bitmap_layer_create(GRect(0, 12, 144, 144)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); #if defined(USER_ROT_BITMAP) s_hour_point_layer = rot_bitmap_layer_create(s_point_bitmap); rot_bitmap_set_compositing_mode(s_hour_point_layer, GCompOpAnd); s_min_point_layer = rot_bitmap_layer_create(s_point_bitmap); rot_bitmap_set_compositing_mode(s_min_point_layer, GCompOpAnd); #else GRect rec= {{0, 0}, {16, 16}}; s_hour_point_layer = bitmap_layer_create(rec); bitmap_layer_set_bitmap(s_hour_point_layer, s_point_bitmap); bitmap_layer_set_compositing_mode(s_hour_point_layer, GCompOpAnd); s_min_point_layer = bitmap_layer_create(rec); bitmap_layer_set_bitmap(s_min_point_layer, s_point_bitmap); bitmap_layer_set_compositing_mode(s_min_point_layer, GCompOpAnd); #endif // Update the time now handle_update(); Layer * root_layer = window_get_root_layer(window); // Add it as a child layer to the Window's root layer layer_add_child(root_layer, bitmap_layer_get_layer(s_background_layer)); #if defined(USER_ROT_BITMAP) layer_add_child(root_layer, (Layer*)(s_hour_point_layer)); layer_add_child(root_layer, (Layer*)(s_min_point_layer)); #else layer_add_child(root_layer, bitmap_layer_get_layer(s_hour_point_layer)); layer_add_child(root_layer, bitmap_layer_get_layer(s_min_point_layer)); #endif add_invert(root_layer); // Register with TickTimerService #if defined(USE_TEST_SECONDS) tick_timer_service_subscribe(SECOND_UNIT, handle_tick); #else tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); #endif }
static void handle_udp_updates(struct datagram *update_port) { char data[DATAGRAM_PAYLOAD_MAX]; char addr[DATAGRAM_ADDRESS_MAX]; int port; while(1) { int result = datagram_recv(update_port, data, DATAGRAM_PAYLOAD_MAX, addr, &port, 0); if(result <= 0) return; data[result] = 0; handle_update(addr,port,data,result,"udp"); } }
static void handle_packet (ccnet_packet *packet, CcnetPeer *peer) { switch (packet->header.type) { case CCNET_MSG_REQUEST: handle_request (peer, packet->header.id, packet->data, packet->header.length); break; case CCNET_MSG_RESPONSE: handle_response (peer, packet->header.id, packet->data, packet->header.length); break; case CCNET_MSG_UPDATE: handle_update (peer, packet->header.id, packet->data, packet->header.length); break; default: ccnet_warning ("Unknown header type %d\n", packet->header.type); }; }
static void handle_message(struct worker* client, const char* data){ struct json_object* json = json_tokener_parse(data); if ( !json ){ logmsg("Failed to parse JSON\n"); return; } struct json_object* type; if ( !json_object_object_get_ex(json, "type", &type) ){ logmsg("message missing type\n"); return; } const char* type_str = json_object_get_string(type); if ( strcmp(type_str, "update") == 0 ){ handle_update(json); } else { logmsg("unhandled message type %s\n", type_str); } json_object_put(json); }
int handle_console_msg(int cons_fd) { int ret = 0; struct cons_msg msg; ret = read(cons_fd, &msg, sizeof(struct cons_msg)); if (ret != sizeof(struct cons_msg)) { printf("ERROR: Could not read console message\n"); return ret; } switch (msg.op) { case CONSOLE_CURS_SET: // printf("Console cursor set (x=%d, y=%d)\n", msg.cursor.x, msg.cursor.y); handle_curs_set(&(msg.cursor)); break; case CONSOLE_CHAR_SET: handle_char_set(&(msg.character)); /* printf("Console character set (x=%d, y=%d, c=%c, style=%c)\n", msg.character.x, msg.character.y, msg.character.c, msg.character.style);*/ break; case CONSOLE_SCROLL: // printf("Console scroll (lines=%d)\n", msg.scroll.lines); handle_scroll(&(msg.scroll)); break; case CONSOLE_UPDATE: // printf("Console update\n"); handle_update(); break; case CONSOLE_RESOLUTION: handle_text_resolution(&(msg.resolution)); break; default: printf("Invalid console message operation (%d)\n", msg.op); break; } return 0; }
void handle_tcp_update( struct link *update_port ) { char data[TCP_PAYLOAD_MAX]; time_t stoptime = time(0) + HANDLE_TCP_UPDATE_TIMEOUT; struct link *l = link_accept(update_port,stoptime); if(!l) return; char addr[LINK_ADDRESS_MAX]; int port; link_address_remote(l,addr,&port); int length = link_read(l,data,sizeof(data)-1,stoptime); if(length>0) { data[length] = 0; handle_update(addr,port,data,length,"tcp"); } link_close(l); }
void Control_socket_manager::handle_control_message(Control_message* message) { set_message_destination_ip(message); const int code = message->header.control_code; switch (code) { case AUTHOR: handle_author(message); break; case INIT: handle_init(message); break; case ROUTING_TABLE: handle_routing_table(message); break; case UPDATE: handle_update(message); break; case CRASH: handle_crash(message); break; case SENDFILE: handle_sendfile(message); break; case SENDFILE_STATS: handle_sendfile_stats(message); break; case LAST_DATA_PACKET: handle_last_data_packet(message); break; case PENULTIMATE_DATA_PACKET: handle_penultimate_data_packet(message); break; } }
// test important PRIVATE gboolean _inotify_poll() { #define EVENT_SIZE ( sizeof (struct inotify_event) ) #define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) if (_inotify_fd != -1) { char buffer[EVENT_BUF_LEN]; int length = read(_inotify_fd, buffer, EVENT_BUF_LEN); struct inotify_event *move_out_event = NULL; GFile* old = NULL;// test : use real fileops to test it for (int i=0; i<length; ) { struct inotify_event *event = (struct inotify_event *) &buffer[i]; i += EVENT_SIZE+event->len; if(desktop_file_filter(event->name)) continue; if (event->len) { GFile* p = g_hash_table_lookup(_monitor_table, GINT_TO_POINTER(event->wd)); if (g_file_equal(p, _desktop_file)) { /* BEGIN MOVE EVENT HANDLE */ if ((event->mask & IN_MOVED_FROM) && (move_out_event == NULL)) { move_out_event = event; old = g_file_get_child(p, event->name); continue; } else if ((event->mask & IN_MOVED_FROM) && (move_out_event != NULL)) { GFile* f = g_file_get_child(_desktop_file, event->name); handle_delete(f); g_object_unref(f); continue; } else if ((event->mask & IN_MOVED_TO) && (move_out_event != NULL)) { move_out_event = NULL; GFile* f = g_file_get_child(p, event->name); handle_rename(old, f); g_object_unref(f); g_object_unref(old); old = NULL; continue; /* END MVOE EVENT HANDLE */ } else if (event->mask & IN_DELETE) { GFile* f = g_file_get_child(p, event->name); handle_delete(f); g_object_unref(f); } else if (event->mask & IN_CREATE) { GFile* f = g_file_get_child(p, event->name); handle_new(f); g_object_unref(f); } else { GFile* f = g_file_get_child(p, event->name); _add_monitor_directory(f); handle_update(f); g_object_unref(f); } } else { if (event->mask & IN_MOVED_TO) { GFile* f = g_file_get_child(_desktop_file, event->name); handle_delete(f); g_object_unref(f); } handle_update(p); } } } if (move_out_event != NULL) { handle_delete(old); move_out_event = NULL; } return TRUE; } else { return FALSE; } }
void handle_new(GFile* f) { _add_monitor_directory(f); handle_update(f); }
inline const pixel_position &offset_at(size_t i) { handle_update(); return member_offsets_.at(i); }
/************************************************************************** * Download Main Function **************************************************************************/ void download_handler(void) { u32 pktsz = 0; u8 *buf = NULL; handle_pl_info (); buf = prepare_data_buf (); /* init global vars */ g_dl_safe_start_addr = 0; g_cust_key_init = FALSE; g_end_user_flash_tool = FALSE; g_sec_img_patch_enable = FALSE; g_sec_img_patch_valid = FALSE; #if DM_CAL_CKSM_FROM_USB_BUFFER dm_ctx.chk_sum = 0; #endif #if DM_TIME_ANALYSIS g_DM_TIME_Tmp = 0; g_DM_TIME_ReadData = 0; g_DM_TIME_FlashData = 0; g_DM_TIME_Erase = 0; g_DM_TIME_USBGet = 0; g_DM_TIME_SkipBadBlock = 0; g_DM_TIME_Checksum = 0; g_DM_TIME_Total_Begin = 0; g_DM_TIME_Total = 0; #endif reset_dm_descriptor (); DM_TIME_TOTAL_BEGIN; if (!buf) return; dm_ctx.dm_status = DM_STATUS_START; while (1) { if (dm_ctx.dm_status == DM_STATUS_SECT_ONGING) { DM_STATE_LOG ("SECT_ONGOING"); handle_data (pktsz, buf); } else if (dm_ctx.dm_status == DM_STATUS_START) { DM_STATE_LOG ("START"); handle_imgp (&pktsz); } else if (dm_ctx.dm_status == DM_STATUS_SECT_FINISHED) { DM_STATE_LOG ("SECT_FINISHED"); handle_cksm (); } else if (dm_ctx.dm_status == DM_STATUS_SECT_WAIT_NXT) { DM_STATE_LOG ("WAIT_NEXT"); handle_midle_state (buf); } else if (dm_ctx.dm_status == DM_STATUS_REBOOT) { DM_STATE_LOG ("REBOOT"); handle_reboot (); break; } else if (dm_ctx.dm_status == DM_STATUS_ATBOOT) { DM_STATE_LOG ("ATBOOT"); handle_autoboot (); break; } else if (dm_ctx.dm_status == DM_STATUS_UPDATE) { DM_STATE_LOG ("UPDATE"); handle_update (); } else if (dm_ctx.dm_status == DM_STATUS_ERR_ONGOING) { DM_STATE_LOG ("ERR_ONGOING"); handle_data (pktsz, buf); } else if (dm_ctx.dm_status == DM_STATUS_ERR_FINISHED) { DM_STATE_LOG ("ERR_FINISHED"); handle_errp (); } } return; }
void handle_tick(struct tm *tick_time, TimeUnits units_changed) { handle_update(); }