• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

Syndication Library

Syndication Namespace Reference

TODO. More...


Classes

class  AbstractParser
 Interface for all parsers. More...
class  Category
 A category for categorizing items or whole feeds. More...
class  DataRetriever
 Abstract baseclass for all data retriever classes. More...
class  DocumentSource
 Represents the source of a syndication document, as read from the downloaded file. More...
class  DocumentVisitor
 Visitor interface, following the Visitor design pattern. More...
class  ElementWrapper
 A wrapper for XML elements. More...
class  Enclosure
 An enclosure describes a (media) file available on the net. More...
class  Feed
 This class represents a feed document ("Channel" in RSS, "Feed" in Atom). More...
class  FileRetriever
 Implements a file retriever, to be used with Loader::loadFrom(). More...
class  Image
 This class represents an image file on the web. More...
class  Item
 An item from a news feed. More...
class  Loader
 This class is the preferred way of loading feed sources. More...
class  Mapper
 A mapper maps an SpecificDocument to something else. More...
class  OutputRetriever
 Implements a data retriever which executes a program and stores returned by the program on stdout. More...
class  ParserCollection
 A collection of format-specific parser implementations. More...
class  Person
 Person objects hold information about a person, such as the author of the content syndicated in the feed. More...
class  SpecificDocument
 Document interface for format-specific feed documents as parsed from a document source (see DocumentSource). More...
class  SpecificItem
 Interface for all format-specific item-like classes, such as RSS2/RDF items, and Atom entries. More...
class  SpecificItemVisitor
 Visitor interface, following the Visitor design pattern. More...

Typedefs

typedef boost::shared_ptr
< Category > 
CategoryPtr

Enumerations

enum  DateFormat { ISODate, RFCDate }
enum  ErrorCode {
  Success = 0, Aborted = 1, Timeout = 2, UnknownHost = 3,
  FileNotFound = 4, OtherRetrieverError = 5, InvalidXml = 6, XmlNotAccepted = 7,
  InvalidFormat = 8
}

Functions

unsigned int calcHash (const QByteArray &array)
unsigned int calcHash (const QString &str)
QString calcMD5Sum (const QString &str)
static void cleanupParserCollection ()
QString commentApiNamespace ()
QString contentNameSpace ()
QString convertNewlines (const QString &str)
QString dateTimeToString (time_t date)
QString dublinCoreNamespace ()
QString escapeSpecialCharacters (const QString &str)
QString htmlToPlainText (const QString &html)
bool isHtml (const QString &str)
QString itunesNamespace ()
QString normalize (const QString &str, bool isCDATA, bool containsMarkup)
QString normalize (const QString &str)
FeedPtr parse (const DocumentSource &src, const QString &formatHint=QString())
time_t parseDate (const QString &str, DateFormat hint=RFCDate)
time_t parseISODate (const QString &str)
ParserCollection< Feed > * parserCollection ()
time_t parseRFCDate (const QString &str)
PersonPtr personFromString (const QString &str)
QString plainTextToHtml (const QString &plainText)
QString resolveEntities (const QString &str)
QString slashNamespace ()
bool stringContainsMarkup (const QString &str)
QString xhtmlNamespace ()
QString xmlNamespace ()

Variables

KMD5 md5Machine
static ParserCollectionImpl
< Syndication::Feed > * 
parserColl = 0
static QRegExp tagRegExp
static bool tagRegExpSet = false

Detailed Description

TODO.


Enumeration Type Documentation

enum Syndication::DateFormat

date formats supported by date parsers

Enumerator:
ISODate  ISO 8601 extended format.

(date: "2003-12-13",datetime: "2003-12-13T18:30:02.25", datetime with timezone: "2003-12-13T18:30:02.25+01:00")

RFCDate  RFC 822.

(e.g. "Sat, 07 Sep 2002 00:00:01 GMT")

Definition at line 41 of file tools.h.

