/*
-----BEGIN QCMOD-----
name: the XScreenSaver extension
-----END QCMOD-----
*/

//----------------------------------------------------------------------------
// qc_xss
//----------------------------------------------------------------------------
class qc_xss : public ConfObj
{
public:
    qc_xss(Conf *c) : ConfObj(c) {}

    QString name() const { return "the XScreenSaver extension"; }
    QString shortname() const { return "xss"; }
#ifdef Q_OS_WIN
    QString checkString() const { return QString(); }
#endif

    bool exec()
    {
#ifdef Q_OS_WIN
    	// skip XSS support on windows
    	return false;
#else
    	QString str =
    		"#include<X11/Xlib.h>\n"
    		"#include<X11/Xutil.h>\n"
    		"#include<X11/extensions/scrnsaver.h>\n"
    		"\n"
    		"int main()\n"
    		"{\n"
    		"    XScreenSaverQueryExtension(NULL, NULL, NULL);\n"
    		"    return 0;\n"
    		"}\n";
    	QString proextra = "CONFIG += x11\n";

    	if (!conf->doCompileAndLink(str, QStringList(), "-lXss", proextra, NULL)) {
    		if (!conf->doCompileAndLink(str, QStringList(), QString(), proextra, NULL)) {
    			return false;
    		}
    	}
    	else {
    		conf->addLib("-lXss");
    	}

    	conf->addDefine("HAVE_XSS");
    	return true;
#endif
    }
};
