示例#1
0
    void ScanFolderPrefPage::loadSettings()
    {
        kcfg_actionMove->setEnabled(!ScanFolderPluginSettings::actionDelete());

        m_group->clear();

        GroupManager* gman = m_plugin->getCore()->getGroupManager();
        QStringList grps;
        GroupManager::Itr it = gman->begin();
        int current = 0;
        int cnt = 0;
        //now custom ones
        while (it != gman->end())
        {
            if (it->second->groupFlags() & Group::CUSTOM_GROUP)
            {
                grps << it->first;
                if (it->first == ScanFolderPluginSettings::group())
                    current = cnt;
                cnt++;
            }
            ++it;
        }
        m_group->addItems(grps);
        m_group->setEnabled(ScanFolderPluginSettings::addToGroup() && grps.count() > 0);
        m_group->setCurrentIndex(current);
        kcfg_addToGroup->setEnabled(grps.count() > 0);

        m_folders->clear();
        folders = ScanFolderPluginSettings::folders();
        foreach (const QString& f, folders)
        {
            m_folders->addItem(new QListWidgetItem(QIcon::fromTheme("folder"), f));
        }
void DesktopSortingStrategy::sortItems(ItemList &items)
{
    GroupManager *gm = qobject_cast<GroupManager *>(parent());
    qStableSort(items.begin(), items.end(), (gm && gm->separateLaunchers()) ?
                DesktopSortingStrategy::lessThanSeperateLaunchers :
                DesktopSortingStrategy::lessThan);
}
bool SymetricSimilarity::group(GroupTask *task, SampleList &samples, GroupManager &groupManager, AlgorithmContext &context)
{
	// extract context
    m_threshold = atoi(context.value("threshold").c_str());
    m_compareTrait = context.value("trait");
    m_compareTraitKey = context.value("traitKey");

	// for each sample try to find appropriate group for it
	for(ExploitSampleHandle sample : samples) {
		// if no groups found (first sample), create immediately group for it
		if(groupManager.count() == 0) {
			int groupId = groupManager.createGroup();
			groupManager.add(groupId, sample, 100);

			task->incrementFoundGroups();
			task->incrementGroupedsamples();

			// export status
			task->updateStatus();
			SystemLogger::instance()->exportStatus(task);

			continue;
		}

		// for each existing group, compare its leader and current sample
		ResemblenceVector resemblenceVector;
		for(int i = 0; i < groupManager.count(); ++i) {
			int resemblence;
            if(compare(groupManager.leader(i), sample, resemblence) == true)
				resemblenceVector.push_back(make_pair(i, resemblence));
		}

		sort(resemblenceVector.begin(), resemblenceVector.end(), compareResemblence);

		if(resemblenceVector.size() > 0) {
			int group = resemblenceVector[resemblenceVector.size() - 1].first;
			int resemblence = resemblenceVector[resemblenceVector.size() - 1].second;
			LOG("adding sample [%s] to group [%d]\n", sample->info()->name().c_str(), group);
			groupManager.add(group, sample, resemblence);
		}
		else {
			int groupId = groupManager.createGroup();
			LOG("creating new group [%d] for sample [%s]\n", groupId, sample->info()->name().c_str());
			groupManager.add(groupId, sample, 100);

			task->incrementFoundGroups();
		}

		task->incrementGroupedsamples();

		// export status
		task->updateStatus();
		SystemLogger::instance()->exportStatus(task);
	}

	return true;
}
示例#4
0
    void TorrentCreatorDlg::loadGroups()
    {
        GroupManager* gman = core->getGroupManager();
        GroupManager::Itr it = gman->begin();

        QStringList grps;

        //First default group
        grps << i18n("All Torrents");

        //now custom ones
        while (it != gman->end())
        {
            if (!it->second->isStandardGroup())
                grps << it->first;
            ++it;
        }

        m_group->addItems(grps);
    }
示例#5
0
Dictionary* BuildTheGroupManagerDictionary(Network* net)
{
GroupManager *gmgr;
Dictionary* groupManagers = new Dictionary;

    boolean isMacro = net->isMacro();
    if ((!isMacro) || (ProcessGroupManager::SupportsMacros())) {
	gmgr = new ProcessGroupManager(net);
	groupManagers->addDefinition (gmgr->getManagerName(), gmgr);
    }

    if ((!isMacro) || (PageGroupManager::SupportsMacros())) {
	gmgr = new PageGroupManager(net);
	groupManagers->addDefinition (gmgr->getManagerName(), gmgr);
    }

    if ((!isMacro) || (AnnotationGroupManager::SupportsMacros())) {
	gmgr = new AnnotationGroupManager(net);
	groupManagers->addDefinition (gmgr->getManagerName(), gmgr);
    }
    return groupManagers;
}
void AddHelpText(sf::RenderWindow &App, sf::Font &f, GroupManager &gm)
{
    sf::View v = App.GetView();
    sf::Vector2f center = v.GetCenter(), half = v.GetHalfSize();

    string s;
    s = "Operations available:\n";
    s += "Move:              Left, Right, Up, Down\n";
    s += "Speed:             s (decrease), d (increase)\n";
    s += "Step size:         w (decrease), e (increase)\n";
    s += "Zoom:              z (in), x (out)\n";
    s += "Steps mode:        a (switch between modes)\n";
    s += "Quit:              Esc\n";
    sf::String text(s, f, 12);
    text.SetColor(sf::Color(128, 200, 40));
    text.Move(center.x - half.x + half.x/20, center.y - half.y + half.y/20);
    App.Draw(text);


    ostringstream step_per_second_str;
    step_per_second_str << "~" << step_per_second << "\n";
    ostringstream step_time_str;
    step_time_str << "~" << step_time << "\n";
    ostringstream framerate_str;
    framerate_str << 1.0/App.GetFrameTime() << "\n";
    ostringstream step_size_str;
    step_size_str << gm.GetStepSize() << "\n";

    s = "Steps per second: ";
    s += step_per_second_str.str() ;
    s += "Step time: ";
    s += step_time_str.str();
    s += "Framerate: ";
    s += framerate_str.str();
    s += "Step size: ";
    s += step_size_str.str();
    s += "Steps mode: ";
    switch (step_mode)
    {
        case SM_HARD_STEPS_CNT: s += "SM_HARD_STEPS_CNT\n"; break;
        case SM_FREE_STEPS_CNT: s += "SM_FREE_STEPS_CNT\n"; break;
        default: break;
    }

    sf::String inf(s.c_str(), f, 20);
    inf.SetColor(sf::Color(230, 200, 180));
    inf.Move(center.x - half.x + half.x/20, center.y + half.y - half.y/2);
    App.Draw(inf);
}
void BuildMechanism(CompManager &cm, GroupManager &gm)
{
    XMLLoader::SetManagers(&cm, &gm);
    XMLSaver::SetManagers(&cm, &gm);

    bool i_want_load_this = false;
    string mname = "invars";

    if (i_want_load_this)
        XMLLoader::Load("xmls\\"+mname+".xml");
    else
    {
    cm.AddSegment("Ground", 10000, 0);

    cm.AddConnectorSlidingD("s0c1","Ground",0.0,-0.150, pi/2);
    cm.AddConnectorTurnD("s0c2", "Ground", 0.20,0.10);
    cm.AddConnectorTurnD("s0c3", "Ground", 0.20,0.10);

    cm.AddSegment("s1");
    cm.AddConnectorTurnD("s1c2", "s1", 0.0,0.0);
    cm.AddConnectorSliding("s1c1","s1",0.0,0.0, 0);
    cm.AddConnectorSliding("s1c3","s1",0.0,0.0, pi/2);
    cm.AddConnectorTurnD("s1c4", "s1", 0.0,0.0);

    cm.AddSegment("s2");
    cm.AddConnectorTurn("s2c1", "s2", 0, 0.0);
    cm.AddConnectorTurn("s2c2", "s2", 0.3, 0.0);
    cm.AddConnectorTurn("s2c3", "s2", 0.3, 0.0);


    cm.AddSegment("s3");
    cm.AddConnectorTurn("s3c1", "s3", 0, 0.0);
    cm.AddConnectorTurn("s3c2", "s3", 0.3, 0.0);


    cm.AddSegment("s4");
    cm.AddConnectorTurn("s4c1", "s4", 0, 0);
    cm.AddConnectorTurn("s4c2", "s4", 0.3, 0);
    cm.AddConnectorTurn("s4c3", "s4", 0.3, 0);


    cm.AddSegment("s5");
    cm.AddConnectorTurn("s5c1", "s5", 0.0, 0);
    cm.AddConnectorTurn("s5c2", "s5", 0.3, 0);

    cm.AddSegment("s6");
    cm.AddConnectorTurn("s6c1", "s6", 0, 0);
    cm.AddConnectorSliding("s6c2", "s6", 0, 0, 0);

    cm.AddSegment("s7");
    cm.AddConnectorTurn("s7c1", "s7", 0, 0);
    cm.AddConnectorSliding("s7c2", "s7", 0, 0, 0);
    cm.AddConnectorSliding("s7c3", "s7", 0, 0, 0);

    cm.AddSegment("s8");
    cm.AddConnectorTurn("s8c1", "s8", 0, 0);
    cm.AddConnectorSliding("s8c2", "s8", 0, 0, 0);

    cm.AddSegment("s9");
    cm.AddConnectorTurn("s9c1", "s9", 0, 0);
    cm.AddConnectorSliding("s9c2", "s9", 0, 0, 0);


    cm.AddKPSliding("O", "s0c1", "s1c1");
    cm.AddKPTurn("A", "s1c2", "s2c1");
    cm.AddKPTurn("B", "s2c2", "s3c1");
    cm.AddKPTurn("S", "s3c2", "s0c2");

    cm.AddKPTurn("E", "s1c4", "s4c1");
    cm.AddKPTurn("D", "s4c2", "s5c1");
    cm.AddKPTurn("C", "s5c2", "s0c3");

    cm.AddKPSliding("G", "s6c2", "s7c2");
    cm.AddKPTurn("F", "s2c3", "s6c1");
    cm.AddKPTurn("H", "s4c3", "s7c1");

    cm.AddKPSliding("L", "s1c3", "s9c2");
    cm.AddKPTurn("M", "s9c1", "s8c1");
    cm.AddKPSliding("N", "s8c2", "s7c3");
    gm.SetStepSize(0.005);
    gm.SetMinGC(0);
    gm.SetMaxGC(6.28);
    gm.SetJump(true);
    gm.BuildEdgesSets();
    gm.AddFirstGroupByName("O", "Ground", "s1");
    gm.Analyze();

        XMLSaver::Save("xmls\\"+mname+".xml");
    }
}
void ProcessAppEvents(sf::RenderWindow &App, sf::View &v, GroupManager &gm)
{
    sf::Event Event;
    while (App.GetEvent(Event))
    {
        switch (Event.Type)
        {
            case sf::Event::Closed: App.Close(); break;
            case sf::Event::KeyPressed:
            {
                switch (Event.Key.Code)
                {
                    case sf::Key::Escape: App.Close(); break;
                    case sf::Key::Right:
                    case sf::Key::Left:
                    case sf::Key::Up:
                    case sf::Key::Down:
                    {
                        const int step = 5;
                        v = App.GetView();
                        int hor = 0, ver = 0;
                        if (Event.Key.Code == sf::Key::Left)
                            hor+=step;
                        if (Event.Key.Code == sf::Key::Right)
                            hor-=step;
                        if (Event.Key.Code == sf::Key::Up)
                            ver+=step;
                        if (Event.Key.Code == sf::Key::Down)
                            ver-=step;
                        v.Move(hor, ver);
                        App.SetView(v);
                        break;
                    }
                    case sf::Key::S:
                    case sf::Key::D:
                    {
                        //if (Event.Key.Code == sf::Key::S)
                        //    wanna_step_per_second-= wanna_step_per_second/10 - 1;
                        //if (Event.Key.Code == sf::Key::D)
                        //    wanna_step_per_second+= wanna_step_per_second/10 + 1;
                        //if (wanna_step_per_second <= 0)
                        //    step_per_second = 1;
                        //if (wanna_step_per_second >= 250)
                        //    step_per_second = 250;
                        //step_time = 1.0/wanna_step_per_second;
                        break;
                    }
                    case sf::Key::W:
                    case sf::Key::E:
                    {
                        if (Event.Key.Code == sf::Key::E)
                            gm.SetStepSize(gm.GetStepSize() + 0.005);
                        if (Event.Key.Code == sf::Key::W)
                            gm.SetStepSize(gm.GetStepSize() - 0.005);
                        break;
                    }
                    case sf::Key::Z:
                    case sf::Key::X:
                    {
                        if (Event.Key.Code == sf::Key::Z)
                            v.Zoom(1.01);
                        if (Event.Key.Code == sf::Key::X)
                            v.Zoom(1.0/1.01);
                        break;
                    }
                    case sf::Key::A:
                    {
                        step_mode = (STEP_MODE) ((int)SM_HARD_STEPS_CNT + (int)SM_FREE_STEPS_CNT - step_mode);
                        break;
                    }
                    default: break;
                }
                break;
            }
            case sf::Event::Resized:
            {
                int h = Event.Size.Height;
                int w = Event.Size.Width;
                v.SetHalfSize(w/2, h/2);
                break;
            }
            default: break;
        }
    }
}
示例#9
0
int main(int nargs, char **args) {

	if(nargs != 2) {
		printf("Give input file\n");
		return 0;
	}


	/************************************************************************
	 * Read the pattern points
	 ************************************************************************/
	const char *fIn = args[1];
	std::vector<cv::Point> extracted;
	bool ret = readConfig(std::string(fIn), extracted);

	if(!ret) {
		printf("Could not read input file '%s'\n", fIn);
		return 0;
	}


	/******************************************
	 * Print the read coordinates
	 ******************************************/
	printf("*****************************************\n");
	printf("* Reading points\n");
	printf("*****************************************\n");
	for(size_t i = 0; i < extracted.size(); ++i) {

		const int x = extracted[i].x;
		const int y = extracted[i].y;

		printf("%d, %d\n", x, y);
	}
	printf("\n");


	/************************************************************************
	 * Create the pupil centre
	 ************************************************************************/
	cv::Point pupil_centre(400, 300);


	/************************************************************************
	 * Draw the scenario in ASCII graphics
	 ************************************************************************/
	draw(extracted, pupil_centre);


	GroupManager grp;
	bool success = grp.identify(extracted, pupil_centre);

	if(success) {
		const std::vector<Configuration> &configs = grp.getConfigurations();

		for(size_t i = 0; i < configs.size(); ++i) {

			const std::vector<group::Element> &elements = configs[i].elements;
			std::vector<group::Element>::const_iterator elit = elements.begin();
			std::vector<group::Element>::const_iterator end = elements.end();

			printf("\nConfiguration %d, err = %.2f\n", (int)(i + 1), configs[i].err);

			while(elit != end) {
				printf("  %d", elit->label);
				++elit;
			}

		}

		printf("\n\nAnd the best configuration is:\n");

		const Configuration &config_best = grp.getBestConfiguration();

		std::vector<group::Element>::const_iterator elit = config_best.elements.begin();

		for(; elit != config_best.elements.end(); ++elit) {
			printf("%d  ", elit->label);
		}
		printf("\n\n");

	}
	else {
		printf("identification failed\n");
	}


	return EXIT_SUCCESS;
}
示例#10
0
int _tmain(int argc, _TCHAR* argv[])
{	
	// Initial manager setup
	UserManager userManager;
	ServerManager serverManager;
	GroupManager groupManager;
	Session session;
	session.userName = NULL;
	session.password = NULL;

	// Plumbing.
	LSA::SetUserManager(&userManager);
	LSA::SetGroupManager(&groupManager);
	LSA::SetServerManager(&serverManager);

	AD::SetUserManager(&userManager);
	AD::SetGroupManager(&groupManager);
	AD::SetServerManager(&serverManager);

	// So apparently we're a bunch of cavemen/cavewomen living in the stone age.
	// As such we have to roll our own UNIX-style command line parsing.
	// This is guaranteed to get ugly fast.
	// TODO: Create an options parsing static class to take care of this for us.

	DWORD i;
	for(i = 1; i < argc; i++) 
	{
		if(argv[i][0] == '-') 
		{
			TCHAR *option = argv[i]+1; 
			// Found a flag that needs an argument.
			if(lstrcmp(option, L"d") == 0) 
			{
				// Is the next argument empty or another flag? If so ya dun goofed.
				if(i+1 >= argc || argv[i+1][0] == '-') 
				{
					Help::Usage(argv[0]);
					exit(1);
				}
				else
				{
					Config::domain = argv[i+1];
				}
			}
			if(lstrcmp(option, L"u") == 0) 
			{
				if(i+1 >= argc || argv[i+1][0] == '-') 
				{
					Help::Usage(argv[0]);
					exit(1);
				}
				else
				{
					session.userName = argv[i+1];
				}
			}
			if(lstrcmp(option, L"p") == 0) 
			{
				if(i+1 >= argc || argv[i+1][0] == '-') 
				{
					Help::Usage(argv[0]);
					exit(1);
				}
				else
				{
					session.password = argv[i+1];
				}
			}
			if(lstrcmp(option, L"t") == 0) 
			{
				if(i+1 >= argc || argv[i+1][0] == '-') 
				{
					Help::Usage(argv[0]);
					exit(1);
				}
				else
				{
					Config::machine = argv[i+1];
				}
			}
			if(lstrcmp(option, L"c") == 0) 
			{
				if(i+1 >= argc || argv[i+1][0] == '-') 
				{
					Help::Usage(argv[0]);
					exit(1);
				}
				else
				{
					Config::csvOutput = true;
					Config::csvFile = argv[i+1];
				}
			}
			if(lstrcmp(option, L"b") == 0) 
			{
				if(i+1 >= argc || argv[i+1][0] == '-') 
				{
					Help::Usage(argv[0]);
					exit(1);
				}
				else
				{
					Config::numBruteTries = _wtoi(argv[i+1]);
				}
			}
			if(lstrcmp(option, L"l") == 0)
			{
				if(i+1 >= argc || argv[i+1][0] == '-')
				{
					Help::Usage(argv[0]);
					exit(1);
				}
				else
				{
					Config::connectLSA = true;

					if(lstrcmpi(argv[i+1], L"group") == 0)
					{
						Config::sidType = SidTypeGroup;
					}
					else if(lstrcmpi(argv[i+1], L"user") == 0)
					{
						Config::sidType = SidTypeUser;
						Config::machineAccountHack = false;
					}
					else if(lstrcmpi(argv[i+1], L"machine") == 0)
					{
						// As far as I can tell enumerable machine accounts
						// through LSA are just regular accounts marked with
						// a dollar sign at the end, so we use SidTypeUser
						// instead of SidTypeComputer, which returns nothing.
						Config::sidType = SidTypeUser;
						// TODO: Fix LSA enumeration so that we don't need this flag.
						Config::machineAccountHack = true;
					}
				}
			}
			if(lstrcmp(option, L"n") == 0)
			{
				Config::connectWNet = true;
			}
			if(lstrcmp(option, L"i") == 0)
			{
				Config::printUserInfo = true;
			}
			if(lstrcmp(option, L"s") == 0)
			{
				Config::printServerInfo = true;
			}
			if(lstrcmp(option, L"g") == 0)
			{
				Config::printGroupInfo = true;
			}
		}
	} 
	// End options parsing.
	//AD::SetHost(L"");
	//AD::GetDN();
	//AD::Login();
	//AD::Enumerate(AD_SEARCH_USER);

	// Console setup
	Util::SetConsoleColor(DEFAULT);

	// Check to make sure run-once conditions have been satisfied.
	if(!Config::printUserNames && !Config::printUserInfo && !Config::printServerInfo && !Config::connectWNet && !Config::connectLSA && !Config::printGroupInfo)
	{
		Help::Usage(argv[0]);
		exit(1);
	}
	//Cosmetic new-line; just makes the output look better.

	wprintf(L"\n");

	// Begin fun non-options-parsing stuff here.
	// Make sure to connect session first if needed.

	if(Config::connectWNet)
	{
		if(!session.userName || !session.password)
		{
			Util::Warn(L"Full NetBIOS credentials unspecified, skipping NetBIOS login.\n");
		}
		else if(lstrlen(Config::machine) <= 0)
		{
			Util::Warn(L"No target IP specified, skipping NetBIOS login.\n");
		}
		else
		{
			Util::Notice(L"Connecting via SMB...\n\n");
			session.ConnectWNet(session.userName, session.password, Config::machine);
		}
	}

	if(Config::connectLSA)
	{
		if(lstrlen(Config::machine) <= 0)
		{
			Util::Warn(L"No target IP specified, skipping LSA SID brute force.\n");
		}
		else if(!Config::sidType)
		{
			Util::Warn(L"Incorrect or no SID type specified, skipping LSA SID brute force.\n");
		}
		else
		{
			Util::Notice(L"Connecting via LSA...\n\n");
			LSA::OpenPolicy(&session, Config::machine);
			LSA::EnumerateSIDs(&session, Config::sidType);

			if(Config::csvOutput && lstrlen(Config::csvFile) > 0)
			{
				switch(Config::sidType)
				{
				case SidTypeUser:
					if(!Config::machineAccountHack)
					{
						userManager.DumpToCSV();
					}
					else
					{
						serverManager.DumpToCSV();
					}
					break;
				case SidTypeGroup:
					groupManager.DumpToCSV();
				default:
					break;
				}
			}
		}
	}

	if(Config::printUserInfo)
	{
		// We send the machine instead of the domain on purpose,
		// since it's faster than sending the name of the domain
		// and the domain name can be a faulty method from time to time.

		if(lstrlen(Config::machine) <= 0)
		{
			Util::Warn(L"No target IP specified, skipping NetBIOS user enumeration.\n");
		}
		else
		{
			Util::Notice(L"Printing user info now\n\n");
			userManager.EnumerateUserInformation(Config::machine); 

			if(Config::csvOutput && lstrlen(Config::csvFile) > 0)
			{
				userManager.DumpToCSV();
			}
		}
	}

	if(Config::printGroupInfo)
	{
		// Fairly sure we do the same as with the user information;
		// which is to say we send directly to the DC instead of using a
		// domain name.

		if(lstrlen(Config::machine) <= 0)
		{
			Util::Warn(L"No Target IP specified, skipping NetBIOS group enumeration.\n");
		}
		else
		{
			Util::Notice(L"Printing group info now\n");
			groupManager.EnumerateGroups(Config::machine);
			if(Config::csvOutput && lstrlen(Config::csvFile) > 0)
			{
				groupManager.DumpToCSV();
			}
		}
	}

	if(Config::printServerInfo)
	{
		// Once again pointing directly at the DC appears to
		// be superior to the option of supplying a domain name.
		if(lstrlen(Config::machine) <= 0)
		{
			Util::Warn(L"No target IP specified, skipping NetBIOS server enumeration.\n");
		}
		else
		{
			Util::Notice(L"Printing server info now...\n\n");
			serverManager.EnumerateServerInformation(Config::machine);
			if(Config::csvOutput && lstrlen(Config::csvFile) > 0)
			{
				serverManager.DumpToCSV();
			}
		}
	}

	if(Config::connectWNet && lstrlen(Config::machine) > 0)
	{
		session.DisconnectWNet(Config::machine);
	}

	Util::SetConsoleColor(SYSTEM_DEFAULT);

	// Be free memory. Be free as a bird.
	userManager.Clear();
	groupManager.Clear();
	serverManager.Clear();
	return 0;
}