~ubuntu-branches/ubuntu/hoary/psi/hoary

« back to all changes in this revision

Viewing changes to qcm/xss.qcm

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2004-06-15 00:10:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040615001041-enywb6pcpe4sjsw6
Tags: 0.9.2-1
* New upstream release
* Set KDEDIR for ./configure so kde specific files get installed
* Don't install libpsiwidgets.so. It got installed in /usr/share
  where it doesn't belong. May be included (at a better location)
  later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
-----BEGIN QCMOD-----
 
3
name: the XScreenSaver extension
 
4
-----END QCMOD-----
 
5
*/
 
6
 
 
7
//----------------------------------------------------------------------------
 
8
// qc_xss
 
9
//----------------------------------------------------------------------------
 
10
class qc_xss : public ConfObj
 
11
{
 
12
public:
 
13
        enum { OK, NEEDLIB, FAIL };
 
14
        qc_xss(Conf *c) : ConfObj(c)
 
15
        {
 
16
        }
 
17
 
 
18
        ~qc_xss()
 
19
        {
 
20
                remove("xssprobe_test.c");
 
21
                remove("xssprobe_test.o");
 
22
                remove("xssprobe_test");
 
23
        }
 
24
 
 
25
        QString name() const
 
26
        {
 
27
                return "the XScreenSaver extension";
 
28
        }
 
29
 
 
30
        QString shortname() const { return "xss"; }
 
31
 
 
32
        int do_write()
 
33
        {
 
34
                char *xsstest =
 
35
                        "#include<X11/Xlib.h>\n"
 
36
                        "#include<X11/Xutil.h>\n"
 
37
                        "#include<X11/extensions/scrnsaver.h>\n"
 
38
                        "\n"
 
39
                        "int main()\n"
 
40
                        "{\n"
 
41
                        "    XScreenSaverQueryExtension(NULL, NULL, NULL);\n"
 
42
                        "    return 0;\n"
 
43
                        "}\n";
 
44
 
 
45
                FILE *f;
 
46
                f = fopen("xssprobe_test.c", "w");
 
47
                if(!f)
 
48
                        return 0;
 
49
                fwrite(xsstest, strlen(xsstest), 1, f);
 
50
                fclose(f);
 
51
 
 
52
                return 1;
 
53
        }
 
54
 
 
55
        int do_compile()
 
56
        {
 
57
                QString inc = conf->expandIncludes(conf->qvar("QMAKE_INCDIR_X11"));
 
58
                QString str = conf->qvar("QMAKE_CC") + " -c " + inc + " xssprobe_test.c -o xssprobe_test.o";
 
59
                int r = conf->doCommand(str);
 
60
                if(r == 0)
 
61
                        return 1;
 
62
                else
 
63
                        return 0;
 
64
        }
 
65
 
 
66
        int do_link()
 
67
        {
 
68
                QString lib = conf->expandLibs(conf->qvar("QMAKE_LIBDIR_X11"));
 
69
                QString inc = conf->expandIncludes(conf->qvar("QMAKE_INCDIR_X11"));
 
70
                QString str = conf->qvar("QMAKE_CC") + " xssprobe_test.o -o xssprobe_test " + lib + ' ' + conf->qvar("QMAKE_LIBS_X11");
 
71
                int r = conf->doCommand(str);
 
72
                if(r == 0)
 
73
                        return 1;
 
74
                else
 
75
                        return 0;
 
76
        }
 
77
 
 
78
        int do_linkLib()
 
79
        {
 
80
                QString lib = conf->expandLibs(conf->qvar("QMAKE_LIBDIR_X11"));
 
81
                QString inc = conf->expandIncludes(conf->qvar("QMAKE_INCDIR_X11"));
 
82
                QString str = conf->qvar("QMAKE_CC") + " xssprobe_test.o -o xssprobe_test " + lib + ' ' + conf->qvar("QMAKE_LIBS_X11") + " -lXss";
 
83
                int r = conf->doCommand(str);
 
84
                if(r == 0)
 
85
                        return 1;
 
86
                else
 
87
                        return 0;
 
88
        }
 
89
 
 
90
        int do_all()
 
91
        {
 
92
                if(!do_write())
 
93
                        return FAIL;
 
94
                if(!do_compile())
 
95
                        return FAIL;
 
96
                if(do_link())
 
97
                        return OK;
 
98
                if(do_linkLib())
 
99
                        return NEEDLIB;
 
100
                return FAIL;
 
101
        }
 
102
 
 
103
        bool exec()
 
104
        {
 
105
                int r = do_all();
 
106
                if(r == OK)
 
107
                        return true;
 
108
                if(r == NEEDLIB) {
 
109
                        conf->addLib("-lXss");
 
110
                        return true;
 
111
                }
 
112
                else {
 
113
                        conf->addDefine("NO_XSS");
 
114
                        return false;
 
115
                }
 
116
        }
 
117
};