void QServerManager::InitServer(const QString& scenarioName)
{
    if(mServer || mEndPoint)
    {
        LOG("Server already exists");
        return;
    }

    if(!PrepareTestCase(scenarioName))
    {
        //LOG();
        emit Finished(false);
        return;
    }

    mEndPoint = new H323EndPoint();
    mServer = new GatekeeperServer(*mEndPoint, mScenario->GetStateMachine());
    ConnectObjects(mServer->GetListener());
    LogManager::Instance().clearLogs();
    LOG("Scenario " + scenarioName + " is opened");
    LOG("server run!");
}
Example #2
0
  Bool ExecuteAutoConnect()
  {
    ConnectOptions options;
    Bool addDynamicsTag = false, inheritDynamicsTag = true;
    GetInt32(CMB_FORCE, options.forcePluginId);
    GetInt32(CMB_TYPE, options.forceType);
    GetInt32(CMB_MODE, options.connectMode);
    GetInt32(EDT_MAXCONN, options.maxConnections);
    GetFloat(EDT_RADIUS, options.radius);
    GetBool(CHK_CLOSED, options.closedChain);
    GetBool(CHK_ADDDYNAMICS, addDynamicsTag);
    GetBool(CHK_COMPOUND, inheritDynamicsTag);

    // Create an InExcludeData for the selection object.
    GeData ge_selection(CUSTOMGUI_INEXCLUDE_LIST, DEFAULTVALUE);
    auto selectionList = static_cast<InExcludeData*>(
      ge_selection.GetCustomDataType(CUSTOMGUI_INEXCLUDE_LIST));
    if (!selectionList)
      return false;

    // Get the active document and object.
    BaseDocument* doc = GetActiveDocument();
    if (!doc)
      return false;
    BaseObject* op = doc->GetActiveObject();
    if (!op)
      return false;

    // Create the root object that will contain the connectors.
    AutoFree<BaseObject> root(BaseObject::Alloc(Onull));
    if (!root)
      return false;

    // Function to create a dynamics tag.
    auto fAddDynamicsTag = [doc] (BaseObject* op, Int32 mode)
    {
      // Create a dynamics tag for the root object if it
      // does not already exist.
      BaseTag* dyn = op->GetTag(ID_RIGIDBODY);
      if (!dyn)
      {
        dyn = op->MakeTag(ID_RIGIDBODY);
        if (dyn) doc->AddUndo(UNDOTYPE_NEW, dyn);
      }

      // Update the parameters.
      if (dyn)
      {
        dyn->SetParameter(RIGID_BODY_HIERARCHY, mode, DESCFLAGS_SET_0);
        doc->AddUndo(UNDOTYPE_CHANGE_SMALL, dyn);
      }
    };

    // This list will contain all objects that should be connected.
    // While collecting, create the dynamics tags.
    maxon::BaseArray<BaseObject*> objects;
    doc->StartUndo();
    for (BaseObject* child=op->GetDown(); child; child=child->GetNext())
    {
      objects.Append(child);
      if (addDynamicsTag && inheritDynamicsTag)
        fAddDynamicsTag(child, RIGID_BODY_HIERARCHY_COMPOUND);
    }
    if (addDynamicsTag && !inheritDynamicsTag)
      fAddDynamicsTag(op, RIGID_BODY_HIERARCHY_INHERIT);

    // If no objects where collected, quit already.
    if (objects.GetCount() <= 0)
    {
      doc->EndUndo();
      doc->DoUndo(false);
      return true;
    }

    // Create the connection objects.
    ConnectObjects(op->GetName() + ": ", objects, options);

    // Fill the selection list and insert the objects.
    for (auto it=options.output.Begin(); it != options.output.End(); ++it)
    {
      (*it)->InsertUnderLast(root);
      doc->AddUndo(UNDOTYPE_NEW, *it);
      selectionList->InsertObject(*it, 0);
    }

    root->SetName(op->GetName() + ": " + root->GetName() + " (" + options.forceName + ")");
    doc->InsertObject(root, nullptr, nullptr);
    doc->AddUndo(UNDOTYPE_NEW, root);

    // Create the selection object.
    if (selectionList->GetObjectCount() > 0)
    {
      BaseObject* selection = BaseObject::Alloc(Oselection);
      if (selection)
      {
        selection->SetParameter(SELECTIONOBJECT_LIST, ge_selection, DESCFLAGS_SET_0);
        selection->SetName(op->GetName() + ": " + options.forceName + " (" + selection->GetName() + ")");
        doc->InsertObject(selection, nullptr, nullptr);
        doc->AddUndo(UNDOTYPE_NEW, selection);
      }
      ActiveObjectManager_SetMode(ACTIVEOBJECTMODE_OBJECT, false);
      doc->SetActiveObject(selection);
    }
    else
      doc->SetActiveObject(root);

    root.Release();
    doc->EndUndo();
    EventAdd();
    return true;
  }