Ejemplo n.º 1
0
// Takes a path and file name like "C:\Folder\Program.exe" and a name like "My Program"
// Makes sure the program is listed in Windows Firewall and its listing is checked, adding and checking it as necessary
// Returns true if the program is listed and checked, false if we weren't able to do it
// When bRemove is TRUE, it removes the application from the exception list
BOOL CFirewall::SetupProgram( const CString& path, const CString& name, BOOL bRemove )
{
	// Make sure the COM interfaces have been accessed
	//if ( ! FwManager ) return FALSE;

	// If the program isn't on the Windows Firewall exceptions list
	BOOL bListed = FALSE;
	if ( ! IsProgramListed( path, &bListed ) ) return FALSE;
	if ( ! bListed && ! bRemove )
	{
		// Add it to the list with a checked checkbox
		if ( ! AddProgram( path, name ) ) return FALSE;
	}
	else if ( bListed && bRemove )
	{
		if ( ! RemoveProgram( path ) ) return FALSE;
		return TRUE;
	}

	// If the program is on the list, but its checkbox isn't checked
	BOOL bEnabled = FALSE;
	if ( ! IsProgramEnabled( path, &bEnabled ) ) return FALSE;
	if ( ! bEnabled )
	{
		// Check the checkbox
		if ( ! EnableProgram( path ) ) return FALSE;
	}

	// The program is listed and checked
	return TRUE;
}
Ejemplo n.º 2
0
void MainHost::SetupGroupContainer()
{
    if(!groupContainer.isNull()) {
        mainContainer->ParkObject( groupContainer );
        groupContainer.clear();
        UpdateSolver(true);
        if(mainWindow)
            mainWindow->mySceneView->viewGroup->ClearViewPrograms();
    }

    ObjectInfo info;
    info.nodeType = NodeType::container;
    info.objType = ObjType::Container;
    info.name = "groupContainer";
    info.forcedObjId = FixedObjId::groupContainer;

    groupContainer = objFactory->NewObject(info).staticCast<Connectables::Container>();
    if(groupContainer.isNull())
        return;

    groupContainer->SetLoadingMode(true);

    groupContainer->LoadProgram(0);
    mainContainer->AddObject(groupContainer);

    QSharedPointer<Connectables::Object> bridge;

    //bridge in
    ObjectInfo in;
    in.name="in";
    in.nodeType = NodeType::bridge;
    in.objType = ObjType::BridgeIn;
    in.forcedObjId = FixedObjId::groupContainerIn;

    bridge = objFactory->NewObject(in);
    groupContainer->AddObject( bridge );
    bridge->SetBridgePinsInVisible(false);
    groupContainer->bridgeIn = bridge;

    //bridge out
    ObjectInfo out;
    out.name="out";
    out.nodeType = NodeType::bridge;
    out.objType = ObjType::BridgeOut;
    out.forcedObjId = FixedObjId::groupContainerOut;

    bridge = objFactory->NewObject(out);
    groupContainer->AddObject( bridge );
    bridge->SetBridgePinsOutVisible(false);
    groupContainer->bridgeOut = bridge;

    //connect with programContainer
    if(!programContainer.isNull()) {
        mainContainer->ConnectObjects(programContainer->bridgeSend, groupContainer->bridgeIn,true);
        mainContainer->ConnectObjects(groupContainer->bridgeOut, programContainer->bridgeReturn,true);
    }

    //bridge send
    ObjectInfo send;
    send.name="send";
    send.nodeType = NodeType::bridge;
    send.objType = ObjType::BridgeSend;
    send.forcedObjId = FixedObjId::groupContainerSend;

    bridge = objFactory->NewObject(send);
    groupContainer->AddObject( bridge );
    bridge->SetBridgePinsOutVisible(false);
    groupContainer->bridgeSend = bridge;

    //bridge return
    ObjectInfo retrn;
    retrn.name="return";
    retrn.nodeType = NodeType::bridge;
    retrn.objType = ObjType::BridgeReturn;
    retrn.forcedObjId = FixedObjId::groupContainerReturn;

    bridge = objFactory->NewObject(retrn);
    groupContainer->AddObject( bridge );
    bridge->SetBridgePinsInVisible(false);
    groupContainer->bridgeReturn = bridge;

    //connect with hostContainer
    if(!hostContainer.isNull()) {
        mainContainer->ConnectObjects(groupContainer->bridgeSend, hostContainer->bridgeIn,true);
        mainContainer->ConnectObjects(hostContainer->bridgeOut, groupContainer->bridgeReturn,true);
    }

    connect(programsModel, SIGNAL(GroupChanged(QModelIndex)),
            groupContainer.data(), SLOT(SetProgram(QModelIndex)));
    connect(programsModel, SIGNAL(GroupDelete(QModelIndex)),
            groupContainer.data(), SLOT(RemoveProgram(QModelIndex)));
    connect(this,SIGNAL(Rendered()),
            groupContainer.data(), SLOT(PostRender()));

    emit groupParkingModelChanged(&groupContainer->parkModel);

    if(projectContainer)
        projectContainer->childContainer=groupContainer;
    if(programContainer) {
        groupContainer->childContainer=programContainer;
        programContainer->parentContainer=groupContainer;
    }

    groupContainer->SetLoadingMode(false);
    groupContainer->UpdateModificationTime();
    SetSolverUpdateNeeded();
}