/*
-----BEGIN QCMOD-----
name: Google File Transfer
arg: enable-google-ft,Enable Google File Transfer support
arg: with-expat-inc=[path],Path to Expat include files (for Google)
arg: with-expat-lib=[path],Path to Expat library files (for Google)
-----END QCMOD-----
*/

//----------------------------------------------------------------------------
// qc_google_ft
//----------------------------------------------------------------------------
class qc_google_ft : public ConfObj
{
public:
    qc_google_ft(Conf *c) : ConfObj(c) {}
    QString name() const { return "Google File Transfer"; }
    QString shortname() const { return "GoogleFT"; }
    bool exec()
    {
    	QString s = conf->getenv("QC_ENABLE_GOOGLE_FT");
    	if(s.isEmpty())
    		return false;

    	// Expat
    	s = conf->getenv("QC_WITH_EXPAT_INC");
    	if(!s.isEmpty()) {
    		if(!conf->checkHeader(s, "expat.h")) {
    			qWarning("Expat includes not found!");
    			return false;
    		}
    		conf->addIncludePath(s);
    	}
    	else {
    		if(!conf->findHeader("expat.h", QStringList(), &s)) {
    			qWarning("Expat includes not found!");
    			return false;
    		}
    		conf->addIncludePath(s);
    	}

    	s = conf->getenv("QC_WITH_EXPAT_LIB");
    	if(!s.isEmpty()) {
    		if(!conf->checkLibrary(s, "expat")) {
    			qWarning("Expat library not found!");
    			return false;
    		}
    		conf->addLib(QString("-L") + s);
    	}
    	else {
    		if(!conf->findLibrary("expat", &s)) {
    			qWarning("Expat library not found!");
    			return false;
    		}
    		if (!s.isEmpty())
    			conf->addLib(QString("-L") + s);
    	}

    	conf->addLib("-lexpat");

    	// Finish
    	conf->addExtra("CONFIG += google_ft");

    	return true;
    }
};
