本文整理匯總了C++中CFNumberGetValue函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFNumberGetValue函數的具體用法?C++ CFNumberGetValue怎麽用?C++ CFNumberGetValue使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFNumberGetValue函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CopyUserVisibleNameForEthernetPort
//.........這裏部分代碼省略.........
junk = CFQDictionarySetNumber(interfaceInfo, kSortOrderKey, kEthernetPCISortOrder);
assert(junk == 0);
// Get "AAPL,slot-name" property from I/O Registry and copy it into
// our interfaceInfo dictionary. But first, mutate the slot name
// into a user-visible name version.
slotName = NULL;
slotNameAsData = (CFDataRef) IORegistryEntryCreateCFProperty(bus, CFSTR("AAPL,slot-name"), NULL, kNilOptions);
if (slotNameAsData != NULL) {
slotName = CreateStringFromData(slotNameAsData);
}
if (slotName != NULL) {
CFStringRef tmp;
tmp = CopyUserVisibleSlotName(slotName);
if (tmp != NULL) {
CFQRelease(slotName);
slotName = tmp;
}
}
if (slotName == NULL) {
CFDictionarySetValue(interfaceInfo, CFSTR("AAPL,slot-name"), CFSTR("unknown"));
} else {
CFDictionarySetValue(interfaceInfo, CFSTR("AAPL,slot-name"), slotName);
}
CFQRelease(slotName);
// Now get the IOChildIndex property to decide whether it's a single
// or multi-port Ethernet card.
portNum = (CFNumberRef) CFDictionaryGetValue(busDict, CFSTR("IOChildIndex"));
if ( (portNum == NULL) || ! CFNumberGetValue(portNum, kCFNumberSInt32Type, &junkNum) ) {
// single-port pci enet card
// Either there is no IOChildIndex property, or it doesn't contain a
// valid number.
*userVisibleName = (CFStringRef) CFQRetain( kMoreSCPortLabelEthernetPCI );
} else {
CFNumberRef portNumRef;
SInt32 portNum;
CFStringRef portNumString;
// multi-port pci enet card
// Get "IOChildIndex" property from I/O Registry and copy it into
// our interfaceInfo dictionary.
portNumString = NULL;
portNumRef = (CFNumberRef) IORegistryEntryCreateCFProperty(bus, CFSTR("IOChildIndex"), NULL, kNilOptions);
if ( (portNumRef != NULL) && CFNumberGetValue(portNumRef, kCFNumberSInt32Type, &portNum) ) {
portNumString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%ld"), portNum + 1);
}
if (portNumString == NULL) {
CFDictionarySetValue(interfaceInfo, CFSTR("IOChildIndex"), CFSTR("unknown"));
} else {
CFDictionarySetValue(interfaceInfo, CFSTR("IOChildIndex"), portNumString);
}
CFQRelease(portNumString);
CFQRelease(portNumRef);
*userVisibleName = (CFStringRef) CFQRetain( kMoreSCPortLabelEthernetPCIMultiport );
}
} else {
示例2: tests
static void tests(void)
{
CFErrorRef error = NULL;
CFDataRef cfpassword = CFDataCreate(NULL, (uint8_t *) "FooFooFoo", 10);
CFDataRef cfwrong_password = CFDataCreate(NULL, (uint8_t *) "NotFooFooFoo", 10);
CFStringRef cfaccount = CFSTR("[email protected]");
CFMutableDictionaryRef changes = CFDictionaryCreateMutableForCFTypes(kCFAllocatorDefault);
SOSAccountRef alice_account = CreateAccountForLocalChanges(CFSTR("Alice"), CFSTR("TestSource"));
SOSAccountRef bob_account = CreateAccountForLocalChanges(CFSTR("Bob"), CFSTR("TestSource"));
SOSAccountRef carol_account = CreateAccountForLocalChanges(CFSTR("Carol"), CFSTR("TestSource"));
ok(SOSAccountAssertUserCredentialsAndUpdate(bob_account, cfaccount, cfpassword, &error), "Credential setting (%@)", error);
// Bob wins writing at this point, feed the changes back to alice.
is(ProcessChangesUntilNoChange(changes, alice_account, bob_account, NULL), 1, "updates");
ok(SOSAccountAssertUserCredentialsAndUpdate(alice_account, cfaccount, cfpassword, &error), "Credential setting (%@)", error);
CFReleaseNull(error);
ok(SOSAccountTryUserCredentials(alice_account, cfaccount, cfpassword, &error), "Credential trying (%@)", error);
CFReleaseNull(error);
ok(!SOSAccountTryUserCredentials(alice_account, cfaccount, cfwrong_password, &error), "Credential failing (%@)", error);
CFReleaseNull(cfwrong_password);
is(error ? CFErrorGetCode(error) : 0, kSOSErrorWrongPassword, "Expected SOSErrorWrongPassword");
CFReleaseNull(error);
ok(SOSAccountResetToOffering_wTxn(alice_account, &error), "Reset to offering (%@)", error);
CFReleaseNull(error);
is(ProcessChangesUntilNoChange(changes, alice_account, bob_account, NULL), 2, "updates");
ok(SOSAccountJoinCircles_wTxn(bob_account, &error), "Bob Applies (%@)", error);
CFReleaseNull(error);
is(ProcessChangesUntilNoChange(changes, alice_account, bob_account, NULL), 2, "updates");
{
CFArrayRef applicants = SOSAccountCopyApplicants(alice_account, &error);
ok(applicants && CFArrayGetCount(applicants) == 1, "See one applicant %@ (%@)", applicants, error);
ok(SOSAccountAcceptApplicants(alice_account, applicants, &error), "Alice accepts (%@)", error);
CFReleaseNull(error);
CFReleaseNull(applicants);
}
is(ProcessChangesUntilNoChange(changes, alice_account, bob_account, NULL), 3, "updates");
accounts_agree("bob&alice pair", bob_account, alice_account);
CFArrayRef peers = SOSAccountCopyPeers(alice_account, &error);
ok(peers && CFArrayGetCount(peers) == 2, "See two peers %@ (%@)", peers, error);
CFReleaseNull(peers);
//bob now goes def while Alice does some stuff.
ok(SOSAccountLeaveCircle(alice_account, &error), "ALICE LEAVES THE CIRCLE (%@)", error);
ok(SOSAccountResetToOffering_wTxn(alice_account, &error), "Alice resets to offering again (%@)", error);
is(ProcessChangesUntilNoChange(changes, alice_account, bob_account, NULL), 2, "updates");
accounts_agree("bob&alice pair", bob_account, alice_account);
is(ProcessChangesUntilNoChange(changes, alice_account, bob_account, carol_account, NULL), 1, "updates");
ok(SOSAccountAssertUserCredentialsAndUpdate(carol_account, cfaccount, cfpassword, &error), "Credential setting (%@)", error);
SOSAccountSetUserPublicTrustedForTesting(carol_account);
ok(SOSAccountResetToOffering_wTxn(carol_account, &error), "Carol is going to push a reset to offering (%@)", error);
int64_t valuePtr = 0;
CFNumberRef gencount = CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &valuePtr);
SOSCircleSetGeneration(carol_account->trusted_circle, gencount);
SecKeyRef user_privkey = SOSUserKeygen(cfpassword, carol_account->user_key_parameters, &error);
CFNumberRef genCountTest = SOSCircleGetGeneration(carol_account->trusted_circle);
CFIndex testPtr;
CFNumberGetValue(genCountTest, kCFNumberCFIndexType, &testPtr);
ok(testPtr== 0);
SOSCircleSignOldStyleResetToOfferingCircle(carol_account->trusted_circle, carol_account->my_identity, user_privkey, &error);
SOSTransportCircleTestRemovePendingChange(carol_account->circle_transport, SOSCircleGetName(carol_account->trusted_circle), NULL);
CFDataRef circle_data = SOSCircleCopyEncodedData(carol_account->trusted_circle, kCFAllocatorDefault, &error);
if (circle_data) {
SOSTransportCirclePostCircle(carol_account->circle_transport, SOSCircleGetName(carol_account->trusted_circle), circle_data, &error);
}
genCountTest = SOSCircleGetGeneration(carol_account->trusted_circle);
CFNumberGetValue(genCountTest, kCFNumberCFIndexType, &testPtr);
ok(testPtr== 0);
ok(SOSAccountAssertUserCredentialsAndUpdate(bob_account, cfaccount, cfpassword, &error), "Credential setting (%@)", error);
ok(SOSAccountAssertUserCredentialsAndUpdate(alice_account, cfaccount, cfpassword, &error), "Credential setting (%@)", error);
SOSAccountSetUserPublicTrustedForTesting(alice_account);
SOSAccountSetUserPublicTrustedForTesting(bob_account);
is(ProcessChangesUntilNoChange(changes, carol_account, alice_account, bob_account, NULL), 2, "updates");
ok(kSOSCCNotInCircle == SOSAccountGetCircleStatus(alice_account, &error), "alice is not in the account (%@)", error);
ok(kSOSCCNotInCircle == SOSAccountGetCircleStatus(bob_account, &error), "bob is not in the account (%@)", error);
//.........這裏部分代碼省略.........
示例3: stream
bool FLACMetadata::WriteMetadata(CFErrorRef *error)
{
UInt8 buf [PATH_MAX];
if(!CFURLGetFileSystemRepresentation(mURL, false, buf, PATH_MAX))
return false;
// TODO: Use unique_ptr once the switch to C++11 STL is made
std::auto_ptr<TagLib::FileStream> stream(new TagLib::FileStream(reinterpret_cast<const char *>(buf)));
if(!stream->isOpen()) {
if(error) {
CFStringRef description = CFCopyLocalizedString(CFSTR("The file “%@” could not be opened for writing."), "");
CFStringRef failureReason = CFCopyLocalizedString(CFSTR("Input/output error"), "");
CFStringRef recoverySuggestion = CFCopyLocalizedString(CFSTR("The file may have been renamed, moved, deleted, or you may not have appropriate permissions."), "");
*error = CreateErrorForURL(AudioMetadataErrorDomain, AudioMetadataInputOutputError, description, mURL, failureReason, recoverySuggestion);
CFRelease(description), description = nullptr;
CFRelease(failureReason), failureReason = nullptr;
CFRelease(recoverySuggestion), recoverySuggestion = nullptr;
}
return false;
}
TagLib::FLAC::File file(stream.get(), TagLib::ID3v2::FrameFactory::instance(), false);
if(!file.isValid()) {
if(error) {
CFStringRef description = CFCopyLocalizedString(CFSTR("The file “%@” is not a valid FLAC file."), "");
CFStringRef failureReason = CFCopyLocalizedString(CFSTR("Not a FLAC file"), "");
CFStringRef recoverySuggestion = CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), "");
*error = CreateErrorForURL(AudioMetadataErrorDomain, AudioMetadataInputOutputError, description, mURL, failureReason, recoverySuggestion);
CFRelease(description), description = nullptr;
CFRelease(failureReason), failureReason = nullptr;
CFRelease(recoverySuggestion), recoverySuggestion = nullptr;
}
return false;
}
// ID3v1 and ID3v2 tags are only written if present, but a Xiph comment is always written
if(file.ID3v1Tag())
SetID3v1TagFromMetadata(*this, file.ID3v1Tag());
if(file.ID3v2Tag())
SetID3v2TagFromMetadata(*this, file.ID3v2Tag());
SetXiphCommentFromMetadata(*this, file.xiphComment(true), false);
// Remove existing cover art
file.removePictures();
// Add album art
for(auto attachedPicture : GetAttachedPictures()) {
CGImageSourceRef imageSource = CGImageSourceCreateWithData(attachedPicture->GetData(), nullptr);
if(nullptr == imageSource) {
LOGGER_ERR("org.sbooth.AudioEngine.AudioMetadata.FLAC", "Skipping album art (unable to create image)");
continue;
}
TagLib::FLAC::Picture *picture = new TagLib::FLAC::Picture;
picture->setData(TagLib::ByteVector((const char *)CFDataGetBytePtr(attachedPicture->GetData()), (TagLib::uint)CFDataGetLength(attachedPicture->GetData())));
picture->setType(static_cast<TagLib::FLAC::Picture::Type>(attachedPicture->GetType()));
if(attachedPicture->GetDescription())
picture->setDescription(TagLib::StringFromCFString(attachedPicture->GetDescription()));
// Convert the image's UTI into a MIME type
CFStringRef mimeType = UTTypeCopyPreferredTagWithClass(CGImageSourceGetType(imageSource), kUTTagClassMIMEType);
if(mimeType) {
picture->setMimeType(TagLib::StringFromCFString(mimeType));
CFRelease(mimeType), mimeType = nullptr;
}
// Flesh out the height, width, and depth
CFDictionaryRef imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nullptr);
if(imagePropertiesDictionary) {
CFNumberRef imageWidth = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelWidth);
CFNumberRef imageHeight = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelHeight);
CFNumberRef imageDepth = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyDepth);
int height, width, depth;
// Ignore numeric conversion errors
CFNumberGetValue(imageWidth, kCFNumberIntType, &width);
CFNumberGetValue(imageHeight, kCFNumberIntType, &height);
CFNumberGetValue(imageDepth, kCFNumberIntType, &depth);
picture->setHeight(height);
picture->setWidth(width);
picture->setColorDepth(depth);
CFRelease(imagePropertiesDictionary), imagePropertiesDictionary = nullptr;
}
file.addPicture(picture);
CFRelease(imageSource), imageSource = nullptr;
//.........這裏部分代碼省略.........
示例4: CFAttributedStringGetString
void InbandTextTrackPrivateAVF::processCueAttributes(CFAttributedStringRef attributedString, GenericCueData* cueData)
{
// Some of the attributes we translate into per-cue WebVTT settings are are repeated on each part of an attributed string so only
// process the first instance of each.
enum AttributeFlags {
Line = 1 << 0,
Position = 1 << 1,
Size = 1 << 2,
Vertical = 1 << 3,
Align = 1 << 4,
FontName = 1 << 5
};
unsigned processed = 0;
StringBuilder content;
String attributedStringValue = CFAttributedStringGetString(attributedString);
CFIndex length = attributedStringValue.length();
if (!length)
return;
CFRange effectiveRange = CFRangeMake(0, 0);
while ((effectiveRange.location + effectiveRange.length) < length) {
CFDictionaryRef attributes = CFAttributedStringGetAttributes(attributedString, effectiveRange.location + effectiveRange.length, &effectiveRange);
if (!attributes)
continue;
StringBuilder tagStart;
CFStringRef valueString;
String tagEnd;
CFIndex attributeCount = CFDictionaryGetCount(attributes);
Vector<const void*> keys(attributeCount);
Vector<const void*> values(attributeCount);
CFDictionaryGetKeysAndValues(attributes, keys.data(), values.data());
for (CFIndex i = 0; i < attributeCount; ++i) {
CFStringRef key = static_cast<CFStringRef>(keys[i]);
CFTypeRef value = values[i];
if (CFGetTypeID(key) != CFStringGetTypeID() || !CFStringGetLength(key))
continue;
if (CFStringCompare(key, kCMTextMarkupAttribute_Alignment, 0) == kCFCompareEqualTo) {
valueString = static_cast<CFStringRef>(value);
if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
continue;
if (processed & Align)
continue;
processed |= Align;
if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Start, 0) == kCFCompareEqualTo)
cueData->setAlign(GenericCueData::Start);
else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Middle, 0) == kCFCompareEqualTo)
cueData->setAlign(GenericCueData::Middle);
else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_End, 0) == kCFCompareEqualTo)
cueData->setAlign(GenericCueData::End);
else
ASSERT_NOT_REACHED();
continue;
}
if (CFStringCompare(key, kCMTextMarkupAttribute_BoldStyle, 0) == kCFCompareEqualTo) {
if (static_cast<CFBooleanRef>(value) != kCFBooleanTrue)
continue;
tagStart.append("<b>");
tagEnd.insert("</b>", 0);
continue;
}
if (CFStringCompare(key, kCMTextMarkupAttribute_ItalicStyle, 0) == kCFCompareEqualTo) {
if (static_cast<CFBooleanRef>(value) != kCFBooleanTrue)
continue;
tagStart.append("<i>");
tagEnd.insert("</i>", 0);
continue;
}
if (CFStringCompare(key, kCMTextMarkupAttribute_UnderlineStyle, 0) == kCFCompareEqualTo) {
if (static_cast<CFBooleanRef>(value) != kCFBooleanTrue)
continue;
tagStart.append("<u>");
tagEnd.insert("</u>", 0);
continue;
}
if (CFStringCompare(key, kCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection, 0) == kCFCompareEqualTo) {
if (CFGetTypeID(value) != CFNumberGetTypeID())
continue;
if (processed & Line)
continue;
processed |= Line;
CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
double line;
CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &line);
cueData->setLine(line);
continue;
//.........這裏部分代碼省略.........
示例5: CFNumberGetValue
pid_t HP_HogMode::GetOwnerFromPreference(bool inSendNotifications) const
{
pid_t theAnswer = -1;
#if HogMode_UseCFPrefs
// get the preference
CFNumberRef theCFNumber = CACFPreferences::CopyNumberValue(mPrefName, false, true);
if(theCFNumber != NULL)
{
// get the number
pid_t theOwner = -1;
CFNumberGetValue(theCFNumber, kCFNumberSInt32Type, &theOwner);
// make sure the process exists
if(theOwner == -1)
{
// hog mode is free
theAnswer = -1;
}
else if(CAProcess::ProcessExists(theOwner))
{
// it does, so set the return value
theAnswer = theOwner;
}
else
{
// it doesn't, so delete the pref
SetOwnerInPreference((pid_t)-1);
if(inSendNotifications)
{
// signal that hog mode changed
SendHogModeChangedNotification();
}
}
CFRelease(theCFNumber);
}
#else
// get the owner from the preference
SInt32 theOwner = -1;
sSettingsStorage->CopySInt32Value(mPrefName, theOwner, SInt32(-1));
// make sure the process exists
if(theOwner == -1)
{
// hog mode is free
theAnswer = -1;
}
else if(CAProcess::ProcessExists(theOwner))
{
// the process that owns hog mode exists
theAnswer = theOwner;
}
else
{
// the process that owns hog mode doesn't exist, so delete the pref
theAnswer = -1;
SetOwnerInPreference((pid_t)-1);
if(inSendNotifications)
{
// signal that hog mode changed
SendHogModeChangedNotification();
}
}
#endif
return theAnswer;
}
示例6: upsdrv_updateinfo
void upsdrv_updateinfo(void)
{
CFPropertyListRef power_dictionary;
CFStringRef power_source_state;
CFNumberRef battery_voltage, battery_runtime;
CFNumberRef current_capacity;
CFBooleanRef is_charging;
double max_capacity_value = 100.0, current_capacity_value;
upsdebugx(1, "upsdrv_updateinfo()");
power_dictionary = copy_power_dictionary( g_power_key );
assert(power_dictionary); /* TODO: call dstate_datastale()? */
status_init();
/* Retrieve OL/OB state */
power_source_state = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSPowerSourceStateKey));
assert(power_source_state);
CFRetain(power_source_state);
upsdebugx(3, "Power Source State:");
if(nut_debug_level >= 3) CFShow(power_source_state);
if(!CFStringCompare(power_source_state, CFSTR(kIOPSACPowerValue), 0)) {
status_set("OL");
} else {
status_set("OB");
}
CFRelease(power_source_state);
/* Retrieve CHRG state */
is_charging = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSIsChargingKey));
if(is_charging) {
Boolean is_charging_value;
is_charging_value = CFBooleanGetValue(is_charging);
if(is_charging_value) {
status_set("CHRG");
}
}
status_commit();
/* Retrieve battery voltage */
battery_voltage = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSVoltageKey));
if(battery_voltage) {
int battery_voltage_value;
CFNumberGetValue(battery_voltage, kCFNumberIntType, &battery_voltage_value);
upsdebugx(2, "battery_voltage = %d mV", battery_voltage_value);
dstate_setinfo("battery.voltage", "%.3f", battery_voltage_value/1000.0);
}
/* Retrieve battery runtime */
battery_runtime = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSTimeToEmptyKey));
if(battery_runtime) {
double battery_runtime_value;
CFNumberGetValue(battery_runtime, kCFNumberDoubleType, &battery_runtime_value);
upsdebugx(2, "battery_runtime = %.f minutes", battery_runtime_value);
if(battery_runtime_value > 0) {
dstate_setinfo("battery.runtime", "%d", (int)(battery_runtime_value*60));
} else {
dstate_delinfo("battery.runtime");
}
} else {
dstate_delinfo("battery.runtime");
}
/* Retrieve current capacity */
current_capacity = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSCurrentCapacityKey));
if(current_capacity) {
CFNumberGetValue(current_capacity, kCFNumberDoubleType, ¤t_capacity_value);
upsdebugx(2, "Current Capacity = %.f/%.f units", current_capacity_value, max_capacity_value);
if(max_capacity_value > 0) {
dstate_setinfo("battery.charge", "%.f", 100.0 * current_capacity_value / max_capacity_value);
}
}
/* TODO: it should be possible to set poll_interval (and maxage in the
* server) to an absurdly large value, and use notify(3) to get
* updates.
*/
/*
* poll_interval = 2;
*/
dstate_dataok();
CFRelease(power_dictionary);
}
示例7: CFRelease
/* Note that AC power sources also include a laptop battery it is charging. */
void power_osx::checkps(CFDictionaryRef dict, bool *have_ac, bool *have_battery, bool *charging) {
CFStringRef strval; /* don't CFRelease() this. */
CFBooleanRef bval;
CFNumberRef numval;
bool charge = false;
bool choose = false;
bool is_ac = false;
int secs = -1;
int maxpct = -1;
int pct = -1;
if ((GETVAL(kIOPSIsPresentKey, &bval)) && (bval == kCFBooleanFalse)) {
return; /* nothing to see here. */
}
if (!GETVAL(kIOPSPowerSourceStateKey, &strval)) {
return;
}
if (STRMATCH(strval, CFSTR(kIOPSACPowerValue))) {
is_ac = *have_ac = true;
} else if (!STRMATCH(strval, CFSTR(kIOPSBatteryPowerValue))) {
return; /* not a battery? */
}
if ((GETVAL(kIOPSIsChargingKey, &bval)) && (bval == kCFBooleanTrue)) {
charge = true;
}
if (GETVAL(kIOPSMaxCapacityKey, &numval)) {
SInt32 val = -1;
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
if (val > 0) {
*have_battery = true;
maxpct = (int)val;
}
}
if (GETVAL(kIOPSMaxCapacityKey, &numval)) {
SInt32 val = -1;
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
if (val > 0) {
*have_battery = true;
maxpct = (int)val;
}
}
if (GETVAL(kIOPSTimeToEmptyKey, &numval)) {
SInt32 val = -1;
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
/* Mac OS X reports 0 minutes until empty if you're plugged in. :( */
if ((val == 0) && (is_ac)) {
val = -1; /* !!! FIXME: calc from timeToFull and capacity? */
}
secs = (int)val;
if (secs > 0) {
secs *= 60; /* value is in minutes, so convert to seconds. */
}
}
if (GETVAL(kIOPSCurrentCapacityKey, &numval)) {
SInt32 val = -1;
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
pct = (int)val;
}
if ((pct > 0) && (maxpct > 0)) {
pct = (int)((((double)pct) / ((double)maxpct)) * 100.0);
}
if (pct > 100) {
pct = 100;
}
/*
* We pick the battery that claims to have the most minutes left.
* (failing a report of minutes, we'll take the highest percent.)
*/
if ((secs < 0) && (nsecs_left < 0)) {
if ((pct < 0) && (percent_left < 0)) {
choose = true; /* at least we know there's a battery. */
}
if (pct > percent_left) {
choose = true;
}
} else if (secs > nsecs_left) {
choose = true;
}
if (choose) {
nsecs_left = secs;
percent_left = pct;
*charging = charge;
}
}
示例8: ReadHashStateFile
//.........這裏部分代碼省略.........
if ( myReplicaDataFileRef == NULL )
{
returnValue = -1;
break;
}
myReadStreamRef = CFReadStreamCreateWithFile( kCFAllocatorDefault, myReplicaDataFileRef );
CFRelease( myReplicaDataFileRef );
if ( myReadStreamRef == NULL )
{
returnValue = -1;
break;
}
CFReadStreamOpen( myReadStreamRef );
errorString = NULL;
myPLFormat = kCFPropertyListXMLFormat_v1_0;
myPropertyListRef = CFPropertyListCreateFromStream( kCFAllocatorDefault, myReadStreamRef, 0,
kCFPropertyListMutableContainersAndLeaves, &myPLFormat, &errorString );
CFReadStreamClose( myReadStreamRef );
CFRelease( myReadStreamRef );
if ( errorString != NULL )
{
char errMsg[256];
if ( CFStringGetCString( errorString, errMsg, sizeof(errMsg), kCFStringEncodingUTF8 ) )
DbgLog(kLogPlugin, "ReadHashStateFile: could not load the state file, error = %s", errMsg );
CFRelease( errorString );
}
if ( myPropertyListRef == NULL )
{
DbgLog(kLogPlugin, "ReadHashStateFile: could not load the hash state file because the property list is empty." );
returnValue = -1;
break;
}
if ( CFGetTypeID(myPropertyListRef) != CFDictionaryGetTypeID() )
{
CFRelease( myPropertyListRef );
DbgLog(kLogPlugin, "ReadHashStateFile: could not load the hash state file because the property list is not a dictionary." );
returnValue = -1;
break;
}
stateDict = (CFMutableDictionaryRef)myPropertyListRef;
keyString = CFStringCreateWithCString( kCFAllocatorDefault, "CreationDate", kCFStringEncodingUTF8 );
if ( keyString != NULL )
{
if ( CFDictionaryGetValueIfPresent( stateDict, keyString, (const void **)&dateValue ) )
{
pwsf_ConvertCFDateToBSDTime( dateValue, &inOutHashState->creationDate );
}
CFRelease( keyString );
}
keyString = CFStringCreateWithCString( kCFAllocatorDefault, "LastLoginDate", kCFStringEncodingUTF8 );
if ( keyString != NULL )
{
if ( CFDictionaryGetValueIfPresent( stateDict, keyString, (const void **)&dateValue ) )
{
pwsf_ConvertCFDateToBSDTime( dateValue, &inOutHashState->lastLoginDate );
}
CFRelease( keyString );
}
keyString = CFStringCreateWithCString( kCFAllocatorDefault, "FailedLoginCount", kCFStringEncodingUTF8 );
if ( keyString != NULL )
{
if ( CFDictionaryGetValueIfPresent( stateDict, keyString, (const void **)&numberValue ) &&
CFGetTypeID(numberValue) == CFNumberGetTypeID() &&
CFNumberGetValue( (CFNumberRef)numberValue, kCFNumberLongType, &aLongValue) )
{
inOutHashState->failedLoginAttempts = (UInt16)aLongValue;
}
CFRelease( keyString );
}
keyString = CFStringCreateWithCString( kCFAllocatorDefault, "NewPasswordRequired", kCFStringEncodingUTF8 );
if ( keyString != NULL )
{
if ( CFDictionaryGetValueIfPresent( stateDict, keyString, (const void **)&numberValue ) &&
CFGetTypeID(numberValue) == CFNumberGetTypeID() &&
CFNumberGetValue( (CFNumberRef)numberValue, kCFNumberSInt16Type, &aShortValue) )
{
inOutHashState->newPasswordRequired = (UInt16)aShortValue;
}
CFRelease( keyString );
}
CFRelease( stateDict );
} while( false );
return returnValue;
}
示例9: OpenLDAPNode
tDirStatus
OpenLDAPNode(
CDSLocalPlugin *inPlugin,
CFMutableDictionaryRef inNodeDict,
tDataListPtr inNodeName,
tDirReference *outDSRef,
tDirNodeReference *outNodeRef )
{
tDirStatus status = eDSNoErr;
tDirReference ldapDirRef = 0;
tDirNodeReference ldapNodeRef = 0;
CFNumberRef ldapNodeRefNumber = NULL;
try
{
CFNumberRef ldapDirRefNumber = (CFNumberRef)CFDictionaryGetValue( inNodeDict, CFSTR(kNodeLDAPDirRef) );
if ( ldapDirRefNumber != NULL )
CFNumberGetValue( ldapDirRefNumber, kCFNumberLongType, &ldapDirRef );
if ( ldapDirRef == 0 )
{
status = inPlugin->GetDirServiceRef( &ldapDirRef );
if ( status != eDSNoErr )
throw( status );
ldapDirRefNumber = CFNumberCreate( NULL, kCFNumberLongType, &ldapDirRef );
CFDictionaryAddValue( inNodeDict, CFSTR(kNodeLDAPDirRef), ldapDirRefNumber );
CFRelease( ldapDirRefNumber );
}
// Free prior LDAP node
ldapNodeRefNumber = (CFNumberRef)CFDictionaryGetValue( inNodeDict, CFSTR(kNodeLDAPNodeRef) );
if ( ldapNodeRefNumber != NULL )
{
CFNumberGetValue( ldapNodeRefNumber, kCFNumberLongType, &ldapNodeRef );
if ( ldapNodeRef != 0 ) {
dsCloseDirNode( ldapNodeRef );
ldapNodeRef = 0;
}
CFDictionaryRemoveValue( inNodeDict, CFSTR(kNodeLDAPNodeRef) );
ldapNodeRefNumber = NULL;
}
status = dsOpenDirNode( ldapDirRef, inNodeName, &ldapNodeRef );
if ( status == eDSNoErr )
{
ldapNodeRefNumber = CFNumberCreate( NULL, kCFNumberLongType, &ldapNodeRef );
CFDictionaryAddValue( inNodeDict, CFSTR(kNodeLDAPNodeRef), ldapNodeRefNumber );
CFRelease( ldapNodeRefNumber );
}
}
catch ( tDirStatus catchStatus )
{
status = catchStatus;
}
*outDSRef = ldapDirRef;
*outNodeRef = ldapNodeRef;
return status;
}
示例10: qtValue
static QVariant qtValue(CFPropertyListRef cfvalue)
{
if (!cfvalue)
return QVariant();
CFTypeID typeId = CFGetTypeID(cfvalue);
/*
Sorted grossly from most to least frequent type.
*/
if (typeId == CFStringGetTypeID()) {
return QSettingsPrivate::stringToVariant(QCFString::toQString(static_cast<CFStringRef>(cfvalue)));
} else if (typeId == CFNumberGetTypeID()) {
CFNumberRef cfnumber = static_cast<CFNumberRef>(cfvalue);
if (CFNumberIsFloatType(cfnumber)) {
double d;
CFNumberGetValue(cfnumber, kCFNumberDoubleType, &d);
return d;
} else {
int i;
qint64 ll;
if (CFNumberGetType(cfnumber) == kCFNumberIntType) {
CFNumberGetValue(cfnumber, kCFNumberIntType, &i);
return i;
}
CFNumberGetValue(cfnumber, kCFNumberLongLongType, &ll);
return ll;
}
} else if (typeId == CFArrayGetTypeID()) {
CFArrayRef cfarray = static_cast<CFArrayRef>(cfvalue);
QList<QVariant> list;
CFIndex size = CFArrayGetCount(cfarray);
bool metNonString = false;
for (CFIndex i = 0; i < size; ++i) {
QVariant value = qtValue(CFArrayGetValueAtIndex(cfarray, i));
if (value.type() != QVariant::String)
metNonString = true;
list << value;
}
if (metNonString)
return list;
else
return QVariant(list).toStringList();
} else if (typeId == CFBooleanGetTypeID()) {
return (bool)CFBooleanGetValue(static_cast<CFBooleanRef>(cfvalue));
} else if (typeId == CFDataGetTypeID()) {
CFDataRef cfdata = static_cast<CFDataRef>(cfvalue);
return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(cfdata)),
CFDataGetLength(cfdata));
} else if (typeId == CFDictionaryGetTypeID()) {
CFDictionaryRef cfdict = static_cast<CFDictionaryRef>(cfvalue);
CFTypeID arrayTypeId = CFArrayGetTypeID();
int size = (int)CFDictionaryGetCount(cfdict);
QVarLengthArray<CFPropertyListRef> keys(size);
QVarLengthArray<CFPropertyListRef> values(size);
CFDictionaryGetKeysAndValues(cfdict, keys.data(), values.data());
QMultiMap<QString, QVariant> map;
for (int i = 0; i < size; ++i) {
QString key = QCFString::toQString(static_cast<CFStringRef>(keys[i]));
if (CFGetTypeID(values[i]) == arrayTypeId) {
CFArrayRef cfarray = static_cast<CFArrayRef>(values[i]);
CFIndex arraySize = CFArrayGetCount(cfarray);
for (CFIndex j = arraySize - 1; j >= 0; --j)
map.insert(key, qtValue(CFArrayGetValueAtIndex(cfarray, j)));
} else {
map.insert(key, qtValue(values[i]));
}
}
return map;
} else if (typeId == CFDateGetTypeID()) {
QDateTime dt;
dt.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970);
return dt.addSecs((int)CFDateGetAbsoluteTime(static_cast<CFDateRef>(cfvalue)));
}
return QVariant();
}
示例11: _org_warhound_mdi_Number2SV
SV* _org_warhound_mdi_Number2SV(CFTypeRef attrItem) {
double thisnv;
/* FIXME: Error check? What to do if it fails? */
CFNumberGetValue(attrItem, kCFNumberDoubleType, &thisnv);
return newSVnv(thisnv);
}
示例12: update_disk_stats
/*
* Update the counters associated with a single disk.
*/
static void
update_disk_stats(struct diskstat *disk,
CFDictionaryRef pproperties, CFDictionaryRef properties)
{
CFDictionaryRef statistics;
CFStringRef name;
CFNumberRef number;
memset(disk, 0, sizeof(struct diskstat));
/* Get name from the drive properties */
name = (CFStringRef) CFDictionaryGetValue(pproperties,
CFSTR(kIOBSDNameKey));
if(name == NULL)
return; /* Not much we can do with no name */
CFStringGetCString(name, disk->name, DEVNAMEMAX,
CFStringGetSystemEncoding());
/* Get the blocksize from the drive properties */
number = (CFNumberRef) CFDictionaryGetValue(pproperties,
CFSTR(kIOMediaPreferredBlockSizeKey));
if(number == NULL)
return; /* Not much we can do with no number */
CFNumberGetValue(number, kCFNumberSInt64Type, &disk->blocksize);
/* Get the statistics from the device properties. */
statistics = (CFDictionaryRef) CFDictionaryGetValue(properties,
CFSTR(kIOBlockStorageDriverStatisticsKey));
if (statistics) {
number = (CFNumberRef) CFDictionaryGetValue(statistics,
CFSTR(kIOBlockStorageDriverStatisticsReadsKey));
if (number)
CFNumberGetValue(number, kCFNumberSInt64Type,
&disk->read);
number = (CFNumberRef) CFDictionaryGetValue(statistics,
CFSTR(kIOBlockStorageDriverStatisticsWritesKey));
if (number)
CFNumberGetValue(number, kCFNumberSInt64Type,
&disk->write);
number = (CFNumberRef) CFDictionaryGetValue(statistics,
CFSTR(kIOBlockStorageDriverStatisticsBytesReadKey));
if (number)
CFNumberGetValue(number, kCFNumberSInt64Type,
&disk->read_bytes);
number = (CFNumberRef) CFDictionaryGetValue(statistics,
CFSTR(kIOBlockStorageDriverStatisticsBytesWrittenKey));
if (number)
CFNumberGetValue(number, kCFNumberSInt64Type,
&disk->write_bytes);
number = (CFNumberRef) CFDictionaryGetValue(statistics,
CFSTR(kIOBlockStorageDriverStatisticsLatentReadTimeKey));
if (number)
CFNumberGetValue(number, kCFNumberSInt64Type,
&disk->read_time);
number = (CFNumberRef) CFDictionaryGetValue(statistics,
CFSTR(kIOBlockStorageDriverStatisticsLatentWriteTimeKey));
if (number)
CFNumberGetValue(number, kCFNumberSInt64Type,
&disk->write_time);
}
}
示例13: initializeDb
static void initializeDb()
{
QFontDatabasePrivate *db = privateDb();
if(!db || db->count)
return;
#if defined(QT_MAC_USE_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
QCFType<CTFontCollectionRef> collection = CTFontCollectionCreateFromAvailableFonts(0);
if(!collection)
return;
QCFType<CFArrayRef> fonts = CTFontCollectionCreateMatchingFontDescriptors(collection);
if(!fonts)
return;
QString foundry_name = "CoreText";
const int numFonts = CFArrayGetCount(fonts);
for(int i = 0; i < numFonts; ++i) {
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i);
QCFString family_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL);
QCFString style_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL);
QtFontFamily *family = db->family(family_name, true);
if (QCFType<CFArrayRef> languages = (CFArrayRef) CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute)) {
CFIndex length = CFArrayGetCount(languages);
for (int i = 1; i < LanguageCount; ++i) {
if (!languageForWritingSystem[i])
continue;
QCFString lang = CFStringCreateWithCString(NULL, languageForWritingSystem[i], kCFStringEncodingASCII);
if (CFArrayContainsValue(languages, CFRangeMake(0, length), lang))
family->writingSystems[i] = QtFontFamily::Supported;
}
}
QtFontFoundry *foundry = family->foundry(foundry_name, true);
QtFontStyle::Key styleKey;
QString styleName = style_name;
if(QCFType<CFDictionaryRef> styles = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute)) {
if(CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontWeightTrait)) {
Q_ASSERT(CFNumberIsFloatType(weight));
double d;
if(CFNumberGetValue(weight, kCFNumberDoubleType, &d)) {
//qDebug() << "BOLD" << (QString)family_name << d;
styleKey.weight = (d > 0.0) ? QFont::Bold : QFont::Normal;
}
}
if(CFNumberRef italic = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontSlantTrait)) {
Q_ASSERT(CFNumberIsFloatType(italic));
double d;
if(CFNumberGetValue(italic, kCFNumberDoubleType, &d)) {
//qDebug() << "ITALIC" << (QString)family_name << d;
if (d > 0.0)
styleKey.style = QFont::StyleItalic;
}
}
}
QtFontStyle *style = foundry->style(styleKey, styleName, true);
style->smoothScalable = true;
if(QCFType<CFNumberRef> size = (CFNumberRef)CTFontDescriptorCopyAttribute(font, kCTFontSizeAttribute)) {
//qDebug() << "WHEE";
int pixel_size=0;
if(CFNumberIsFloatType(size)) {
double d;
CFNumberGetValue(size, kCFNumberDoubleType, &d);
pixel_size = d;
} else {
CFNumberGetValue(size, kCFNumberIntType, &pixel_size);
}
//qDebug() << "SIZE" << (QString)family_name << pixel_size;
if(pixel_size)
style->pixelSize(pixel_size, true);
} else {
//qDebug() << "WTF?";
}
}
} else
#endif
{
#ifndef QT_MAC_USE_COCOA
FMFontIterator it;
if (!FMCreateFontIterator(0, 0, kFMUseGlobalScopeOption, &it)) {
while (true) {
FMFont fmFont;
if (FMGetNextFont(&it, &fmFont) != noErr)
break;
FMFontFamily fmFamily;
FMFontStyle fmStyle;
QString familyName;
QtFontStyle::Key styleKey;
ATSFontRef atsFont = FMGetATSFontRefFromFont(fmFont);
if (!FMGetFontFamilyInstanceFromFont(fmFont, &fmFamily, &fmStyle)) {
{ //sanity check the font, and see if we can use it at all! --Sam
ATSUFontID fontID;
if(ATSUFONDtoFontID(fmFamily, 0, &fontID) != noErr)
continue;
//.........這裏部分代碼省略.........
示例14: DoLoadMemory
static OSStatus DoLoadMemory(
AuthorizationRef auth,
const void * userData,
CFDictionaryRef request,
CFMutableDictionaryRef response,
aslclient asl,
aslmsg aslMsg
)
// Implements the kGetUIDsCommand. Gets the process's three UIDs and
// adds them to the response dictionary.
{
//asl_log(asl, aslMsg, ASL_LEVEL_DEBUG, "DoLoadMemory()");
// Pre-conditions
if(auth == NULL || request == NULL || response == NULL)
return kMemToolBadParameter;
// CFShow(request);
// load in the WoW ProcessID
pid_t wowPID = 0;
CFNumberRef cfPID = CFDictionaryGetValue(request, CFSTR(kWarcraftPID));
if(!CFNumberGetValue(cfPID, kCFNumberIntType, &wowPID) || wowPID <= 0) {
return kMemToolBadPID;
}
// load in the memory address
unsigned int address = 0;
CFNumberRef cfAddress = CFDictionaryGetValue(request, CFSTR(kMemoryAddress));
if(!CFNumberGetValue(cfAddress, kCFNumberIntType, &address) || address == 0) {
return kMemToolBadAddress;
}
// load in memory length
vm_size_t length = 0;
CFNumberRef cfLength = CFDictionaryGetValue(request, CFSTR(kMemoryLength));
if(!CFNumberGetValue(cfLength, kCFNumberIntType, &length) || length == 0) {
return kMemToolBadLength;
}
bool memSuccess = false;
if(wowPID && address && length) {
//asl_log(asl, aslMsg, ASL_LEVEL_DEBUG, "Reading pid %d at address 0x%X for length %d", wowPID, address, length);
// create buffer for our data
Byte buffer[length];
int i;
for(i=0; i<length; i++)
buffer[i] = 0;
// get a handle on the WoW task
mach_port_t wowTask;
task_for_pid(current_task(), wowPID, &wowTask);
vm_size_t bytesRead = length;
memSuccess = ((KERN_SUCCESS == vm_read_overwrite(wowTask, address, length, (vm_address_t)&buffer, &bytesRead)) && (bytesRead == length) );
//(KERN_SUCCESS == vm_write(wowTask, address, (vm_offset_t)&buffer, length));
if(memSuccess) {
CFDataRef memoryContents = CFDataCreate(NULL, buffer, length);
if(memoryContents != NULL) {
// we got our memory! add it to the return dictionary
CFDictionaryAddValue(response, CFSTR(kMemoryContents), memoryContents);
CFRelease(memoryContents);
return kMemToolNoError;
}
}
} else {
return kMemToolBadParameter;
}
return kMemToolUnknown;
}
示例15: SetValue
bool SFB::Audio::Metadata::SetFromDictionaryRepresentation(CFDictionaryRef dictionary)
{
if(nullptr == dictionary)
return false;
SetValue(kTitleKey, CFDictionaryGetValue(dictionary, kTitleKey));
SetValue(kAlbumTitleKey, CFDictionaryGetValue(dictionary, kAlbumTitleKey));
SetValue(kArtistKey, CFDictionaryGetValue(dictionary, kArtistKey));
SetValue(kAlbumArtistKey, CFDictionaryGetValue(dictionary, kAlbumArtistKey));
SetValue(kGenreKey, CFDictionaryGetValue(dictionary, kGenreKey));
SetValue(kComposerKey, CFDictionaryGetValue(dictionary, kComposerKey));
SetValue(kReleaseDateKey, CFDictionaryGetValue(dictionary, kReleaseDateKey));
SetValue(kCompilationKey, CFDictionaryGetValue(dictionary, kCompilationKey));
SetValue(kTrackNumberKey, CFDictionaryGetValue(dictionary, kTrackNumberKey));
SetValue(kTrackTotalKey, CFDictionaryGetValue(dictionary, kTrackTotalKey));
SetValue(kDiscNumberKey, CFDictionaryGetValue(dictionary, kDiscNumberKey));
SetValue(kDiscTotalKey, CFDictionaryGetValue(dictionary, kDiscTotalKey));
SetValue(kLyricsKey, CFDictionaryGetValue(dictionary, kLyricsKey));
SetValue(kBPMKey, CFDictionaryGetValue(dictionary, kBPMKey));
SetValue(kRatingKey, CFDictionaryGetValue(dictionary, kRatingKey));
SetValue(kCommentKey, CFDictionaryGetValue(dictionary, kCommentKey));
SetValue(kISRCKey, CFDictionaryGetValue(dictionary, kISRCKey));
SetValue(kMCNKey, CFDictionaryGetValue(dictionary, kMCNKey));
SetValue(kMusicBrainzReleaseIDKey, CFDictionaryGetValue(dictionary, kMusicBrainzReleaseIDKey));
SetValue(kMusicBrainzRecordingIDKey, CFDictionaryGetValue(dictionary, kMusicBrainzRecordingIDKey));
SetValue(kTitleSortOrderKey, CFDictionaryGetValue(dictionary, kTitleSortOrderKey));
SetValue(kAlbumTitleSortOrderKey, CFDictionaryGetValue(dictionary, kAlbumTitleSortOrderKey));
SetValue(kArtistSortOrderKey, CFDictionaryGetValue(dictionary, kArtistSortOrderKey));
SetValue(kAlbumArtistSortOrderKey, CFDictionaryGetValue(dictionary, kAlbumArtistSortOrderKey));
SetValue(kComposerSortOrderKey, CFDictionaryGetValue(dictionary, kComposerSortOrderKey));
SetValue(kGroupingKey, CFDictionaryGetValue(dictionary, kGroupingKey));
SetValue(kAdditionalMetadataKey, CFDictionaryGetValue(dictionary, kAdditionalMetadataKey));
SetValue(kReferenceLoudnessKey, CFDictionaryGetValue(dictionary, kReferenceLoudnessKey));
SetValue(kTrackGainKey, CFDictionaryGetValue(dictionary, kTrackGainKey));
SetValue(kTrackPeakKey, CFDictionaryGetValue(dictionary, kTrackPeakKey));
SetValue(kAlbumGainKey, CFDictionaryGetValue(dictionary, kAlbumGainKey));
SetValue(kAlbumPeakKey, CFDictionaryGetValue(dictionary, kAlbumPeakKey));
RemoveAllAttachedPictures();
CFArrayRef attachedPictures = (CFArrayRef)CFDictionaryGetValue(dictionary, kAttachedPicturesKey);
for(CFIndex i = 0; i < CFArrayGetCount(attachedPictures); ++i) {
CFDictionaryRef pictureDictionary = (CFDictionaryRef)CFArrayGetValueAtIndex(attachedPictures, i);
CFDataRef pictureData = (CFDataRef)CFDictionaryGetValue(pictureDictionary, AttachedPicture::kDataKey);
AttachedPicture::Type pictureType = AttachedPicture::Type::Other;
CFNumberRef typeWrapper = (CFNumberRef)CFDictionaryGetValue(pictureDictionary, AttachedPicture::kTypeKey);
if(nullptr != typeWrapper)
CFNumberGetValue(typeWrapper, kCFNumberIntType, &pictureType);
CFStringRef pictureDescription = (CFStringRef)CFDictionaryGetValue(pictureDictionary, AttachedPicture::kDescriptionKey);
AttachPicture(std::make_shared<AttachedPicture>(pictureData, pictureType, pictureDescription));
}
return true;
}