JBoolean JGetSVNEntryType ( const JCharacter* url, JString* type, JString* error ) { type->Clear(); error->Clear(); JString cmd = "svn info --xml " + JPrepArgForExec(url); JProcess* p; int fromFD, errFD; JError err = JProcess::Create(&p, cmd, kJIgnoreConnection, NULL, kJCreatePipe, &fromFD, kJCreatePipe, &errFD); if (!err.OK()) { err.ReportIfError(); return kJFalse; } p->WaitUntilFinished(); if (p->SuccessfulFinish()) { xmlDoc* doc = xmlReadFd(fromFD, NULL, NULL, XML_PARSE_NOBLANKS | XML_PARSE_NOCDATA); close(fromFD); if (doc != NULL) { xmlNode* root = xmlDocGetRootElement(doc); if (root != NULL && strcmp((char*) root->name, "info") == 0 && strcmp((char*) root->children->name, "entry") == 0) { *type = JGetXMLNodeAttr(root->children, "kind"); return kJTrue; } } } JReadAll(errFD, error, kJTrue); return kJFalse; }
void XDGetBreakpoints::HandleSuccess ( const JString& data ) { XDLink* link = dynamic_cast<XDLink*>(CMGetLink()); xmlNode* root; if (link == NULL || !link->GetParsedData(&root)) { return; } (CMGetLink()->GetBreakpointManager())->SetUpdateWhenStop(kJFalse); JPtrArray<CMBreakpoint> bpList(JPtrArrayT::kForgetAll); // ownership taken by CMBreakpointManager bpList.SetCompareFunction(CMBreakpointManager::CompareBreakpointLocations); bpList.SetSortOrder(JOrderedSetT::kSortAscending); JPtrArray<CMBreakpoint> otherList(JPtrArrayT::kForgetAll); // ownership taken by CMBreakpointManager xmlNode* node = root->children; JString type, idStr, fileName, lineStr, state; while (node != NULL) { type = JGetXMLNodeAttr(node, "type"); if (type == "line") { idStr = JGetXMLNodeAttr(node, "id"); fileName = JGetXMLNodeAttr(node, "filename"); lineStr = JGetXMLNodeAttr(node, "lineno"); state = JGetXMLNodeAttr(node, "state"); JIndex bpIndex; JBoolean ok = idStr.ConvertToUInt(&bpIndex); assert( ok ); if (fileName.BeginsWith("file://")) { fileName.RemoveSubstring(1, 7); } JIndex lineNumber; ok = lineStr.ConvertToUInt(&lineNumber); assert( ok ); const JBoolean enabled = JI2B(state == "enabled"); CMBreakpoint* bp = new CMBreakpoint(bpIndex, fileName, lineNumber, "", "", enabled, CMBreakpoint::kKeepBreakpoint, "", 0); assert( bp != NULL ); bpList.InsertSorted(bp); if (true) // no way to know if it is temporary -- may be deleted or other status change { (CMGetLink()->GetBreakpointManager())->SetUpdateWhenStop(kJTrue); } } node = node->next; } (CMGetLink()->GetBreakpointManager())->UpdateBreakpoints(bpList, otherList); }
void XDLink::ReceiveMessageFromDebugger() { itsLink->StopTimer(); JString data; const JBoolean ok = itsLink->GetNextMessage(&data); assert( ok ); if (data.IsEmpty() || data.GetFirstCharacter() != '<') { return; } Broadcast(DebugOutput(data, kOutputType)); if (itsInitFinishedFlag) { if (!itsProgramIsStoppedFlag) { itsProgramIsStoppedFlag = kJTrue; Broadcast(ProgramStopped(CMLocation("", 1))); } itsDebuggerBusyFlag = kJFalse; Broadcast(DebuggerReadyForInput()); } xmlDoc* doc = xmlReadMemory(data.GetCString(), data.GetLength(), NULL, NULL, XML_PARSE_NOCDATA); if (doc != NULL) { xmlNode* root = xmlDocGetRootElement(doc); if (root != NULL && strcmp((char*) root->name, "init") == 0) { itsIDEKey = JGetXMLNodeAttr(root, "idekey"); const JString uri = JGetXMLNodeAttr(root, "fileuri"); const JCharacter* map[] = { "idekey", itsIDEKey, "uri", uri }; JString msg = JGetString("ConnectionInfo::XDLink", map, sizeof(map)); Broadcast(UserOutput(msg, kJFalse)); Send("feature_set -n show_hidden -v 1"); Send("step_into"); JString programName; GetProgram(&programName); Broadcast(AttachedToProcess()); Broadcast(SymbolsLoaded(JI2B(uri == itsScriptURI), programName)); itsInitFinishedFlag = kJTrue; itsScriptURI = uri; } else if (root != NULL && strcmp((char*) root->name, "response") == 0) { const JString status = JGetXMLNodeAttr(root, "status"); const JString reason = JGetXMLNodeAttr(root, "reason"); if (status == "break" && reason == "error" && root->children != NULL && root->children->children != NULL && strcmp((char*) root->children->name, "error") == 0 && root->children->children->type == XML_TEXT_NODE) { JString msg = (char*) root->children->children->content; const JString encoding = JGetXMLNodeAttr(root->children, "encoding"); if (encoding == "base64") { msg.DecodeBase64(&msg); } msg += "\n"; Broadcast(UserOutput(msg, kJTrue)); } const JString idStr = JGetXMLNodeAttr(root, "transaction_id"); JUInt id; if (idStr.ConvertToUInt(&id)) { HandleCommandRunning(id); } CMCommand* cmd; if (GetRunningCommand(&cmd)) { itsParsedDataRoot = root; cmd->Finished(JI2B( root->children == NULL || strcmp((char*) root->children->name, "error") != 0)); itsParsedDataRoot = NULL; SetRunningCommand(NULL); if (!HasForegroundCommands()) { RunNextCommand(); } } if (status == "stopping" || status == "stopped") { CancelAllCommands(); XDCloseSocketTask* task = new XDCloseSocketTask(itsLink); assert( task != NULL ); task->Go(); } } xmlFreeDoc(doc); } }