/* -----BEGIN QCMOD----- name: Linux Directory Notification -----END QCMOD----- */ #include #include #include #include //---------------------------------------------------------------------------- // qc_dnotify //---------------------------------------------------------------------------- class qc_dnotify : public ConfObj { public: qc_dnotify(Conf *c) : ConfObj(c) { } ~qc_dnotify() { remove("ftest.c"); remove("ftest.o"); } QString name() const { return "Linux Directory Notification"; } QString shortname() const { return "dnotify"; } bool do_write() { char *fdata = "#define _GNU_SOURCE\n" "#include\n" "#include\n" "#include\n" "#include\n" "\n" "int main()\n" "{\n" " DN_DELETE|DN_CREATE|DN_RENAME|DN_MULTISHOT|DN_MODIFY|DN_ATTRIB;\n" " return 0;\n" "}\n"; FILE *f; f = fopen("ftest.c", "w"); if(!f) return false; fwrite(fdata, strlen(fdata), 1, f); fclose(f); return true; } bool do_compile() { QString str = conf->qvar("QMAKE_CC") + " -c ftest.c -o ftest.o"; int r = conf->doCommand(str); if(r == 0) return true; else return false; } bool exec() { // taken from KDE bool supports_dnotify = true; // not guilty until proven guilty struct utsname uts; int major, minor, patch; if(uname(&uts) < 0) supports_dnotify = false; // *shrug* else if(sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3) supports_dnotify = false; // *shrug* else if( major * 1000000 + minor * 1000 + patch < 2004019 ) // <2.4.19 supports_dnotify = false; if(!supports_dnotify) return false; if(!do_write()) return false; if(!do_compile()) return false; conf->addDefine("HAVE_DNOTIFY"); return true; } };