Ejemplo n.º 1
0
void WebyPlugin::getResults(QList<InputData>* id, QList<CatItem>* results)
{
	if (id->last().hasLabel(HASH_WEBSITE)) {
		const QString & text = id->last().getText();
		// This is a website, create an entry for it
		results->push_front(CatItem(text + ".weby", text, HASH_WEBY, getIcon()));
	}

	if (id->count() > 1 && (unsigned int) id->first().getTopResult().id == HASH_WEBY) {
		const QString & text = id->last().getText();
		// This is user search text, create an entry for it
		results->push_front(CatItem(text + ".weby", text, HASH_WEBY, getIcon()));
	}

	// If we don't have any results, add default
	if (results->size() == 0 && id->count() <= 1) {
		const QString & text = id->last().getText();
		if (text != "") {
			QString name = getDefault().name;
			if (name != "")
				results->push_back(CatItem(text + ".weby", name, HASH_WEBY, getIcon()));
		}
	}


}
Ejemplo n.º 2
0
void WebyPlugin::indexFirefox(QString path, QList<CatItem>* items)
{
	QFile file(path);
	if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
		return;

	marks.clear();

	QRegExp regex_url("<a href=\"([^\"]*)\"", Qt::CaseInsensitive);
	QRegExp regex_urlname("\">([^<]*)</A>", Qt::CaseInsensitive);
	QRegExp regex_shortcut("SHORTCUTURL=\"([^\"]*)\"");
	QRegExp regex_postdata("POST_DATA", Qt::CaseInsensitive);

	while (!file.atEnd()) {
		QString line = QString::fromUtf8(file.readLine());
		if (regex_url.indexIn(line) != -1) {
			Bookmark mark;
			mark.url = regex_url.cap(1);

			if (regex_urlname.indexIn(line) != -1) {
				mark.name = regex_urlname.cap(1);

				if (regex_postdata.indexIn(line) != -1) continue;
				if (regex_shortcut.indexIn(line) != -1) {
					mark.shortcut = regex_shortcut.cap(1);
					marks.push_back(mark);
					items->push_back(CatItem(mark.url + ".shortcut", mark.shortcut, HASH_WEBY, getIcon()));
				} else {
					items->push_back(CatItem(mark.url, mark.name, 0, getIcon()));
				}	
			}			
		}
	}
}
Ejemplo n.º 3
0
void VerbyPlugin::getResults(QList<InputData>* inputData, QList<CatItem>* results)
{
	if (inputData->count() == 2)
	{
		if (inputData->first().hasLabel(HASH_DIR))
		{
			results->push_back(CatItem("Properties", "Directory properties", HASH_VERBY, getIconPath() + "properties.png"));
		}
		else if (inputData->first().hasLabel(HASH_FILE))
		{
			results->push_back(CatItem("Open containing folder", "Open containing folder", HASH_VERBY, getIconPath() + "opencontainer.png"));
			results->push_back(CatItem("Properties", "File properties", HASH_VERBY, getIconPath() + "properties.png"));
		}
		else if (inputData->first().hasLabel(HASH_LINK))
		{
			results->push_back(CatItem("Run", "Run", HASH_VERBY, getIconPath() + "run.png"));
			results->push_back(CatItem("Run as", "Run as a different user", HASH_VERBY, getIconPath() + "run.png"));
			results->push_back(CatItem("Open containing folder", "Open containing folder", HASH_VERBY, getIconPath() + "opencontainer.png"));
			results->push_back(CatItem("Open shortcut folder", "Open shortcut folder", HASH_VERBY, getIconPath() + "opencontainer.png"));
			results->push_back(CatItem("Copy path", "Copy path to clipboard", HASH_VERBY, getIconPath() + "copy.png"));
			results->push_back(CatItem("Properties", "File properties", HASH_VERBY, getIconPath() + "properties.png"));
			inputData->first().setID(HASH_VERBY);
			inputData->first().getTopResult().id = HASH_VERBY;
		}
		else
		{
			return;
		}

		if (inputData->last().hasText())
			results->push_front(CatItem(inputData->last().getText(), inputData->last().getText(), 0, inputData->first().getTopResult().icon));
	}
}
Ejemplo n.º 4
0
void controlyPlugin::getCatalog(QList<CatItem>* items) {
	getApps(items);

	CatItem tmp = CatItem("Launchy.controly", "Launchy", HASH_controly, getIcon());
	tmp.usage = 5000;
	items->push_back(tmp);
}
Ejemplo n.º 5
0
void VerbyPlugin::addCatItem(QString text, QList<CatItem>* results, QString fullName, QString shortName, QString iconName)
{
    if (text.length() == 0 || isMatch(shortName, text))
    {
        CatItem item = CatItem(fullName, shortName, HASH_VERBY, getIconPath() + iconName);
        item.usage = (*settings)->value("verby/" + shortName.replace(" ", "") , 0).toInt();
        results->push_back(item);
    }
}
Ejemplo n.º 6
0
void controlyPlugin::addCatItem(QString text, QList<CatItem>* results, QString fullName, QString shortName)
{
	if (text.length() == 0 || isMatch(shortName, text))
	{
		CatItem& item = CatItem(fullName, shortName, HASH_controly, getIconPath() + fullName.toLower() + ".png");
		item.usage = (*settings)->value("controly/" + shortName.replace(" ", "") , 0).toInt();
		results->push_back(item);
	}
}
Ejemplo n.º 7
0
void controlyPlugin::getResults(QList<InputData>* id, QList<CatItem>* results)
{
	// if user enters "*.controly", dynamically return all elements that we added to the primary catalog (for informational / debugging purposes only)
	if (id->size() == 1) {
		const QString & text = id->first().getText();

		if (text.compare("*.controly") == 0) {
			QList<CatItem> controlyCatalog;
			getCatalog(&controlyCatalog);
			CatItem temp("ItemCount.controly", QString::number(controlyCatalog.size()), HASH_controly, getIcon());
			temp.usage = 32000;
			results->append(temp);
			(*results) += controlyCatalog;
		}
	}

	if (id->count() != 2)
		return;

	if (id->first().getTopResult().id == HASH_controly) {
		QSettings* set = *settings;
		if (set == NULL) return;

		CatItem tmp = CatItem("Launchy.options", "Options", HASH_controly, getIcon());
		tmp.usage = set->value("controly/OptionsCount",0).toInt();
		results->push_back(tmp);

		tmp = CatItem("Launchy.reindex", "Rebuild Index", HASH_controly, getIcon());
		tmp.usage = set->value("controly/RebuildCount",0).toInt();
		results->push_back(tmp);

		tmp = CatItem("Launchy.exit", "Exit", HASH_controly, getIcon());
		tmp.usage = set->value("controly/ExitCount",0).toInt();
		results->push_back(tmp);
	}	
}
Ejemplo n.º 8
0
void WebyPlugin::indexIE(QString path, QList<CatItem>* items)
{
	QDir qd(path);
	QString dir = qd.absolutePath();
	QStringList dirs = qd.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);

	for (int i = 0; i < dirs.count(); ++i) {
		QString cur = dirs[i];
		if (cur.contains(".lnk")) continue;
		indexIE(dir + "/" + dirs[i],items);
	}	

	QStringList files = qd.entryList(QStringList("*.url"), QDir::Files, QDir::Unsorted);
	for(int i = 0; i < files.count(); ++i) {
		items->push_back(CatItem(dir + "/" + files[i], files[i].mid(0,files[i].size()-4)));
	}
}
Ejemplo n.º 9
0
void VerbyPlugin::getResults(QList<InputData>* inputData, QList<CatItem>* results)
{
    if (inputData->count() == 2)
    {
        QString text = inputData->at(1).getText();

        if (inputData->first().hasLabel(HASH_DIR))
        {
            addCatItem(text, results, "Properties", "Directory properties", "properties.png");
        }
        else if (inputData->first().hasLabel(HASH_FILE))
        {
            addCatItem(text, results, "Open containing folder", "Open containing folder", "opencontainer.png");
            addCatItem(text, results, "Properties", "File properties", "properties.png");
        }
        else if (inputData->first().hasLabel(HASH_LINK))
        {
            addCatItem(text, results, "Run as", "Run as a different user", "run.png");
            addCatItem(text, results, "Open containing folder", "Open containing folder", "opencontainer.png");
            addCatItem(text, results, "Open shortcut folder", "Open shortcut folder", "opencontainer.png");
            addCatItem(text, results, "Copy path", "Copy path to clipboard", "copy.png");
            addCatItem(text, results, "Properties", "File properties", "properties.png");
        }
        else
        {
            return;
        }

        // Mark the item as a Verby item so that Verby has a chance to process it before Launchy
        inputData->first().setID(HASH_VERBY);
        inputData->first().getTopResult().id = HASH_VERBY;

        // ensure there's always an item at the top of the list for launching with parameters.
        results->push_front(CatItem(
            "Run",
            inputData->last().getText(), INT_MAX,
            getIconPath() + "run.png"));
    }
}
Ejemplo n.º 10
0
void controlyPlugin::getApps(QList<CatItem>* items) {
	int a = 0;
	// Get the control panel applications
	TCHAR  infoBuf[32767];
	if (!GetSystemDirectory(infoBuf, 32767)) {
		return;
	}
	QString buff = QString::fromUtf16((const ushort*) infoBuf);
	QDir qd(buff);


	QStringList files = qd.entryList(QStringList("*.cpl"), QDir::Files, QDir::Unsorted);
	foreach(QString file, files) {

		QString path = QDir::toNativeSeparators(qd.absoluteFilePath(file));

		if (cache.count(file) > 0) {
			if (cache[file] != "") 
				items->push_back(CatItem(path, cache[file], 0, getIcon()));
			continue;
		}
		union { 
			NEWCPLINFOA NewCplInfoA;
			NEWCPLINFOW NewCplInfoW; 
		} Newcpl;
	    
		HINSTANCE hLib; // Library Handle to *.cpl file
		APPLET_PROC CplCall; // Pointer to CPlApplet() function
		LONG i;


		hLib = LoadLibrary((LPCTSTR) path.utf16());
		if (hLib) {
			CplCall=(APPLET_PROC)GetProcAddress(hLib,"CPlApplet");
			if (CplCall) {
				if (CplCall(NULL, CPL_INIT,0,0)) {
					
					for (i=0;i<CplCall(NULL,CPL_GETCOUNT,0,0);i++)
					{	        
						Newcpl.NewCplInfoA.dwSize = 0;
						Newcpl.NewCplInfoA.dwFlags = 0;
						a = CplCall(NULL,CPL_INQUIRE,i,(long)&Newcpl);

						if (Newcpl.NewCplInfoA.dwSize == sizeof(NEWCPLINFOW))
						{
							// Case #1, CPL_INQUIRE has returned an Unicode String
							items->push_back(CatItem(path, QString::fromUtf16((const ushort*)Newcpl.NewCplInfoW.szName), 0, getIcon()));
							cache[file] = QString::fromUtf16((const ushort*)Newcpl.NewCplInfoW.szName);
						}
						else 
						{
							// Case #2, CPL_NEWINQUIRE has returned an ANSI String
							if (Newcpl.NewCplInfoA.dwSize != sizeof(NEWCPLINFOA))
							{
								// Case #3, CPL_NEWINQUIRE failed to return a string
								//    Get the string from the *.cpl Resource instead
								CPLINFO CInfo;
								a = CplCall(NULL,CPL_INQUIRE,i,(long)&CInfo);

								LoadStringA(hLib,CInfo.idName,
									Newcpl.NewCplInfoA.szName,32);
							}
			//				wchar_t	tmpString[32];
			//				MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, Newcpl.NewCplInfoA.szName, 32, tmpString, 32);
							items->push_back(CatItem(path, QString(Newcpl.NewCplInfoA.szName), 0, getIcon()));
							cache[file] = QString(Newcpl.NewCplInfoA.szName);
						}
					} // for
					CplCall(NULL,CPL_EXIT,0,0);
				}
				
			}
			FreeLibrary(hLib);
		} 
	}
Ejemplo n.º 11
0
void testpluginPlugin::getCatalog(QList<CatItem>* items)
{
    items = items;
    CatItem me(itemPath);
#ifdef TEST
    Q_ASSERT(items);
    CatItem cv("test://catalogTestVerb", testVerbStr, TEST_HASH);
    cv.setItemType(CatItem::VERB);
    items->append(cv);

    CatItem ci("test://catalogTestNounItem", testNounStr , TEST_HASH);
    CatItem c("testCatalogChildItem", "testChild", TEST_HASH);
    ci.addChild(c);
    items->append(ci);

    for(uint i=0; i < str_len;i++){
        QString out_str = str_list[i][1];
        CatItem it(out_str, out_str, TEST_HASH);
        it.setExternalWeight(MAX_EXTERNAL_WEIGHT, me);
        qDebug() << "test item path: " << it.getPath();
        qDebug() << "test item name: " << it.getName();

        items->append(it);
    }
    QFileInfo fileInfo("~/.oneline/custom_actions/Send_Email.oneline");
    Q_ASSERT(fileInfo.exists());
    QSettings s(fileInfo.absoluteFilePath(), QSettings::IniFormat);

    CatItem custI(&s);

//    CatItem custI("vTestCustomVerb", testCustomVerbStr, TEST_HASH);
//    custI.setCustomPluginValue(MIN_ARG_NUM_KEY,2);
//    custI.setCustomPluginInfo(VERB_ARG "1","built-in://long-text | body | %s");
//    custI.setCustomPluginInfo(VERB_ARG "2","tag://email-address | recipient(s) | to %s ");
//    custI.setCustomPluginInfo(VERB_ARG "3","tag://email-address | recipient(s) | to %s ");
//    custI.setCustomPluginInfo(CUSTOM_ACTION_KEY,"test_action.sh");

#endif

#ifdef TEST_GUI
    Q_ASSERT(items);
    CatItem ci("catalogTestItem", "testItem", TEST_HASH);
    ci.setExternalWeight(HIGH_EXTERNAL_WEIGHT,me);
    ci.addChild(CatItem("testCatalogChildItem", "testChild", TEST_HASH));
    items->append(ci);
    for(uint i=0; i < str_len;i++){
        QString out_str = str_list[i][1];
        CatItem it(out_str, out_str, TEST_HASH);
        items->append(it);
    }

    CatItem ci0("AHighttestResultItem", "AHighcustom",TEST_HASH);
    ci0.setExternalWeight(HIGH_EXTERNAL_WEIGHT,me);
    items->append(ci0);

    CatItem ci1("AtestResultSource", "Acustom",TEST_HASH);
    ci1.setItemType(CatItem::TAG);
    CatItem childI1("AtestResultChild", "nps_child",TEST_HASH);
    ci1.addChild(childI1);
    items->append(childI1);
    items->append(ci1);

    CatItem ci2("XtestResultSource", "Xcustom",TEST_HASH);
    ci2.setItemType(CatItem::TAG);
    CatItem childI2("XtestResultChild", "wmv_child",TEST_HASH);

    ci2.addChild(childI2);
    items->append(childI2);
    items->append(ci2);

    CatItem ci3("UtestResultSource", "Ucustom",TEST_HASH);
    ci3.setItemType(CatItem::TAG);
    CatItem childI3("UtestResultChild", "pst_child",TEST_HASH);

    ci3.addChild(childI3);
    items->append(ci3);
    items->append(childI3);

    for(uint i=0; i < fill_len;i++){
        QString out_str = fill_list[i][1];
        CatItem it(out_str, out_str, TEST_HASH);
        items->append(it);
    }

    CatItem it("tag item");
    it.setItemType(CatItem::OPERATION);
    it.setTakesAnykeys(true);

    for(int i=0; i< 20; i++){
        CatItem it(QString::number(i));
        ListItem li(it);
        for(int j=0; j< 30; j++){
            CatItem it2(numAsStr(i));
            ListItem li2(it2);
            li.setTotalWeight(abs(5000 - j*j*10 + i*i*i));
            li.addChild(li2);
            if(j % 3 ==0){
                tl.append(li2);
            }

        }
        if(i%5 ==0){
            tl.append(li);
        }
    }




#endif
}
Ejemplo n.º 12
0
	foreach(runnerCmd cmd, cmds)
	{
		items->push_back(CatItem(cmd.file + "%%%" + cmd.args, cmd.name, HASH_runner, getIcon(cmd.file)));
	}