bool TrackPropDlg::SaveChanges( void ) { if( m_pRoute && !m_pRoute->m_bIsInLayer ) { // Get User input Text Fields m_pRoute->m_RouteNameString = m_tName->GetValue(); m_pRoute->m_RouteStartString = m_tFrom->GetValue(); m_pRoute->m_RouteEndString = m_tTo->GetValue(); m_pRoute->m_RouteDescription = m_tDescription->GetValue(); m_pRoute->SetVisible( m_cbShow->GetValue() ); if( m_cColor->GetSelection() == 0 ) m_pRoute->m_Colour = wxEmptyString; else m_pRoute->m_Colour = ::GpxxColorNames[m_cColor->GetSelection() - 1]; m_pRoute->m_style = ::StyleValues[m_cStyle->GetSelection()]; m_pRoute->m_width = ::WidthValues[m_cWidth->GetSelection()]; pConfig->UpdateRoute( m_pRoute ); pConfig->UpdateSettings(); } if( ((Track*) m_pRoute)->IsRunning() ) { wxJSONValue v; v[_T("Name")] = m_pRoute->m_RouteNameString; v[_T("GUID")] = m_pRoute->m_GUID; wxString msg_id( _T("OCPN_TRK_ACTIVATED") ); g_pi_manager->SendJSONMessageToAllPlugins( msg_id, v ); } return true; }
bool Routeman::ActivateRoute( Route *pRouteToActivate, RoutePoint *pStartPoint ) { pActiveRoute = pRouteToActivate; if( pStartPoint ) { pActivePoint = pStartPoint; } else { wxRoutePointListNode *node = ( pActiveRoute->pRoutePointList )->GetFirst(); pActivePoint = node->GetData(); // start at beginning } wxJSONValue v; v[_T("Route_activated")] = pRouteToActivate->m_RouteNameString; v[_T("GUID")] = pRouteToActivate->m_GUID; wxString msg_id( _T("OCPN_RTE_ACTIVATED") ); g_pi_manager->SendJSONMessageToAllPlugins( msg_id, v ); ActivateRoutePoint( pRouteToActivate, pActivePoint ); m_bArrival = false; pRouteToActivate->m_bRtIsActive = true; m_bDataValid = false; console->ShowWithFreshFonts(); return true; }
bool Routeman::DeactivateRoute( bool b_arrival ) { if( pActivePoint ) { pActivePoint->m_bBlink = false; pActivePoint->m_bIsActive = false; } if( pActiveRoute ) { pActiveRoute->m_bRtIsActive = false; pActiveRoute->m_pRouteActivePoint = NULL; } wxJSONValue v; if( !b_arrival ) { v[_T("Route_deactivated")] = pActiveRoute->m_RouteNameString; v[_T("GUID")] = pActiveRoute->m_GUID; wxString msg_id( _T("OCPN_RTE_DEACTIVATED") ); g_pi_manager->SendJSONMessageToAllPlugins( msg_id, v ); } else { v[_T("GUID")] = pActiveRoute->m_GUID; v[_T("Route_ended")] = pActiveRoute->m_RouteNameString; wxString msg_id( _T("OCPN_RTE_ENDED") ); g_pi_manager->SendJSONMessageToAllPlugins( msg_id, v ); } pActiveRoute = NULL; if( pRouteActivatePoint ) delete pRouteActivatePoint; pRouteActivatePoint = NULL; console->pCDI->ClearBackground(); console->Show( false ); m_bDataValid = false; return true; }
void connect_ping_thread(redhorn::logger log) { log.info("connecting"); auto sock = socket::connect("127.0.0.1", port); log.info("connected"); for (size_t i = 0; i < 5; ++i) { log.info("recevinig"); auto m = sock.recv(); log.info("received"); int beat_id = transport::cfgs::BEAT::msg_id; ASSERT_EQ(beat_id, m.msg_id()); } log.info("exiting"); }
bool PathMan::ActivatePath(ODPath *pPathToActivate ) { wxString msg_id( wxS("OCPN_PATH_ACTIVATED") ); wxString msg; msg.append( wxS("Name: ") ); msg.append( pPathToActivate->m_PathNameString.c_str() ); msg.append( wxS(", GUID: ") ); msg.append( pPathToActivate->m_GUID ); SendPluginMessage( msg_id, msg ); pPathToActivate->m_bPathIsActive = true; pPathToActivate->SetActiveColours(); return true; }
bool Routeman::ActivateNextPoint( Route *pr, bool skipped ) { wxJSONValue v; if( pActivePoint ) { pActivePoint->m_bBlink = false; pActivePoint->m_bIsActive = false; v[_T("isSkipped")] = skipped; v[_T("GUID")] = pActivePoint->m_GUID; v[_T("WP_arrived")] = pActivePoint->GetName(); } int n_index_active = pActiveRoute->GetIndexOf( pActivePoint ); if( ( n_index_active + 1 ) <= pActiveRoute->GetnPoints() ) { pActiveRouteSegmentBeginPoint = pActivePoint; pActiveRoute->m_pRouteActivePoint = pActiveRoute->GetPoint( n_index_active + 1 ); pActivePoint = pActiveRoute->GetPoint( n_index_active + 1 ); v[_T("Next_WP")] = pActivePoint->GetName(); v[_T("GUID")] = pActivePoint->m_GUID; pActivePoint->m_bBlink = true; pActivePoint->m_bIsActive = true; g_blink_rect = pActivePoint->CurrentRect_in_DC; // set up global blinker m_bArrival = false; // Update the RouteProperties Dialog, if currently shown if( ( NULL != pRoutePropDialog ) && ( pRoutePropDialog->IsShown() ) ) { if( pRoutePropDialog->m_pRoute == pr ) { if( pRoutePropDialog->m_pEnroutePoint ) pRoutePropDialog->m_pEnroutePoint = pActivePoint; pRoutePropDialog->SetRouteAndUpdate( pr ); pRoutePropDialog->UpdateProperties(); } } wxString msg_id( _T("OCPN_WPT_ARRIVED") ); g_pi_manager->SendJSONMessageToAllPlugins( msg_id, v ); return true; } return false; }
bool PathMan::DeactivatePath( ODPath *pPathToDeactivate ) { wxString msg_id( _T("OCPN_PATH_DEACTIVATED") ); wxString msg; msg.append( wxS("Name: ") ); msg.append( pPathToDeactivate->m_PathNameString.c_str() ); msg.append( wxS(", GUID: ") ); msg.append( pPathToDeactivate->m_GUID ); SendPluginMessage( msg_id, msg ); pPathToDeactivate->m_bPathIsActive = false; pPathToDeactivate->SetActiveColours(); // console->pCDI->ClearBackground(); // m_bDataValid = false; return true; }
bool PathProp::SaveChanges( void ) { if( m_pPath && !m_pPath->m_bIsInLayer ) { // Get User input Text Fields m_pPath->m_PathNameString = m_PathNameCtl->GetValue(); m_pPath->m_PathDescription = m_textDescription->GetValue(); m_pPath->m_bPathIsActive = m_pPathActive->GetValue(); if( m_chColor->GetSelection() == 0 ) m_pPath->m_ActiveLineColour = wxEmptyString; else m_pPath->m_ActiveLineColour = ::GpxxColorNames[m_chColor->GetSelection() - 1]; if( m_chLineColor->GetSelection() == 0 ) m_pPath->m_ActiveFillColour = wxEmptyString; else m_pPath->m_ActiveFillColour = ::GpxxColorNames[m_chLineColor->GetSelection() - 1]; m_pPath->m_style = ::StyleValues[m_chStyle->GetSelection()]; m_pPath->m_width = ::WidthValues[m_chWidth->GetSelection()]; g_pODConfig->UpdatePath( m_pPath ); //g_ocpn_draw_pi->SaveConfig(); } if( m_pPath->IsActive() ) { wxString msg_id( wxS("OCPN_PATH_ACTIVATED") ); wxString msg; msg.append( wxS("Name: ") ); msg.append( m_pPath->m_PathNameString.c_str() ); msg.append( wxS(", GUID: ") ); msg.append( m_pPath->m_GUID ); SendPluginMessage( msg_id, msg ); } return true; }
int machine_bind_blob(Code stmt,int index,void * blob,int size){ return msg_id( sqlite3_bind_blob((sqlite3_stmt*)stmt, index ,blob, size, 0)); }
int machine_step(Code stmt ) { clear_events; return set_ready_event(msg_id(sqlite3_step((sqlite3_stmt*) stmt )));}
int machine_reset(Pointer stmt) { reset_ready_event( EV_Done| EV_Data | EV_Error); return msg_id(sqlite3_reset((sqlite3_stmt*)stmt));}
int machine_exec(Pointer g_db,char * buff,char ** err) { return msg_id(sqlite3_exec((sqlite3 *)g_db,buff,0,0,err));}
int machine_lock() { char * err; return msg_id(sqlite3_exec((sqlite3 *)g_db,"BEGIN IMMEDIATE;",0,0,&err));}
bool Routeman::ActivateRoutePoint( Route *pA, RoutePoint *pRP_target ) { wxJSONValue v; pActiveRoute = pA; pActivePoint = pRP_target; pActiveRoute->m_pRouteActivePoint = pRP_target; v[_T("GUID")] = pRP_target->m_GUID; v[_T("WP_activated")] = pRP_target->GetName(); wxRoutePointListNode *node = ( pActiveRoute->pRoutePointList )->GetFirst(); while( node ) { RoutePoint *pn = node->GetData(); pn->m_bBlink = false; // turn off all blinking points pn->m_bIsActive = false; node = node->GetNext(); } node = ( pActiveRoute->pRoutePointList )->GetFirst(); RoutePoint *prp_first = node->GetData(); // If activating first point in route, create a "virtual" waypoint at present position if( pRP_target == prp_first ) { if( pRouteActivatePoint ) delete pRouteActivatePoint; pRouteActivatePoint = new RoutePoint( gLat, gLon, wxString( _T("") ), wxString( _T("") ), GPX_EMPTY_STRING, false ); // Current location pRouteActivatePoint->m_bShowName = false; pActiveRouteSegmentBeginPoint = pRouteActivatePoint; } else { prp_first->m_bBlink = false; node = node->GetNext(); RoutePoint *np_prev = prp_first; while( node ) { RoutePoint *pnext = node->GetData(); if( pnext == pRP_target ) { pActiveRouteSegmentBeginPoint = np_prev; break; } np_prev = pnext; node = node->GetNext(); } } pRP_target->m_bBlink = true; // blink the active point pRP_target->m_bIsActive = true; // and active g_blink_rect = pRP_target->CurrentRect_in_DC; // set up global blinker m_bArrival = false; // Update the RouteProperties Dialog, if currently shown if( ( NULL != pRoutePropDialog ) && ( pRoutePropDialog->IsShown() ) ) { if( pRoutePropDialog->m_pRoute == pA ) { if( pRoutePropDialog->m_pEnroutePoint ) pRoutePropDialog->m_pEnroutePoint = pActivePoint; pRoutePropDialog->SetRouteAndUpdate( pA ); pRoutePropDialog->UpdateProperties(); } } wxString msg_id( _T("OCPN_WPT_ACTIVATED") ); g_pi_manager->SendJSONMessageToAllPlugins( msg_id, v ); return true; }
int machine_unlock() { char * err; return msg_id(sqlite3_exec((sqlite3 *)g_db,"COMMIT TRANSACTION;",0,0,&err));}
int machine_prepare(Pointer g_db,char * ch,Code * stmt) { return msg_id(sqlite3_prepare_v2( (sqlite3 *)g_db,ch,G_strlen(ch)+1,(sqlite3_stmt **) stmt,0));}
void msg_dump(const struct conn *conn, const struct kdbus_msg *msg) { const struct kdbus_item *item = msg->items; char buf_src[32]; char buf_dst[32]; uint64_t timeout = 0; uint64_t cookie_reply = 0; if (msg->flags & KDBUS_MSG_FLAGS_EXPECT_REPLY) timeout = msg->timeout_ns; else cookie_reply = msg->cookie_reply; printf("MESSAGE: %s (%llu bytes) flags=0x%08llx, %s → %s, cookie=%llu, timeout=%llu cookie_reply=%llu\n", enum_PAYLOAD(msg->payload_type), (unsigned long long)msg->size, (unsigned long long)msg->flags, msg_id(msg->src_id, buf_src), msg_id(msg->dst_id, buf_dst), (unsigned long long)msg->cookie, (unsigned long long)timeout, (unsigned long long)cookie_reply); KDBUS_ITEM_FOREACH(item, msg, items) { if (item->size <= KDBUS_ITEM_HEADER_SIZE) { printf(" +%s (%llu bytes) invalid data record\n", enum_MSG(item->type), item->size); break; } switch (item->type) { case KDBUS_ITEM_PAYLOAD_OFF: { char *s; if (item->vec.offset == ~0ULL) s = "[\\0-bytes]"; else s = (char *)conn->buf + item->vec.offset; printf(" +%s (%llu bytes) off=%llu size=%llu '%s'\n", enum_MSG(item->type), item->size, (unsigned long long)item->vec.offset, (unsigned long long)item->vec.size, s); break; } case KDBUS_ITEM_PAYLOAD_MEMFD: { char *buf; uint64_t size; buf = mmap(NULL, item->memfd.size, PROT_READ, MAP_SHARED, item->memfd.fd, 0); if (buf == MAP_FAILED) { printf("mmap() fd=%i failed:%m", item->memfd.fd); break; } if (ioctl(item->memfd.fd, KDBUS_CMD_MEMFD_SIZE_GET, &size) < 0) { fprintf(stderr, "KDBUS_CMD_MEMFD_SIZE_GET failed: %m\n"); break; } printf(" +%s (%llu bytes) fd=%i size=%llu filesize=%llu '%s'\n", enum_MSG(item->type), item->size, item->memfd.fd, (unsigned long long)item->memfd.size, (unsigned long long)size, buf); break; } case KDBUS_ITEM_CREDS: printf(" +%s (%llu bytes) uid=%lld, gid=%lld, pid=%lld, tid=%lld, starttime=%lld\n", enum_MSG(item->type), item->size, item->creds.uid, item->creds.gid, item->creds.pid, item->creds.tid, item->creds.starttime); break; case KDBUS_ITEM_PID_COMM: case KDBUS_ITEM_TID_COMM: case KDBUS_ITEM_EXE: case KDBUS_ITEM_CGROUP: case KDBUS_ITEM_SECLABEL: case KDBUS_ITEM_DST_NAME: case KDBUS_ITEM_CONN_NAME: printf(" +%s (%llu bytes) '%s' (%zu)\n", enum_MSG(item->type), item->size, item->str, strlen(item->str)); break; case KDBUS_ITEM_NAME: { printf(" +%s (%llu bytes) '%s' (%zu) flags=0x%08llx\n", enum_MSG(item->type), item->size, item->name.name, strlen(item->name.name), item->name.flags); break; } case KDBUS_ITEM_CMDLINE: { size_t size = item->size - KDBUS_ITEM_HEADER_SIZE; const char *str = item->str; int count = 0; printf(" +%s (%llu bytes) ", enum_MSG(item->type), item->size); while (size) { printf("'%s' ", str); size -= strlen(str) + 1; str += strlen(str) + 1; count++; } printf("(%d string%s)\n", count, (count == 1) ? "" : "s"); break; } case KDBUS_ITEM_AUDIT: printf(" +%s (%llu bytes) loginuid=%llu sessionid=%llu\n", enum_MSG(item->type), item->size, (unsigned long long)item->data64[0], (unsigned long long)item->data64[1]); break; case KDBUS_ITEM_CAPS: { int n; const uint32_t *cap; int i; printf(" +%s (%llu bytes) len=%llu bytes\n", enum_MSG(item->type), item->size, (unsigned long long)item->size - KDBUS_ITEM_HEADER_SIZE); cap = item->data32; n = (item->size - KDBUS_ITEM_HEADER_SIZE) / 4 / sizeof(uint32_t); printf(" CapInh="); for (i = 0; i < n; i++) printf("%08x", cap[(0 * n) + (n - i - 1)]); printf(" CapPrm="); for (i = 0; i < n; i++) printf("%08x", cap[(1 * n) + (n - i - 1)]); printf(" CapEff="); for (i = 0; i < n; i++) printf("%08x", cap[(2 * n) + (n - i - 1)]); printf(" CapInh="); for (i = 0; i < n; i++) printf("%08x", cap[(3 * n) + (n - i - 1)]); printf("\n"); break; } case KDBUS_ITEM_TIMESTAMP: printf(" +%s (%llu bytes) seq=%llu realtime=%lluns monotonic=%lluns\n", enum_MSG(item->type), item->size, (unsigned long long)item->timestamp.seqnum, (unsigned long long)item->timestamp.realtime_ns, (unsigned long long)item->timestamp.monotonic_ns); break; case KDBUS_ITEM_REPLY_TIMEOUT: printf(" +%s (%llu bytes) cookie=%llu\n", enum_MSG(item->type), item->size, msg->cookie_reply); break; case KDBUS_ITEM_NAME_ADD: case KDBUS_ITEM_NAME_REMOVE: case KDBUS_ITEM_NAME_CHANGE: printf(" +%s (%llu bytes) '%s', old id=%lld, new id=%lld, old_flags=0x%llx new_flags=0x%llx\n", enum_MSG(item->type), (unsigned long long) item->size, item->name_change.name, item->name_change.old.id, item->name_change.new.id, item->name_change.old.flags, item->name_change.new.flags); break; case KDBUS_ITEM_ID_ADD: case KDBUS_ITEM_ID_REMOVE: printf(" +%s (%llu bytes) id=%llu flags=%llu\n", enum_MSG(item->type), (unsigned long long) item->size, (unsigned long long) item->id_change.id, (unsigned long long) item->id_change.flags); break; default: printf(" +%s (%llu bytes)\n", enum_MSG(item->type), item->size); break; } } if ((char *)item - ((char *)msg + msg->size) >= 8) printf("invalid padding at end of message\n"); printf("\n"); }
int machine_bind_text(Code stmt,int index,char * ch) { return msg_id(sqlite3_bind_text((sqlite3_stmt*)stmt,index, ch,G_strlen( ch),0));}
int machine_bind_int(Code stmt,int index,int value) { return msg_id(sqlite3_bind_int((sqlite3_stmt*) stmt,index++,value));}
int machine_install_callback(Pointer g_db,char * name,int nargs,Pointer gfunction) { return msg_id(sqlite3_create_function_v2((sqlite3 *) g_db, name,nargs,SQLITE_UTF8 ,0, (xFunc) gfunction,0,0,0)); }
void CassDriver::Retrieve( std::tr1::function<void(bool success, Wrapper* data)> cob, const std::string& receiver_id, Wrapper* data_wrapper) { CassStatement* statement = cass_prepared_bind(select_prepared_); cass_statement_bind_string(statement, 0, cass_string_init(receiver_id.c_str())); cass_statement_set_paging_size(statement, FLAGS_page_size); CassFuture* future = cass_session_execute(session_, statement); auto retrieve_cb = [](CassFuture* future, void* data) { CassError rc = cass_future_error_code(future); Wrapper* wrapper = (Wrapper*)data; if (rc == CASS_OK) { const CassResult* result = cass_future_get_result(future); if (cass_result_row_count(result)) { CassIterator* iterator = cass_iterator_from_result(result); CassString cass_receiver, cass_time, cass_msg_id, cass_group_id, cass_msg, cass_sender; while (cass_iterator_next(iterator)) { const CassRow* row = cass_iterator_get_row(iterator); cass_value_get_string(cass_row_get_column(row, 0), &cass_receiver); cass_value_get_string(cass_row_get_column(row, 1), &cass_time); cass_value_get_string(cass_row_get_column(row, 2), &cass_msg_id); cass_value_get_string(cass_row_get_column(row, 3), &cass_group_id); cass_value_get_string(cass_row_get_column(row, 4), &cass_msg); cass_value_get_string(cass_row_get_column(row, 5), &cass_sender); std::string receiver(cass_receiver.data, cass_receiver.length); std::string time(cass_time.data, cass_time.length); std::string msg_id(cass_msg_id.data, cass_msg_id.length); std::string group_id(cass_group_id.data, cass_group_id.length); std::string msg(cass_msg.data, cass_msg.length); std::string sender(cass_sender.data, cass_sender.length); boost::shared_ptr<Message> message(new Message()); message->__set_receiver_id(receiver); message->__set_timestamp(time); message->__set_msg_id(msg_id); message->__set_group_id(group_id); message->__set_msg(msg); message->__set_sender_id(sender); wrapper->pmsgs->push_back(message); } cass_bool_t has_more_pages = cass_result_has_more_pages(result); if (has_more_pages) { cass_statement_set_paging_state(wrapper->statement, result); (wrapper->func)(); } else { cass_statement_free(wrapper->statement); CassStatement* statement = cass_prepared_bind(wrapper->this_obj->delete_prepared_); cass_statement_bind_string(statement, 0, cass_receiver); CassFuture* delete_future = cass_session_execute(wrapper->this_obj->session_, statement); cass_future_free(delete_future); cass_statement_free(statement); (wrapper->cob)(true, wrapper); } cass_iterator_free(iterator); } else { cass_statement_free(wrapper->statement); (wrapper->cob)(true, wrapper); } cass_result_free(result); } else { cass_statement_free(wrapper->statement); wrapper->this_obj->PrintError(future); (wrapper->cob)(false, wrapper); } }; data_wrapper->this_obj = this; data_wrapper->cob = cob; data_wrapper->statement = statement; data_wrapper->func = [=]() { CassFuture* future = cass_session_execute(session_, statement); cass_future_set_callback(future, retrieve_cb, data_wrapper); cass_future_free(future); }; cass_future_set_callback(future, retrieve_cb, data_wrapper); cass_future_free(future); }
int open_machine_layer(char * name,Pointer g_db) { char complete_name[400]; G_strcpy(complete_name,DirOrigin); G_strcat(complete_name,name); return msg_id(sqlite3_open(complete_name,(sqlite3 **)g_db));}