void MvcpThread::run() { mvcp_parser parser = mvcp_parser_init_remote( const_cast<char*>(m_address.toUtf8().constData()), m_port); mvcp_response response = mvcp_parser_connect(parser); if (response) { mvcp lmvcp = mvcp_init(parser); mvcp_response_close(response); int command = COMMAND_INVALID; QObject* parameters = 0; m_mutex.lock(); if (!m_commands.isEmpty()) { parameters = m_commands.takeFirst(); command = parameters->property("command").toInt(); } m_mutex.unlock(); while (!m_quit) { if (parameters) { switch (command) { case COMMAND_ULS: do_uls(lmvcp, parameters); break; case COMMAND_CLS: do_cls(lmvcp, parameters); break; case COMMAND_USTA: do_usta(lmvcp, parameters); break; default: break; } } m_mutex.lock(); while (!m_quit && m_commands.isEmpty()) m_cond.wait(&m_mutex); if (!m_commands.isEmpty()) { parameters = m_commands.takeFirst(); command = parameters->property("command").toInt(); } m_mutex.unlock(); } mvcp_close(lmvcp); } mvcp_parser_close(parser); }
else { beep( ); } } } return mvcp_ok; } /** Entry point for main menu. */ void client_run( client this ) { this->dv = mvcp_init( this->parser ); if ( mvcp_connect( this->dv ) == mvcp_ok ) { pthread_create( &this->thread, NULL, client_status_thread, this ); client_run_menu( this, &connected_menu ); this->terminated = 1; pthread_join( this->thread, NULL ); this->terminated = 0; } else { printf( "Unable to connect." ); wait_for_any_key( "" ); } mvcp_close( this->dv );