File: growl.qcm

package info (click to toggle)
psi 0.11-9
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 11,036 kB
  • ctags: 19,340
  • sloc: cpp: 130,316; ansic: 26,008; xml: 900; sh: 558; makefile: 225; python: 178; ruby: 21
file content (63 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
-----BEGIN QCMOD-----
name: Growl
arg: with-growl=[path],Path to the Growl framework
-----END QCMOD-----
*/

//----------------------------------------------------------------------------
// qc_growl
//----------------------------------------------------------------------------
class qc_growl : public ConfObj
{
public:
	qc_growl(Conf *c) : ConfObj(c) {}
	QString name() const { return "Growl"; }
	QString shortname() const { return "growl"; }
#ifndef Q_WS_MAC
	QString checkString() const { return QString(); }
#endif

	// TODO: This should go into ConfObj
    bool checkFramework(const QString &path, const QString &name)
    {
        QString str =
            "int main()\n"
            "{\n"
            "    return 0;\n"
            "}\n";

        QString extra;
        if(!path.isEmpty())
            extra += QString("-F") + path + ' ';
        extra += QString("-framework ") + name;
        if(!conf->doCompileAndLink(str, QStringList(), extra, "", NULL))
            return false;
        return true;
    }
	
	// TODO: This should go into ConfObj
	void addFrameworkPath(const QString& str)
	{
		conf->addExtra("QMAKE_CXXFLAGS += -F" + str);
		conf->addLib("-F" + str);
	}

	bool exec()
	{
#ifdef Q_WS_MAC
		QString growl_path = conf->getenv("QC_WITH_GROWL");
		if(!checkFramework(growl_path, "Growl"))
			return false;

		if(!growl_path.isEmpty()) 
			addFrameworkPath(growl_path);
		conf->addLib("-framework Growl");
		conf->addDefine("HAVE_GROWL");

		return true;
#else
		return false;
#endif
	}
};