MLocalThemeDaemonClient::MLocalThemeDaemonClient(QObject *parent) :
    MAbstractThemeDaemonClient(parent),
    m_pixmapCache(),
    m_imageDirNodes()
#ifdef HAVE_MLITE
    , themeItem("/meegotouch/theme/name")
#endif
{
    QStringList themeRoots;
    QString themeRoot;

    themeRoot = qgetenv("M_THEME_DIR");
    if (themeRoot.isEmpty()) {
#if defined(THEME_DIR)
        themeRoot = THEME_DIR;
#else
# ifdef Q_OS_WIN
        themeRoot = "c:\\";
# else
        themeRoot = "/usr/share/themes";
# endif
#endif
    }

    // we must always fallback to blanco for assets we don't provide in the custom theme
    themeRoots += themeRoot + QDir::separator() + QLatin1String("blanco") + QDir::separator() + QLatin1String("meegotouch");

#ifdef HAVE_MLITE
    // custom theme will be searched after blanco, meaning it will override assets from there
    qDebug() << Q_FUNC_INFO << "Theme: " << themeItem.value("blanco").toString();
    themeRoots += themeRoot + QDir::separator() + themeItem.value("blanco").toString() + QDir::separator() + QLatin1String("meegotouch");
#else
    qDebug() << Q_FUNC_INFO << "Theme: blanco (hardcoded)";
#endif

    for (int i = 0; i < themeRoots.size(); ++i) {
        if (themeRoots.at(i).endsWith(QDir::separator()))
            themeRoots[i].truncate(themeRoots.at(i).length() - 1);

        buildHash(themeRoots.at(i) + QDir::separator() + "icons", QStringList() << "*.svg" << "*.png" << "*.jpg");
        buildHash(themeRoots.at(i) + QDir::separator() + "images" + QDir::separator() + "theme", QStringList() << "*.png" << "*.jpg");
        buildHash(themeRoots.at(i) + QDir::separator() + "images" + QDir::separator() + "backgrounds", QStringList() << "*.png" << "*.jpg");
    }

    m_imageDirNodes.append(ImageDirNode("icons" , QStringList() << ".svg" << ".png" << ".jpg"));
    m_imageDirNodes.append(ImageDirNode(QLatin1String("images") + QDir::separator() + QLatin1String("theme"), QStringList() << ".png" << ".jpg"));
    m_imageDirNodes.append(ImageDirNode(QLatin1String("images") + QDir::separator() + QLatin1String("backgrounds"), QStringList() << ".png" << ".jpg"));

    qDebug() << "LocalThemeDaemonClient: Looking for assets in" << themeRoots;
}
Example #2
0
/*	================== buildHead =================
 This function creates the header structure that
 contains pointers to the tree and the hash table.
 It also calls other functions to read in the data
 file.
 Pre		pHeader - pointer to HEAD structure
 fileInput - name of the file
 Post		both the tree and the hash table are
 created.
 Return	pointer to create HEAD structure
 */
HEAD* buildHead (HEAD* pHeader, char* fileInput)
{
	//	Local Declarations
	DATA* newAirport;
    FILE* fpIn;
    
	//	Statements
    fpIn = fopen(fileInput, "r");
    if (!fpIn) {
        printf("Error opening input file\n");
        exit(101);
    }
    
    if ((pHeader = (HEAD*) malloc(sizeof(HEAD))))
    {
        pHeader->pHash = buildHash(2 * countLines(fileInput));
        pHeader->pTree = BST_Create(compareCode);
    }
    else{
        printf("Memory allocation error\n");
        exit(100);
    }
    
    while (getData(pHeader->pTree, fpIn, &newAirport)) {
        BST_Insert(pHeader->pTree, newAirport);
        insertHash(pHeader->pHash, newAirport);
    }
    
    return pHeader;
}	// buildHead
Example #3
0
	ShaderInstance* ShaderSet::getInstance (PropertySetGet* properties)
	{
		size_t h = buildHash (properties);
		if (std::find(mFailedToCompile.begin(), mFailedToCompile.end(), h) != mFailedToCompile.end())
			return NULL;
		if (mInstances.find(h) == mInstances.end())
		{
			ShaderInstance newInstance(this, mName + "_" + boost::lexical_cast<std::string>(h), properties);
			if (!newInstance.getSupported())
			{
				mFailedToCompile.push_back(h);
				return NULL;
			}
			mInstances.insert(std::make_pair(h, newInstance));
		}
		return &mInstances.find(h)->second;
	}
