~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to qcm/certstore.qcm

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
-----BEGIN QCMOD-----
 
3
name: certstore
 
4
section: project
 
5
arg: certstore-path=[path],Path to the SSL/X509 Certificate store file (bundled QCA only)
 
6
-----END QCMOD-----
 
7
*/
 
8
 
 
9
class qc_certstore : public ConfObj
 
10
{
 
11
public:
 
12
        qc_certstore(Conf *c) : ConfObj(c) {}
 
13
        QString name() const { return "certstore"; }
 
14
        QString shortname() const { return "certstore"; }
 
15
 
 
16
        QString checkString() const {
 
17
                if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
 
18
                        return "";
 
19
                else
 
20
                        return ConfObj::checkString();
 
21
        }
 
22
 
 
23
        bool exec()
 
24
        {
 
25
                if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty() || !QFile::exists("third-party/qca/qca-ossl")) {
 
26
                        return true;
 
27
                }
 
28
                        
 
29
                bundled = false;
 
30
 
 
31
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
 
32
                // use built-in
 
33
                return true;
 
34
#else
 
35
                QStringList pathsToTry;
 
36
 
 
37
                path = conf->getenv("QC_CERTSTORE_PATH");
 
38
                if(!path.isEmpty())
 
39
                {
 
40
                        if(QFile::exists(path))
 
41
                        {
 
42
                                QString certPathString = 
 
43
                                        "QCA_SYSTEMSTORE_PATH=\\\\\\\\\\\\\"" + path + "\\\\\\\\\\\\\"";
 
44
                                conf->addDefine(certPathString);
 
45
                                return true;
 
46
                        }
 
47
                        return false;
 
48
                }
 
49
 
 
50
                // This is from Debian
 
51
                pathsToTry.append( QString("/etc/ssl/certs/ca-certificates.crt") );
 
52
 
 
53
                // Fedora Core 2 uses these
 
54
                pathsToTry.append( QString("/usr/share/ssl/cert.pem") );
 
55
                pathsToTry.append( QString("/usr/share/ssl/certs/ca-bundle.crt") );
 
56
 
 
57
                // Fedora Core 5 changes to this
 
58
                pathsToTry.append( QString("/etc/pki/tls/cert.pem") );
 
59
 
 
60
                for(int n = 0; n < pathsToTry.count(); ++n)
 
61
                {
 
62
                        if(QFile::exists(pathsToTry[n]))
 
63
                        {
 
64
                                path = pathsToTry[n];
 
65
                                break;
 
66
                        }
 
67
                }
 
68
 
 
69
                // fall back to bundled
 
70
                if(path.isEmpty())
 
71
                {
 
72
                        // --prefix=$pwd ?
 
73
                        if(QFile::exists(conf->getenv("PREFIX") + "/certs/rootcerts.pem"))
 
74
                                path = "$$PREFIX/certs/rootcerts.pem";
 
75
                        else
 
76
                                path = "$$DATADIR/psi/certs/rootcerts.pem";
 
77
 
 
78
                        QString extra =
 
79
                        "qcasharedfiles.path = $$DATADIR/psi\n"
 
80
                        "qcasharedfiles.files = third-party/qca/qca/certs\n"
 
81
                        "INSTALLS += qcasharedfiles\n";
 
82
                        conf->addExtra(extra);
 
83
                        bundled = true;
 
84
                }
 
85
 
 
86
                // Qt<4.2 workaround
 
87
                QString certPathString = 
 
88
                        "QCA_SYSTEMSTORE_PATH=\\\\\\\\\\\\\"" + path + "\\\\\\\\\\\\\"";
 
89
                conf->addDefine(certPathString);
 
90
 
 
91
                return true;
 
92
#endif
 
93
        }
 
94
 
 
95
        QString resultString() const
 
96
        {
 
97
#if defined(Q_OS_WIN)
 
98
                return "using Windows built-in";
 
99
#elif defined(Q_OS_MAC)
 
100
                return "using Mac built-in";
 
101
#else
 
102
                if(success)
 
103
                {
 
104
                        if(bundled)
 
105
                                return "using bundled";
 
106
                        else
 
107
                                return path;
 
108
                }
 
109
                else
 
110
                        return ConfObj::resultString();
 
111
#endif
 
112
        }
 
113
 
 
114
private:
 
115
        QString path;
 
116
        bool bundled;
 
117
};