Esempio n. 1
0
  void DisplayProcess::Execute(const wxString& command)
  {
    if (!tctrl)
    {
      return;
    }

    wxProcess *process = new wxProcess(wxPROCESS_REDIRECT);
    //long pid =
      wxExecute(command, wxEXEC_ASYNC, process);
    process->Redirect();

    if (process)
    {
      wxString log;
      wxInputStream *msg = process->GetInputStream();

      wxTextInputStream tStream(*msg);
      while (!msg->Eof())
      {
        log = tStream.ReadLine();
        tctrl->AppendText(log + wxT("\n"));
        tctrl->ShowPosition(tctrl->GetLastPosition());
      }
      tctrl->AppendText(wxT("Finished!\n"));
    }
    else {
      tctrl->AppendText(wxT("FAIL: Command" + command + " could not be run!\n"));
    }
  }
/*This function is called from thread context, where the only job is to process each packet from list */
int ISocketCommunication::Socket_ProcessInboundPackets()
{
  int iPktCnt;
  std::shared_ptr<IPacket> packet;
  
  if(sock_fd <= 0)  {
    return -1; /* socket has not been initialized, hence return with error.. */
  }
  
  try
  {
    while(1)  {
                              
      m_pMutexReadCondwait->lock();
    
      while( ( m_InboundPacket.empty() ) && m_bReadyToRead_InBndPkts) {
     
        m_pMutexReadCondwait->mutex_cond_wait();
      }
      m_bReadyToRead_InBndPkts  = false;
      iPktCnt = m_InboundPacket.size();
    
      m_pMutexReadCondwait->unlock();
                  
      do
      {
        
        packet = *m_InboundPacket.begin();
                
        std::stringstream tStream(packet->packet_data());
        m_pChatEvtCmd->onStreamRecvd(tStream);
        
        m_InboundPacket.pop_front();
        iPktCnt--;
        
        /* for each received packet from client, one heart beat message (hello world + time stamp) is sent to client */
        if(m_eConnectionType == socketCommunication_namespace::eSockServer)  {
          Socket_ServerHeartbeatMsg();
        }
                                                  
      }while(iPktCnt);
        
      m_bReadyToRead_InBndPkts  = true;  
    }
  }
  catch(abi::__forced_unwind&)
    {
      throw;
    }
  catch(...)  {
      
    m_pChatEvtCmd->executeChatEvtCmd(chatevtcmd_namespace::eChildRemoved, nullptr, getpid() );      
    m_pChatEvtCmd->executeChatEvtCmd(chatevtcmd_namespace::eFatalError, nullptr, errno);
    
  }
 
  /*theortically, it should not reach here, except if any exception error happens */ 
  return  0;
}
Esempio n. 3
0
void FileController::copyDataFromFile() {
    QTextStream tStream(file);
    QString fileData = tStream.readAll();
    QStringList list = fileData.split('\n');

    for(int i = 0; i < list.size(); ++i) {
        lines.push_back(list.at(i));
    }

    if(lines.size() >= 1) {
        line = lines[0];
        for(int i = 1; i < lines.size(); ++i) {
            if(i != 1) {src.push_back('\n');}

            src.push_back(lines[i]);
        }
    }

    fileOpenned = 1;
}