void GnomeKeyringPasswordBackend::updateLastUsed(PasswordEntry &entry)
{
    initialize();

    entry.updated = QDateTime::currentDateTime().toTime_t();

    GnomeKeyringAttributeList* attributes = createAttributes(entry);

    GnomeKeyringResult result = gnome_keyring_item_set_attributes_sync(GNOME_KEYRING_DEFAULT,
                                entry.id.toUInt(),
                                attributes);

    gnome_keyring_attribute_list_free(attributes);

    if (result != GNOME_KEYRING_RESULT_OK) {
        qWarning() << "GnomeKeyringPasswordBackend::updateLastUsed Cannot updated entry in keyring!";
        return;
    }

    int index = m_allEntries.indexOf(entry);

    if (index > -1) {
        m_allEntries[index] = entry;
    }
}
void GnomeKeyringPasswordBackend::addEntry(const PasswordEntry &entry)
{
    initialize();

    PasswordEntry stored = entry;
    stored.updated = QDateTime::currentDateTime().toTime_t();

    guint32 itemId;
    GnomeKeyringAttributeList* attributes = createAttributes(stored);

    QByteArray pass = stored.password.toUtf8();
    QByteArray host = stored.host.toUtf8();

    GnomeKeyringResult result = gnome_keyring_item_create_sync(GNOME_KEYRING_DEFAULT,
                                GNOME_KEYRING_ITEM_GENERIC_SECRET,
                                host.constData(),
                                attributes,
                                pass.constData(),
                                TRUE, // Update if exists
                                &itemId);

    gnome_keyring_attribute_list_free(attributes);

    if (result != GNOME_KEYRING_RESULT_OK) {
        qWarning() << "GnomeKeyringPasswordBackend::addEntry Cannot add entry to keyring!";
    }

    stored.id = itemId;

    m_allEntries.append(stored);
}
示例#3
0
void Item::copyAttributes(Item* item)
{
	if(item && item->attributes && !item->attributes->empty())
	{
		createAttributes();
		*attributes = *item->attributes;
	}

	eraseAttribute("decaying");
	eraseAttribute("duration");
}
    ElectricalMeasurementCluster::ElectricalMeasurementCluster(ZigbeeDevice * zigbeeDevice, const EndpointID endpoint, NwkAddr networkAddress) :
            Cluster(zigbeeDevice, endpoint, networkAddress) {
        createAttributes(attributesDef);

        _commandsDef.emplace_back([=](std::vector<uint8_t> &&) { zigbeeDevice->sendCmd(networkAddress, endpoint, ElectricalMeasurament, 0); }, 0,
                                  "Get Profile Info Command");
        _commandsDef.emplace_back(
                [=](std::vector<uint8_t> &&) { zigbeeDevice->sendCmd(networkAddress, endpoint, ElectricalMeasurament, 1); },
                1,
                "Get Measurement Profile Command",
                std::make_shared<ClusterCmdParams<ZCLTypeDataType::ZCLTypeUInt16>>("Attribute ID"),
                std::make_shared<ClusterCmdParams<ZCLTypeDataType::ZCLTypeUTCTime>>("Start Time"),
                std::make_shared<ClusterCmdParams<ZCLTypeDataType::ZCLTypeUInt8>>("Number Of Intervals")
        );
    }