int main(int argc,char **argv)
{
		if (argc != 9) {
			fprintf(stderr,"usage: %s <ITEMS> <CS> <p1> <p2> <p3> <p1> <p2> <p3>\n",argv[0]);exit(1);
		}

		itemFileName=argv[1];
		cFileName=argv[2];
		iP1=atoi(argv[3]);
		iP2=atoi(argv[4]);
		iP3=atoi(argv[5]);
		cP1=atoi(argv[6]);
		cP2=atoi(argv[7]);
		cP3=atoi(argv[8]);

		if (iP1 != -1) iP1--;
		if (iP2 != -1) iP2--;
		if (iP3 != -1) iP3--;
		if (cP1 != -1) cP1--;
		if (cP2 != -1) cP2--;
		if (cP3 != -1) cP3--;

		mType=get_type(cP1,cP2,cP3,iP1,iP2,iP3);
		//printf("mType=%d\n",mType);

		cMxCnt=get_line_count(cFileName); 	// needed to allocate memory
		cMxLgh=8; 				// for now, just to allocate memory and read the items
		cCnt=read_data(cFileName,cMxCnt,cMxLgh,maxPos(cP1,cP2,cP3),&cs); // read C items
		cMxLgh=strlen(cs[0]);			// assume all C items are same length

		buildAlphabet(cs,cCnt,cMxLgh);		// assign unique serial number to each letter used in C items

		buildIndex(&cIdx,cs,cCnt,mType,cP1,cP2,cP3); // calculate an index for each C items (unique at up to MLET letters)

		buildHash(mType);			// build hash table with C items

		init_hits(&hits,cCnt);

fprintf(stderr,"prep done\n");

		match_items_cs(mType);			// match GIGA file data to C items using hash table

		dump_hits(hits,cs,cCnt);
}
MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString &testPath, QObject *parent) :
    MAbstractThemeDaemonClient(parent),
    m_pixmapCache()
#ifdef HAVE_MLITE
    , themeItem("/meegotouch/theme/name")
#endif
{
    QStringList themeRoots;
    QString themeRoot = testPath;
    bool testMode = false;

    if (themeRoot.isEmpty())
        themeRoot = qgetenv("M_THEME_DIR");
    else
        testMode = true;

    if (themeRoot.isEmpty()) {
#if defined(THEME_DIR)
        themeRoot = THEME_DIR;
#else
# ifdef Q_OS_WIN
        themeRoot = "c:\\";
# else
        themeRoot = "/usr/share/themes";
# endif
#endif
    }

    if (testMode == false) {
        QString themeName;
# if !defined(THEME_NAME)
#  define THEME_NAME "blanco"
# endif
#ifdef HAVE_MLITE
        qDebug() << Q_FUNC_INFO << "Theme: " << themeItem.value(THEME_NAME).toString();
        themeName = themeItem.value(THEME_NAME).toString();
#else
        qDebug() << Q_FUNC_INFO << "Theme: " << THEME_NAME << " (hardcoded)";
        themeName = QLatin1String(THEME_NAME);
#endif

        // find out the inheritance chain for the new theme
        QString nextTheme = themeName;
        QSet<QString> inheritanceChain;

        while (true) {
            // Determine whether this is an m theme:
            const QString themeIndexFileName = themeRoot + QDir::separator() + nextTheme + QDir::separator() + "index.theme";

            // it needs to be a valid ini file
            const QSettings themeIndexFile(themeIndexFileName, QSettings::IniFormat);
            if (themeIndexFile.status() != QSettings::NoError) {
                qWarning() << Q_FUNC_INFO << "Theme" << themeName << "does not exist! Falling back to " << THEME_NAME;
                break;
            }

            // we need to have X-MeeGoTouch-Metatheme group in index.theme
            if (!themeIndexFile.childGroups().contains(QString("X-MeeGoTouch-Metatheme"))) {
                qWarning() << Q_FUNC_INFO << "Theme" << themeName << " is invalid";
                break;
            }

            inheritanceChain.insert(nextTheme);
            // the paths should be stored in reverse order than in the inheritance chain
            themeRoots.prepend(themeRoot + QDir::separator() + nextTheme + QDir::separator() + QLatin1String("meegotouch"));

            QString parentTheme = themeIndexFile.value("X-MeeGoTouch-Metatheme/X-Inherits", "").toString();

            if (parentTheme.isEmpty()) {
                break;
            }
            nextTheme = parentTheme;

            // check that there are no cyclic dependencies
            if (inheritanceChain.contains(parentTheme)) {
                qFatal("%s: cyclic dependency in theme: %s", Q_FUNC_INFO, themeName.toUtf8().constData());
            }
        }
    } else {
        qDebug() << Q_FUNC_INFO << "Theme: test mode: " << themeRoot;
        themeRoots += themeRoot;
    }

    for (int i = 0; i < themeRoots.size(); ++i) {
        if (themeRoots.at(i).endsWith(QDir::separator()))
            themeRoots[i].truncate(themeRoots.at(i).length() - 1);

        buildHash(themeRoots.at(i) + QDir::separator() + "icons", QStringList() << "*.svg" << "*.png" << "*.jpg");
    }

    qDebug() << "LocalThemeDaemonClient: Looking for assets in" << themeRoots;
}
 foreach(const QString &nextDirString, dirList){
     QDir nextDir(rootDir.absolutePath() + QDir::separator() + nextDirString);
     buildHash(nextDir, nameFilter);
 }
Example #7
0
void CSVHeader::read(FILE *fp)
{
	CSVData::read(fp);
	buildHash();
}
	TITANIUM_PROPERTY_GETTER(TiModule, buildHash)
	{
		return get_context().CreateString(buildHash());
	}