本文整理汇总了C++中Environment::configDir方法的典型用法代码示例。如果您正苦于以下问题:C++ Environment::configDir方法的具体用法?C++ Environment::configDir怎么用?C++ Environment::configDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::configDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isValid
bool isValid() {
static bool hasValidated = false;
static bool validates = false;
if ( hasValidated ) return validates;
Environment *env = Environment::Instance();
if ( env == NULL ) {
cerr << "FATAL ERROR: No environment available" << endl;
return false;
}
hasValidated = true;
string licenseDir = env->configDir() + "/key";
string licenseFile = licenseDir + "/License";
string licenseKeyfile = licenseDir + "/License.key";
string licenseSignature = licenseDir + "/License.signed";
boost::filesystem::path path = SC_FS_PATH(env->shareDir())
/ SC_FS_PATH("licenses") / SC_FS_PATH("seiscomp3.crt");
if ( !Seiscomp::Util::fileExists(path.string().c_str()) ) {
path = SC_FS_PATH(env->configDir())
/ SC_FS_PATH("licenses") / SC_FS_PATH("seiscomp3.crt");
if ( !Seiscomp::Util::fileExists(path.string()) ) {
path = SC_FS_PATH(env->configDir())
/ SC_FS_PATH("key") / SC_FS_PATH("License.crt");
}
}
X509 *x509 = readCertificate(path.string());
if ( x509 ) {
ASN1_TIME* notAfter = X509_get_notAfter(x509),
* notBefore = X509_get_notBefore(x509);
time_t ptime = time(NULL);
int res = X509_cmp_time(notBefore, &ptime);
if ( res == 0 || res > 0 ) {
X509_free(x509);
cerr << "FATAL ERROR: License has expired: " << path.string() << endl;
return false;
}
res = X509_cmp_time(notAfter, &ptime);
if ( res == 0 || res < 0 ) {
X509_free(x509);
cerr << "FATAL ERROR: License has expired: " << path.string() << endl;
return false;
}
OpenSSL_add_all_algorithms();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
EVP_PKEY* pkey=X509_get_pubkey(x509);
if ( !pkey ) {
X509_free(x509);
EVP_cleanup();
cerr << "FATAL ERROR: License verification has failed: " << path.string() << endl;
return false;
}
res = X509_verify(x509, pkey);
if ( res != 1 ) {
X509_free(x509);
EVP_PKEY_free(pkey);
EVP_cleanup();
cerr << "FATAL ERROR: License verification has failed: " << path.string() << endl;
return false;
}
char *buf;
if ( readNID(&buf, x509, NID_netscape_comment) ) {
licenseText = buf;
delete buf;
}
EVP_PKEY_free(pkey);
X509_free(x509);
EVP_cleanup();
return true;
}
// Read license file
MD5_CTX ctx;
MD5_Init(&ctx);
unsigned char digest[MD5_DIGEST_LENGTH];
char data[64];
size_t len;
ifstream f;
try {
f.open(licenseFile.c_str(), ios_base::in);
}
catch ( std::exception &e ) {
//.........这里部分代码省略.........
示例2: QDialog
StageSelectionDialog(QWidget *parent) : QDialog(parent) {
Environment *env = Environment::Instance();
QVBoxLayout *layout = new QVBoxLayout;
QHBoxLayout *hlayout;
QLabel *label;
label = new QLabel;
QFont f = label->font();
f.setBold(true);
f.setPointSize(f.pointSize()*150/100);
label->setFont(f);
label->setText(tr("Select configuration mode"));
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
layout->addSpacing(fontMetrics().ascent());
// Create dialog here
_systemMode = new QPushButton;
_systemMode->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
_systemMode->setIcon(QIcon(":/res/icons/system-settings.png"));
_systemMode->setIconSize(QSize(72,72));
label = new QLabel;
label->setWordWrap(true);
label->setAlignment(Qt::AlignCenter);
label->setText(QString(tr("Manage system configuration in <i>%1</i>.")).arg(env->appConfigDir().c_str()));
hlayout = new QHBoxLayout;
hlayout->addStretch();
hlayout->addWidget(_systemMode);
hlayout->addStretch();
layout->addLayout(hlayout);
layout->addWidget(label);
QFrame *frame = new QFrame;
frame->setFrameShape(QFrame::HLine);
layout->addWidget(frame);
_userMode = new QPushButton;
_userMode->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
_userMode->setIcon(QIcon(":/res/icons/user-settings.png"));
_userMode->setIconSize(QSize(72,72));
label = new QLabel;
label->setWordWrap(true);
label->setAlignment(Qt::AlignCenter);
label->setText(QString(tr("Manage user configuration in <i>%1</i>.")).arg(env->configDir().c_str()));
hlayout = new QHBoxLayout;
hlayout->addStretch();
hlayout->addWidget(_userMode);
hlayout->addStretch();
layout->addLayout(hlayout);
layout->addWidget(label);
layout->addStretch();
setLayout(layout);
connect(_userMode, SIGNAL(clicked()), this, SLOT(accept()));
connect(_systemMode, SIGNAL(clicked()), this, SLOT(accept()));
}