Exemple #1
0
UdpSocket::UdpSocket(QObject *parent)
    : QObject(parent)
{
    connect(&socket, SIGNAL(readyRead()), this, SLOT(processPendingData()));

    timer.setInterval(3000);
    timer.start();
    connect(&timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));

}
Exemple #2
0
void XDNet::processResponse(QDomElement& root)
{
  QString cmd = root.attribute("command");

  if((cmd == "step_into") ||
      (cmd == "step_over") ||
      (cmd == "step_out") ||
      (cmd == "run"))
  {
    if((root.attribute("status") == "break"))
    {
      if(root.attribute("reason") == "error")
      {
        processError(root.firstChild().toElement());
      }

      requestStack();
      requestBreakpointList();
    }
    else if(root.attribute("status") == "stopped")
    {
      //nothing...
    }
    else
    {
      error(QString("Unknown error\ncommand: ") + cmd +
            "\nstatus: " + root.attribute("status") +
            "\nreason: " + root.attribute("reason"));
    }
  }
  else if(cmd == "stack_get")
  {
    QDomNodeList list = root.elementsByTagName("stack");
    QDomElement st;
    DebuggerStack* stack = new DebuggerStack();
    for(uint i = 0; i < list.count(); i++)
    {
      st = list.item(i).toElement();
      int level = st.attributeNode("level").value().toInt();
      int line = st.attributeNode("lineno").value().toInt();

      KURL file = st.attributeNode("filename").value();
      QString where = st.attributeNode("where").value();

      if((where == "{main}") || (where == "include"))
      {
        where = file.path() + "::main()";
      }

      //to local filepath
      QString localFile;

      SiteSettings* site = ProtoeditorSettings::self()->currentSiteSettings();
      if(site) 
      {
        localFile = site->localBaseDir()
                            + file.path().remove(0, site->remoteBaseDir().length());
      }
      else
      {
        localFile = file.path();
      }
      stack->insert(level, localFile, line, where);
    }

    //request global/local vars
    //requestVariables(stack->bottomExecutionPoint()->id(), XDNet::GLOBAL_SCOPE);
    //requestVariables(stack->topExecutionPoint()->id(), XDNet::LOCAL_SCOPE);


    //update stack
    m_debugger->updateStack(stack);

    emit sigStepDone();

    processPendingData();
  }
  else if(cmd == "context_get")
  {
    QDomNodeList list = root.childNodes();
    XDVariableParser p;

    VariablesList_t* array = p.parse(list);

    if(root.attributeNode("transaction_id").value().toInt() == LocalScopeId)
    {
      m_debugger->updateVariables(array, false);
    }
    else if(root.attributeNode("transaction_id").value().toInt() == GlobalScopeId)
    {
      if(root.attributeNode("transaction_id").value().toInt() ==
          GlobalScopeId && m_debugger->settings()->sendSuperGlobals())
      {
        m_globalVars = array;
      }
      else
      {
        m_debugger->updateVariables(array, true);
      }
    }
  }
  else if(cmd == "property_get")
  {
    QDomNode nd = root.firstChild();
    XDVariableParser p;

    Variable* var = p.parse(nd);
    if(root.attributeNode("transaction_id").value().toInt() == SuperGlobalId)
    {
      m_globalVars->append(var);
      m_superglobalsCount--;

      if(m_superglobalsCount == 0)
      {
        m_debugger->updateVariables(m_globalVars, true);
      }
    }
    else
    {
      m_debugger->updateWatch(var);
    }
  }
  else if((cmd == "stop") ||
          (cmd == "breakpoint_remove") ||
          (cmd == "stdout") ||
          (cmd == "stderr"))
  {
    //nothing..
  }
  else if((cmd == "breakpoint_set") || (cmd == "breakpoint_update"))
  {
    requestBreakpointList();
  }
  else if(cmd == "breakpoint_list")
  {
    /*
    <response command="breakpoint_list" transaction_id="1">
      <breakpoint type="line" filename="file:///usr/local/apache/htdocs/texto.php"
        lineno="9" state="enabled" id="157470001">
      </breakpoint>
      <breakpoint type="line" filename="file:///usr/local/apache/htdocs/texto.php" lineno="10" state="enabled" id="157470002">
      </breakpoint>
    </response>

    */
    QDomNodeList list = root.elementsByTagName("breakpoint");
    QDomElement e;
    for(uint i = 0; i < list.count(); i++)
    {
      e = list.item(i).toElement();
      int id = e.attributeNode("id").value().toInt();
      QString filePath = KURL(e.attributeNode("filename").value()).path();
      int line = e.attributeNode("lineno").value().toInt();
      QString state = e.attributeNode("state").value();
      int hitCount = e.attributeNode("hit_count").value().toInt();
      int skip = e.attributeNode("hit_value").value().toInt();
      QString condition = e.attributeNode("condition").value();

      m_debugger->updateBreakpoint(id, filePath, line, state, hitCount, skip, condition);
    }
  }
  else
  {
    error(QString("Unknow network packet: ") + cmd);
  }
}