enum Syndication::ErrorCode

error code indicating fetching or parsing errors

Enumerator:
Success  No error occurred, feed was fetched and parsed successfully.
Aborted  file downloading/parsing was aborted by the user
Timeout  file download timed out
UnknownHost  The hostname couldn't get resolved to an IP address.
FileNotFound  the host was contacted successfully, but reported a 404 error
OtherRetrieverError  retriever error not covered by the error codes above.

This is returned if a custom DataRetriever was used. See the retriever-specific status byte for more information on the occurred error.

InvalidXml  The XML is invalid.

This is returned if no parser accepts the source and the DOM document can't be parsed. It is not returned if the source is not valid XML but a (non-XML) parser accepts it.

XmlNotAccepted  The source is valid XML, but no parser accepted it.
InvalidFormat  the source was accepted by a parser, but the actual parsing failed.

As our parser implementations currently do not validate the source ("parse what you can get"), this code will be rarely seen.

Definition at line 85 of file global.h.


Function Documentation

unsigned int Syndication::calcHash ( const QByteArray &  array  ) 

For internal use only.

calculates a hash value for a byte array

Definition at line 46 of file tools.cpp.

unsigned int Syndication::calcHash ( const QString &  str  ) 

For internal use only.

calculates a hash value for a string

Definition at line 41 of file tools.cpp.

QString Syndication::calcMD5Sum ( const QString &  str  ) 

For internal use only.

calculates a md5 checksum for a string

Definition at line 103 of file tools.cpp.

QString Syndication::commentApiNamespace (  ) 

wellformedweb.org's RSS namespace for comment functionality "http://wellformedweb.org/CommentAPI/"

Definition at line 54 of file constants.cpp.

QString Syndication::convertNewlines ( const QString &  str  ) 

replaces newlines ("\n") by <br/>

Parameters:
str to convert

Definition at line 126 of file tools.cpp.

QString Syndication::dateTimeToString ( time_t  date  ) 

For internal use only.

returns a string representation of a datetime. this is used internally to create debugging output.

Parameters:
date the date to convert
Returns:
string representation of the date, or a null string if date is 0

Definition at line 93 of file tools.cpp.

QString Syndication::escapeSpecialCharacters ( const QString &  str  ) 

replaces the characters < >, &, ", ' with &lt; &gt; &amp;, &quot; &apos;.

Parameters:
str the string to escape

Definition at line 115 of file tools.cpp.

QString Syndication::htmlToPlainText ( const QString &  html  ) 

converts a HTML string to plain text

Parameters:
html string in HTML format
Returns:
stripped text

Definition at line 144 of file tools.cpp.

bool Syndication::isHtml ( const QString &  str  ) 

guesses whether a string contains plain text or HTML

Parameters:
str the string in unknown format
Returns:
true if the heuristic thinks it's HTML, false if thinks it is plain text

Definition at line 176 of file tools.cpp.

QString Syndication::normalize ( const QString &  str,
bool  isCDATA,
bool  containsMarkup 
)

normalizes a string based on feed-wide properties of tag content.

It is based on the assumption that all items in a feed encode their title/description content in the same way (CDATA or not, plain text vs. HTML). isCDATA and containsMarkup are determined once by the feed, and then passed to this method.

The returned string contains HTML, with special characters <, >, &, ", and ' escaped, and all other entities resolved. Whitespace is collapsed, relevant whitespace is replaced by respective HTML tags (<br/>).

Parameters:
str a string
isCDATA whether the feed uses CDATA for the tag str was read from
containsMarkup whether the feed uses HTML markup in the tag str was read from.
Returns:
string as HTML (as long as the heuristics work)

Definition at line 202 of file tools.cpp.

QString Syndication::normalize ( const QString &  str  ) 

Ensures HTML formatting for a string.

guesses via isHtml() if str contains HTML or plain text, and returns plainTextToHtml(str) if it thinks it is plain text, or the unmodified str otherwise.