bool GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry)
{
    initialize();

    // Update item attributes
    GnomeKeyringAttributeList* attributes = createAttributes(entry);

    GnomeKeyringResult result = gnome_keyring_item_set_attributes_sync(GNOME_KEYRING_DEFAULT,
                                entry.id.toUInt(),
                                attributes);

    gnome_keyring_attribute_list_free(attributes);

    if (result != GNOME_KEYRING_RESULT_OK) {
        qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot updated entry attributes in keyring!";
        return false;
    }

    // Update secret
    GnomeKeyringItemInfo* info;
    result = gnome_keyring_item_get_info_full_sync(GNOME_KEYRING_DEFAULT, entry.id.toUInt(),
             GNOME_KEYRING_ITEM_INFO_SECRET, &info);

    if (result != GNOME_KEYRING_RESULT_OK) {
        qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot get entry info from keyring!";
        return false;
    }

    QByteArray pass = entry.password.toUtf8();
    gnome_keyring_item_info_set_secret(info, pass.constData());

    result = gnome_keyring_item_set_info_sync(GNOME_KEYRING_DEFAULT, entry.id.toUInt(), info);

    gnome_keyring_item_info_free(info);

    if (result != GNOME_KEYRING_RESULT_OK) {
        qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot set entry info in keyring!";
        return false;
    }

    int index = m_allEntries.indexOf(entry);

    if (index > -1) {
        m_allEntries[index] = entry;
    }

    return true;
}
示例#6
0
bool ItemAttributes::unserializeAttributeMap(PropStream& stream)
{

  uint16_t n;
  if(stream.GET_USHORT(n)){
    createAttributes();

    std::string key;
    ItemAttribute attrib;

    while(n--){
      if(!stream.GET_STRING(key))
        return false;
      if(!attrib.unserialize(stream))
        return false;
      (*attributes)[key] = attrib;
    }
  }
  return true;
}
示例#7
0
MStatus PRTAttrs::updateStartRules(MFnDependencyNode & node) {
	PRTNode* prtNode = (PRTNode*)node.userNode();

	const prt::RuleFileInfo::Entry* startRule = 0;

	prt::Status infoStatus = prt::STATUS_UNSPECIFIED_ERROR;
	const prt::RuleFileInfo* info = prt::createRuleFileInfo(prtNode->mResolveMap->getString(prtNode->mRuleFile.c_str()), 0, &infoStatus);
	if (infoStatus == prt::STATUS_OK) {
		for(size_t r = 0; r < info->getNumRules(); r++) {
			if(info->getRule(r)->getNumParameters() > 0) continue;
			for(size_t a = 0; a < info->getRule(r)->getNumAnnotations(); a++) {
				if(!(wcscmp(info->getRule(r)->getAnnotation(a)->getName(), ANNOT_START_RULE))) {
					startRule = info->getRule(r);
					break;
				}
			}
		}
	}
	if(startRule) {
		prtNode->mStartRule = startRule->getName();

		MCHECK(addBoolParameter(node, prtNode->mGenerate,  NAME_GENERATE, true));

		if(prtNode->mGenerateAttrs) {
			prtNode->mGenerateAttrs->destroy();
			prtNode->mGenerateAttrs = 0;
		}

		prt::AttributeMapBuilder* aBuilder = prt::AttributeMapBuilder::create();
		createAttributes(node, prtNode->mRuleFile, prtNode->mStartRule, aBuilder, info);
		prtNode->mGenerateAttrs = aBuilder->createAttributeMap();
		aBuilder->destroy();
	}

  if(info)
		info->destroy();

	return MS::kSuccess;
}
bool ItemAttributes::unserializeMap(PropStream& stream)
{
	uint16_t n;
	if(!stream.getShort(n))
		return true;

	createAttributes();
	while(n--)
	{
		std::string key;
		if(!stream.getString(key))
			return false;

		ItemAttribute attr;
		if(!attr.unserialize(stream))
			return false;

		(*attributes)[key] = attr;
	}

	return true;
}
示例#9
0
void ItemAttributes::setAttribute(const std::string& key, bool value)
{
  createAttributes();
  (*attributes)[key].set(value);
}
namespace ErrorCodes
{
	extern const int TYPE_MISMATCH;
	extern const int ARGUMENT_OUT_OF_BOUND;
	extern const int BAD_ARGUMENTS;
	extern const int DICTIONARY_IS_EMPTY;
}

ComplexKeyHashedDictionary::ComplexKeyHashedDictionary(
	const std::string & name, const DictionaryStructure & dict_struct, DictionarySourcePtr source_ptr,
	const DictionaryLifetime dict_lifetime, bool require_nonempty)
	: name{name}, dict_struct(dict_struct), source_ptr{std::move(source_ptr)}, dict_lifetime(dict_lifetime),
	require_nonempty(require_nonempty)
{
	createAttributes();

	try
	{
		loadData();
		calculateBytesAllocated();
	}
	catch (...)
	{
		creation_exception = std::current_exception();
	}

	creation_time = std::chrono::system_clock::now();
}

ComplexKeyHashedDictionary::ComplexKeyHashedDictionary(const ComplexKeyHashedDictionary & other)
示例#11
0
		//! Creates a new empty collection of attributes, usable for serialization and more.
		IAttributes* SharedFileSystem::createEmptyAttributes()
		{
			return createAttributes();
		}
示例#12
0
void ItemAttributes::setAttribute(const char* key, bool value)
{
    createAttributes();
    (*attributes)[key].set(value);
}
示例#13
0
void ItemAttributes::setAttribute(const char* key, const std::string& value)
{
    createAttributes();
    (*attributes)[key].set(value);
}
PressureMeasurementCluster::PressureMeasurementCluster(ZigbeeDevice *  zigbeeDevice, const EndpointID endpoint, NwkAddr networkAddress) :
								Cluster(zigbeeDevice, endpoint, networkAddress) {

	createAttributes(attributesDef);
}
IlluminanceLevelSensingCluster::IlluminanceLevelSensingCluster(ZigbeeDevice *  zigbeeDevice, const EndpointID endpoint, NwkAddr networkAddress) :
				Cluster(zigbeeDevice, endpoint, networkAddress){

	createAttributes(attributesDef);
}