// ----------------------------------------------------------------------------- // CAtomFeedParser::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CAtomFeedParser::ConstructL() { // The mappings are used to map elements to handler methods. For example when // a <title> element is found its contents are extracted as CDATA and passed // on to the observer as a EFeedAttributeTitle. // // Add mappings to process the children of a channel. // AddFeedMappingL(KNullDesC8(), KEntry(), EFeedAttributeUnused, ElementHandlerItemL); AddFeedMappingL(KNullDesC8(), KTitle(), EFeedAttributeTitle, ElementHandlerTextL); AddFeedMappingL(KNullDesC8(), KLink(), EFeedAttributeLink, ElementHandlerLinkL); AddFeedMappingL(KNullDesC8(), KTagline(), EFeedAttributeDescription, ElementHandlerCDataL); AddFeedMappingL(KNullDesC8(), KSubtitle(), EFeedAttributeDescription, ElementHandlerCDataL); AddFeedMappingL(KNullDesC8(), KPublished(), EFeedAttributeTimestamp, ElementHandlerTimestampL); AddFeedMappingL(KNullDesC8(), KUpdated(), EFeedAttributeTimestamp, ElementHandlerTimestampL); AddFeedMappingL(KNullDesC8(), KModified(), EFeedAttributeTimestamp, ElementHandlerTimestampL); AddFeedMappingL(KNullDesC8(), KIssued(), EFeedAttributeTimestamp, ElementHandlerTimestampL); // // Add mappings to process the children of an item. // AddItemMappingL(KNullDesC8(), KTitle(), EItemAttributeTitle, ElementHandlerTextL); AddItemMappingL(KNullDesC8(), KLink(), EItemAttributeLink, ElementHandlerLinkL); AddItemMappingL(KNullDesC8(), KContent(), EItemAttributeDescription, ElementHandlerCDataL); AddItemMappingL(KNullDesC8(), KSummary(), EItemAttributeDescription, ElementHandlerCDataL); AddItemMappingL(KNullDesC8(), KPublished(), EItemAttributeTimestamp, ElementHandlerTimestampL); AddItemMappingL(KNullDesC8(), KUpdated(), EItemAttributeTimestamp, ElementHandlerTimestampL); AddItemMappingL(KNullDesC8(), KModified(), EItemAttributeTimestamp, ElementHandlerTimestampL); AddItemMappingL(KNullDesC8(), KIssued(), EItemAttributeTimestamp, ElementHandlerTimestampL); }
bool KEntryMap::setEntry(const QByteArray& group, const QByteArray& key, const QByteArray& value, KEntryMap::EntryOptions options) { KEntryKey k; KEntry e; bool newKey = false; const Iterator it = findExactEntry(group, key, SearchFlags(options>>16)); if (key.isEmpty()) { // inserting a group marker k.mGroup = group; e.bImmutable = (options&EntryImmutable); if (options&EntryDeleted) { qWarning("Internal KConfig error: cannot mark groups as deleted"); } if(it == end()) { insert(k, e); return true; } else if(it.value() == e) { return false; } it.value() = e; return true; } if (it != end()) { if (it->bImmutable) return false; // we cannot change this entry. Inherits group immutability. k = it.key(); e = *it; //qDebug() << "found existing entry for key" << k; } else { // make sure the group marker is in the map KEntryMap const *that = this; ConstIterator cit = that->findEntry(group); if (cit == constEnd()) insert(KEntryKey(group), KEntry()); else if (cit->bImmutable) return false; // this group is immutable, so we cannot change this entry. k = KEntryKey(group, key); newKey = true; } // set these here, since we may be changing the type of key from the one we found k.bLocal = (options&EntryLocalized); k.bDefault = (options&EntryDefault); k.bRaw = (options&EntryRawKey); e.mValue = value; e.bDirty = e.bDirty || (options&EntryDirty); e.bGlobal = (options&EntryGlobal); //we can't use || here, because changes to entries in //kdeglobals would be written to kdeglobals instead //of the local config file, regardless of the globals flag e.bImmutable = e.bImmutable || (options&EntryImmutable); if (value.isNull()) e.bDeleted = e.bDeleted || (options&EntryDeleted); else e.bDeleted = false; // setting a value to a previously deleted entry e.bExpand = (options&EntryExpansion); e.bReverted = false; if(newKey) { //qDebug() << "inserting" << k << "=" << value; insert(k, e); if(k.bDefault) { k.bDefault = false; //qDebug() << "also inserting" << k << "=" << value; insert(k, e); } // TODO check for presence of unlocalized key return true; } else { // KEntry e2 = it.value(); if(it.value() != e) { //qDebug() << "changing" << k << "from" << e.mValue << "to" << value; it.value() = e; if(k.bDefault) { KEntryKey nonDefaultKey(k); nonDefaultKey.bDefault = false; insert(nonDefaultKey, e); } if (!(options & EntryLocalized)) { KEntryKey theKey(group, key, true, false); //qDebug() << "non-localized entry, remove localized one:" << theKey; remove(theKey); if (k.bDefault) { theKey.bDefault = true; remove(theKey); } } return true; } else { //qDebug() << k << "was already set to" << e.mValue; if (!(options & EntryLocalized)) { //qDebug() << "unchanged non-localized entry, remove localized one."; KEntryKey theKey(group, key, true, false); bool ret = false; Iterator cit = find(theKey); if (cit != end()) { erase(cit); ret = true; } if (k.bDefault) { theKey.bDefault = true; Iterator cit = find(theKey); if (cit != end()) { erase(cit); return true; } } return ret; } //qDebug() << "localized entry, unchanged, return false"; // When we are writing a default, we know that the non- // default is the same as the default, so we can simply // use the same branch. return false; } } }