Parameters:
str a string with unknown content
Returns:
string as HTML (as long as the heuristics work)

Definition at line 197 of file tools.cpp.

FeedPtr Syndication::parse ( const DocumentSource &  src,
const QString &  formatHint = QString() 
)

parses a document from a source and returns a new Feed object wrapping the feed content.

Shortcut for parserCollection()->parse(). See ParserCollection::parse() for more details.

Parameters:
src the document source to parse
formatHint an optional hint which format to test first

Definition at line 69 of file global.cpp.

time_t Syndication::parseDate ( const QString &  str,
DateFormat  hint = RFCDate 
)

parses a date string in ISO (see parseISODate()) or RFC 822 (see parseRFCDate()) format.

It tries both parsers and returns the first valid parsing result found (or 0 otherwise). To speed up parsing, you can give a hint which format you expect. The method will try the corresponding parser first then.

Parameters:
str a date string
hint the expected format
Returns:
parsed date in seconds since epoch, 0 if no date could be parsed from the string.

Definition at line 76 of file tools.cpp.

time_t Syndication::parseISODate ( const QString &  str  ) 

parses a date string in ISO 8601 extended format.

(date: "2003-12-13",datetime: "2003-12-13T18:30:02.25", datetime with timezone: "2003-12-13T18:30:02.25+01:00")

Parameters:
str a string in ISO 8601 format
Returns:
parsed date in seconds since epoch, 0 if no date could be parsed from the string.

Definition at line 62 of file tools.cpp.

ParserCollection< Feed > * Syndication::parserCollection (  ) 

The default ParserCollection instance parsing a DocumentSource into a Feed object.

Use this to parse a local file or a otherwise manually created DocumentSource object.

To retrieve a feed from the web, use Loader instead.

Example code:

 ...
 QFile someFile(somePath);
 ...
 DocumentSource src(someFile.readAll());
 someFile.close();

 FeedPtr feed = parserCollection()->parse(src);

 if (feed)
 {
     QString title = feed->title();
     QList<ItemPtr> items = feed->items();
     ...
 }

Definition at line 55 of file global.cpp.

time_t Syndication::parseRFCDate ( const QString &  str  ) 

parses a date string as defined in RFC 822.

(Sat, 07 Sep 2002 00:00:01 GMT)

Parameters:
str a string in RFC 822 format
Returns:
parsed date in seconds since epoch, 0 if no date could be parsed from the string.

Definition at line 69 of file tools.cpp.

PersonPtr Syndication::personFromString ( const QString &  str  ) 

Parses a person object from a string by identifying name and email address in the string.

Currently detected variants are: "foo@bar.com", "Foo", "Foo &lt;foo@bar.com>", "foo@bar.com (Foo)".

Parameters:
str the string to parse the person from.
Returns:
a Person object containing the parsed information.

Definition at line 225 of file tools.cpp.

QString Syndication::plainTextToHtml ( const QString &  plainText  ) 

converts a plain text string to HTML

Parameters:
plainText a string in plain text.

Definition at line 133 of file tools.cpp.

QString Syndication::resolveEntities ( const QString &  str  ) 

resolves entities to respective unicode chars.

Parameters:
str a string

Definition at line 110 of file tools.cpp.

QString Syndication::slashNamespace (  ) 

"slash" namespace http://purl.org/rss/1.0/modules/slash/

Definition at line 59 of file constants.cpp.

bool Syndication::stringContainsMarkup ( const QString &  str  ) 

guesses whether a string contains (HTML) markup or not.

This implements not an exact check for valid HTML markup, but a simple (and relatively fast) heuristic.

Parameters:
str the string that might or might not contain markup
Returns:
true if the heuristic thinks it contains markup, false if thinks it is markup-free plain text

Definition at line 158 of file tools.cpp.

Syndication Library

Skip menu "Syndication Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal