diff -r 000000000000 -r dd21522fd290 browserutilities/feedsengine/FeedsServer/Reconizer/src/FeedsRec.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserutilities/feedsengine/FeedsServer/Reconizer/src/FeedsRec.cpp Mon Mar 30 12:54:55 2009 +0300 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Recognizer for the bowser supported MIME types. +* +*/ + + +#include "FeedsRec.h" + +#include + + +// Constants +_LIT8(KMimeTypeRss, "application/rss+xml"); +//_LIT8(KMimeTypeAtom, "application/atom+xml"); +_LIT8(KMimeTypeXml1, "application/xml"); +_LIT8(KMimeTypeXml2, "text/xml"); + + +// ----------------------------------------------------------------------------- +// CFeedsRec::CFeedsRec +// +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CFeedsRec::CFeedsRec() + :CApaDataRecognizerType(KUidMimeFeedsRec, CApaDataRecognizerType::EHigh) + { + iCountDataTypes = KSupportedMimetypes; + } + + +// ----------------------------------------------------------------------------- +// CFeedsRec::PreferredBufSize +// +// Returns the preferred buffer size. +// ----------------------------------------------------------------------------- +// +TUint CFeedsRec::PreferredBufSize() + { + return 0x100; + } + + +// ----------------------------------------------------------------------------- +// CFeedsRec::SupportedDataTypeL +// +// Returns the index'ed supported mime-type. +// ----------------------------------------------------------------------------- +// +TDataType CFeedsRec::SupportedDataTypeL(TInt aIndex) const + { + __ASSERT_DEBUG((aIndex >= 0) && (aIndex < KSupportedMimetypes), User::Invariant()); + + switch (aIndex) + { + case 0: + return TDataType(KMimeTypeRss); + + default: + return TDataType(); + } + } + + +// ----------------------------------------------------------------------------- +// CFeedsRec::DoRecognizeL +// +// Given the buffer it examines the buffer and sets the inherited +// member variable, iConfidence. +// ----------------------------------------------------------------------------- +// +void CFeedsRec::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer) + { + TInt confidence; + + iConfidence = ENotRecognized; + + // Examine the buffer for RSS. + if ((confidence = RecognizeRss(aName, aBuffer)) != ENotRecognized) + { + iDataType = TDataType(KMimeTypeRss); + iConfidence = confidence; + } + + // Examine the buffer for Atom. + // TODO: in 3.1 + + // Examine the buffer for Opml 1.0. + // TODO: in 3.1 + } + + +// ----------------------------------------------------------------------------- +// CFeedsRec::DoRecognizeRss +// +// Given the buffer it examines the buffer and returns the confidence level that +// this document is rss. +// ----------------------------------------------------------------------------- +// +TInt CFeedsRec::RecognizeRss(const TDesC& /*aName*/, const TDesC8& aBuffer) + { + _LIT8(KRss, "