void QDirectFBPixmapData::fill(const QColor &color) { if (!serialNumber()) return; Q_ASSERT(dfbSurface); alpha |= (color.alpha() < 255); if (alpha && isOpaqueFormat(imageFormat)) { QSize size; dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight()); screen->releaseDFBSurface(dfbSurface); imageFormat = screen->alphaPixmapFormat(); d = QDirectFBScreen::depth(imageFormat); dfbSurface = screen->createDFBSurface(size, screen->alphaPixmapFormat(), QDirectFBScreen::TrackSurface); setSerialNumber(++global_ser_no); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fill()"); invalidate(); return; } } dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), color.alpha()); }
void PhilipsHue::createCentral() { try { if(_central) return; int32_t seedNumber = BaseLib::HelperFunctions::getRandomNumber(1, 9999999); std::ostringstream stringstream; stringstream << "VHC" << std::setw(7) << std::setfill('0') << std::dec << seedNumber; std::string serialNumber(stringstream.str()); _central.reset(new PhilipsHueCentral(0, serialNumber, 1, this)); GD::out.printMessage("Created central with id " + std::to_string(_central->getId()) + ", address 0x" + BaseLib::HelperFunctions::getHexString(1, 6) + " and serial number " + serialNumber); } catch(const std::exception& ex) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(BaseLib::Exception& ex) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(...) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__); } }
void Miscellaneous::createCentral() { try { if(_central) return; std::string serialNumber(getUniqueSerialNumber("VMC", BaseLib::HelperFunctions::getRandomNumber(1, 9999999))); _central.reset(new MiscCentral(0, serialNumber, this)); add(_central); GD::out.printMessage("Created Miscellaneous central with id " + std::to_string(_central->getID()) + " and serial number " + serialNumber); } catch(const std::exception& ex) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(BaseLib::Exception& ex) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(...) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__); } }
bool QDirectFBPixmapData::hasAlphaChannel() const { if (!serialNumber()) return false; DFBSurfacePixelFormat format; surface->GetPixelFormat(surface, &format); switch (format) { case DSPF_ARGB1555: case DSPF_ARGB: case DSPF_LUT8: case DSPF_AiRGB: case DSPF_A1: case DSPF_ARGB2554: case DSPF_ARGB4444: case DSPF_AYUV: case DSPF_A4: case DSPF_ARGB1666: case DSPF_ARGB6666: case DSPF_LUT2: return true; default: return false; } }
QVariant Certificate::detailResult(Certificate::Details detail) const { switch(detail) { case Details::EXPIRATION_DATE : return expirationDate (); case Details::ACTIVATION_DATE : return activationDate (); case Details::REQUIRE_PRIVATE_KEY_PASSWORD : return requirePrivateKeyPassword (); case Details::PUBLIC_SIGNATURE : return publicSignature (); case Details::VERSION_NUMBER : return versionNumber (); case Details::SERIAL_NUMBER : return serialNumber (); case Details::ISSUER : return issuer (); case Details::SUBJECT_KEY_ALGORITHM : return subjectKeyAlgorithm (); case Details::CN : return cn (); case Details::N : return n (); case Details::O : return o (); case Details::SIGNATURE_ALGORITHM : return signatureAlgorithm (); case Details::MD5_FINGERPRINT : return md5Fingerprint (); case Details::SHA1_FINGERPRINT : return sha1Fingerprint (); case Details::PUBLIC_KEY_ID : return publicKeyId (); case Details::ISSUER_DN : return issuerDn (); case Details::NEXT_EXPECTED_UPDATE_DATE : return nextExpectedUpdateDate (); case Details::OUTGOING_SERVER : return outgoingServer (); case Details::COUNT__: Q_ASSERT(false); }; return QVariant(); }
void BidCoS::createCentral() { try { if(_central) return; int32_t address = 0; std::string addressHex = GD::settings->get("centraladdress"); if(!addressHex.empty()) address = BaseLib::Math::getNumber(addressHex); if(address == 0) address = (0xfd << 16) + BaseLib::HelperFunctions::getRandomNumber(0, 0xFFFF); int32_t seedNumber = BaseLib::HelperFunctions::getRandomNumber(1, 9999999); std::ostringstream stringstream; stringstream << "VBC" << std::setw(7) << std::setfill('0') << std::dec << seedNumber; std::string serialNumber(stringstream.str()); _central.reset(new HomeMaticCentral(0, serialNumber, address, this)); GD::out.printMessage("Created HomeMatic BidCoS central with id " + std::to_string(_central->getId()) + ", address 0x" + BaseLib::HelperFunctions::getHexString(address, 6) + " and serial number " + serialNumber); } catch(const std::exception& ex) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(BaseLib::Exception& ex) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(...) { GD::out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__); } }
uint EFXFixture::timeOffset() const { if (m_parent->propagationMode() == EFX::Asymmetric || m_parent->propagationMode() == EFX::Serial) { return m_parent->duration() / (m_parent->fixtures().size() + 1) * serialNumber(); } else { return 0; } }
void QDirectFBPixmapData::fill(const QColor &color) { if (!serialNumber()) return; Q_ASSERT(surface); if (color.alpha() < 255 && !hasAlphaChannel()) { // convert to surface supporting alpha channel DFBSurfacePixelFormat format; surface->GetPixelFormat(surface, &format); switch (format) { case DSPF_YUY2: case DSPF_UYVY: format = DSPF_AYUV; break; #if (Q_DIRECTFB_VERSION >= 0x010100) case DSPF_RGB444: format = DSPF_ARGB4444; break; case DSPF_RGB555: #endif case DSPF_RGB18: format = DSPF_ARGB6666; break; default: format = DSPF_ARGB; break; } DFBSurfaceDescription description; description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT); surface->GetSize(surface, &description.width, &description.height); description.pixelformat = format; surface->Release(surface); // release old surface IDirectFB *fb = QDirectFBScreen::instance()->dfb(); DFBResult result = fb->CreateSurface(fb, &description, &surface); if (result != DFB_OK) { DirectFBError("QDirectFBPixmapData::fill()", result); setSerialNumber(0); return; } } surface->Clear(surface, color.red(), color.green(), color.blue(), color.alpha()); }
void ServerDriver::hooksTrackedDeviceActivated(void* serverDriver, int version, uint32_t unObjectId) { LOG(TRACE) << "ServerDriver::hooksTrackedDeviceActivated(" << serverDriver << ", " << version << ", " << unObjectId << ")"; auto i = _deviceManipulationHandles.find(serverDriver); if (i != _deviceManipulationHandles.end()) { auto handle = i->second; handle->setOpenvrId(unObjectId); _openvrIdToDeviceManipulationHandleMap[unObjectId] = handle.get(); // get device property container auto container = vr::VRPropertiesRaw()->TrackedDeviceToPropertyContainer(unObjectId); handle->setPropertyContainer(container); _propertyContainerToDeviceManipulationHandleMap[container] = handle.get(); LOG(INFO) << "Successfully added device " << handle->serialNumber() << " (OpenVR Id: " << handle->openvrId() << ")"; } }
int QDirectFBPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!serialNumber()) return 0; switch (metric) { case QPaintDevice::PdmWidth: { int w, h; surface->GetSize(surface, &w, &h); return w; } case QPaintDevice::PdmHeight: { int w, h; surface->GetSize(surface, &w, &h); return h; } case QPaintDevice::PdmWidthMM: { int w, h; surface->GetSize(surface, &w, &h); return qRound(w * qreal(25.4) / qt_defaultDpiX()); } case QPaintDevice::PdmHeightMM: { int w, h; surface->GetSize(surface, &w, &h); return qRound(h * qreal(25.4) / qt_defaultDpiY()); } case QPaintDevice::PdmNumColors: { return (1 << depth()); // hw: make inline } case QPaintDevice::PdmDepth: { DFBSurfacePixelFormat format; surface->GetPixelFormat(surface, &format); return QDirectFBScreen::depth(format); } case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmDpiX: { return qt_defaultDpiX(); } case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmDpiY: { return qt_defaultDpiY(); } default: qCritical("QDirectFBScreen::metric(): Unhandled metric!"); return 0; } }
// ---------------------------------------------------------------------------- // UntrustedCertificateInfoSymbian::certificateDetails() // ---------------------------------------------------------------------------- // QString UntrustedCertificateInfoSymbian::certificateDetails(const QString &siteName) const { // TODO: localized UI string needed QString details = tr("Service:\n%1\n\nIssuer:\n%2\n\nSubject:\n%3\n\n" "Valid from:\n%4\n\nValid until:\n%5\n\nCertificate format:\n%6\n\n" "Algorithm:\n%7\n\nSerial number:\n%8\n\n" "Fingerprint (SHA1):\n%9\n\nFingerprint (MD5):\n%10") .arg(siteName) // %1 .arg(issuerName()) // %2 .arg(subjectName()) // %3 .arg(validFrom().toString()) // %4 .arg(validTo().toString()) // %5 .arg(format()) // %6 .arg(combinedAlgorithmName()) // %7 .arg(formattedSerialNumber(serialNumber())) // %8 .arg(formattedFingerprint(fingerprint())) // %9 .arg(formattedFingerprint(mMd5Fingerprint)); // %10 return details; }
Result CreateEncodedOCSPRequest(TrustDomain& trustDomain, const struct CertID& certID, /*out*/ uint8_t (&out)[OCSP_REQUEST_MAX_LENGTH], /*out*/ size_t& outLen) { // We do not add any extensions to the request. // RFC 6960 says "An OCSP client MAY wish to specify the kinds of response // types it understands. To do so, it SHOULD use an extension with the OID // id-pkix-ocsp-response." This use of MAY and SHOULD is unclear. MSIE11 // on Windows 8.1 does not include any extensions, whereas NSS has always // included the id-pkix-ocsp-response extension. Avoiding the sending the // extension is better for OCSP GET because it makes the request smaller, // and thus more likely to fit within the 255 byte limit for OCSP GET that // is specified in RFC 5019 Section 5. // Bug 966856: Add the id-pkix-ocsp-pref-sig-algs extension. // Since we don't know whether the OCSP responder supports anything other // than SHA-1, we have no choice but to use SHA-1 for issuerNameHash and // issuerKeyHash. static const uint8_t hashAlgorithm[11] = { 0x30, 0x09, // SEQUENCE 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, // OBJECT IDENTIFIER id-sha1 0x05, 0x00, // NULL }; static const uint8_t hashLen = TrustDomain::DIGEST_LENGTH; static const unsigned int totalLenWithoutSerialNumberData = 2 // OCSPRequest + 2 // tbsRequest + 2 // requestList + 2 // Request + 2 // reqCert (CertID) + sizeof(hashAlgorithm) // hashAlgorithm + 2 + hashLen // issuerNameHash + 2 + hashLen // issuerKeyHash + 2; // serialNumber (header) // The only way we could have a request this large is if the serialNumber was // ridiculously and unreasonably large. RFC 5280 says "Conforming CAs MUST // NOT use serialNumber values longer than 20 octets." With this restriction, // we allow for some amount of non-conformance with that requirement while // still ensuring we can encode the length values in the ASN.1 TLV structures // in a single byte. static_assert(totalLenWithoutSerialNumberData < OCSP_REQUEST_MAX_LENGTH, "totalLenWithoutSerialNumberData too big"); if (certID.serialNumber.GetLength() > OCSP_REQUEST_MAX_LENGTH - totalLenWithoutSerialNumberData) { return Result::ERROR_BAD_DER; } outLen = totalLenWithoutSerialNumberData + certID.serialNumber.GetLength(); uint8_t totalLen = static_cast<uint8_t>(outLen); uint8_t* d = out; *d++ = 0x30; *d++ = totalLen - 2u; // OCSPRequest (SEQUENCE) *d++ = 0x30; *d++ = totalLen - 4u; // tbsRequest (SEQUENCE) *d++ = 0x30; *d++ = totalLen - 6u; // requestList (SEQUENCE OF) *d++ = 0x30; *d++ = totalLen - 8u; // Request (SEQUENCE) *d++ = 0x30; *d++ = totalLen - 10u; // reqCert (CertID SEQUENCE) // reqCert.hashAlgorithm for (size_t i = 0; i < sizeof(hashAlgorithm); ++i) { *d++ = hashAlgorithm[i]; } // reqCert.issuerNameHash (OCTET STRING) *d++ = 0x04; *d++ = hashLen; Result rv = trustDomain.DigestBuf(certID.issuer, d, hashLen); if (rv != Success) { return rv; } d += hashLen; // reqCert.issuerKeyHash (OCTET STRING) *d++ = 0x04; *d++ = hashLen; rv = KeyHash(trustDomain, certID.issuerSubjectPublicKeyInfo, d, hashLen); if (rv != Success) { return rv; } d += hashLen; // reqCert.serialNumber (INTEGER) *d++ = 0x02; // INTEGER *d++ = static_cast<uint8_t>(certID.serialNumber.GetLength()); Reader serialNumber(certID.serialNumber); do { rv = serialNumber.Read(*d); if (rv != Success) { return rv; } ++d; } while (!serialNumber.AtEnd()); assert(d == out + totalLen); return Success; }