[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim/akregator_port] krss: respect the request payload part in
From: Frank Osterfeld <frank.osterfeld () kdemail ! net>
Date: 2011-07-27 12:12:12
Message-ID: 20110727121212.98630A610A () git ! kde ! org
[Download RAW message or body]
Git commit 9e27606faaae5fb5c9bec560ef6de66c2031cffa by Frank Osterfeld.
Committed on 17/10/2009 at 23:36.
Pushed by cgiboudeaux into branch 'akregator_port'.
respect the request payload part in the qdatastream serializer
svn path=/branches/work/akonadi-ports/kdepim/; revision=1036831
M +107 -87 krss/rssitemserializer_qdatastream.cpp
http://commits.kde.org/kdepim/9e27606faaae5fb5c9bec560ef6de66c2031cffa
diff --git a/krss/rssitemserializer_qdatastream.cpp \
b/krss/rssitemserializer_qdatastream.cpp index cc55aa4..f74536e 100644
--- a/krss/rssitemserializer_qdatastream.cpp
+++ b/krss/rssitemserializer_qdatastream.cpp
@@ -34,34 +34,40 @@ using namespace KRss;
void RssItemSerializer::serialize( const RssItem& item, QByteArray& ba, ItemPart \
part ) { QDataStream stream( &ba, QIODevice::WriteOnly );
- stream << static_cast<qint64>( item.hash() )
- << item.guidIsHash()
- << item.title()
- << item.link()
- << item.description()
- << item.content()
- << item.language()
- << item.datePublished().toString()
- << item.dateUpdated().toString()
- << item.guid()
- << static_cast<qint32>( item.commentsCount() )
- << item.commentPostUri()
- << item.commentsFeed()
- << item.commentsLink();
- stream << static_cast<quint32>( item.enclosures().count() );
- Q_FOREACH( const Enclosure& i, item.enclosures() )
- stream << static_cast<qint32>( i.duration() ) << static_cast<qint32>( \
i.length() ) << i.title() << i.type() << i.url();
- stream << static_cast<quint32>( item.categories().count() );
- Q_FOREACH( const Category& i, item.categories() )
- stream << i.label() << i.scheme() << i.term();
- stream << static_cast<quint32>( item.authors().count() );
- Q_FOREACH( const Person& i, item.authors() )
- stream << i.email() << i.name() << i.uri();
- const QHash<QString, QString> ap = item.customProperties();
- stream << static_cast<quint32>( ap.size() );
- Q_FOREACH( const QString& key, ap.keys() )
- stream << key << ap.value( key );
+ const bool writeHeaders = ( part & Headers ) != 0;
+ const bool writeContent = ( part & Content ) != 0;
+ if ( writeHeaders ) {
+ stream << static_cast<qint64>( item.hash() )
+ << item.guidIsHash()
+ << item.title()
+ << item.datePublished().toString()
+ << item.dateUpdated().toString()
+ << item.guid()
+ stream << static_cast<quint32>( item.authors().count() );
+ Q_FOREACH( const Person& i, item.authors() )
+ stream << i.email() << i.name() << i.uri();
+ }
+ if ( writeContent ) {
+ stream << item.content()
+ << item.description()
+ << item.link()
+ << item.language()
+ << static_cast<qint32>( item.commentsCount() )
+ << item.commentPostUri()
+ << item.commentsFeed()
+ << item.commentsLink();
+ stream << static_cast<quint32>( item.enclosures().count() );
+ Q_FOREACH( const Enclosure& i, item.enclosures() )
+ stream << static_cast<qint32>( i.duration() ) << static_cast<qint32>( \
i.length() ) << i.title() << i.type() << i.url(); + stream << \
static_cast<quint32>( item.categories().count() ); + Q_FOREACH( const \
Category& i, item.categories() ) + stream << i.label() << i.scheme() << \
i.term(); + const QHash<QString, QString> ap = item.customProperties();
+ stream << static_cast<quint32>( ap.size() );
+ Q_FOREACH( const QString& key, ap.keys() )
+ stream << key << ap.value( key );
+ }
}
#define READSTRING(name) QString name; stream >> name; item.set##name( name );
@@ -71,71 +77,85 @@ void RssItemSerializer::serialize( const RssItem& item, \
QByteArray& ba, ItemPart #define READDATE(name) QString name; stream >> name; \
item.set##name( KDateTime::fromString( name ) );
bool RssItemSerializer::deserialize( RssItem& itemOut, const QByteArray& ba, \
ItemPart part ) { + const bool readHeaders = ( part & Headers ) != 0;
+ const bool readContent = ( part & Content ) != 0;
+
QDataStream stream( ba );
RssItem item;
- READ(qint64,Hash)
- READ(bool,GuidIsHash)
- READSTRING(Title)
- READSTRING(Link)
- READSTRING(Description)
- READSTRING(Content)
- READSTRING(Language)
- READDATE(DatePublished)
- READDATE(DateUpdated)
- READSTRING(Guid)
- READ(qint32,CommentsCount)
- READSTRING(CommentPostUri)
- READSTRING(CommentsFeed)
- READSTRING(CommentsLink)
- quint32 encCount;
- stream >> encCount;
- QList<Enclosure> enclosures;
- for ( quint32 i = 0; i < encCount; ++i ) {
- Enclosure enc;
- READ2(qint32, Duration, enc)
- READ2(qint32, Length, enc)
- READSTRING2(Title, enc)
- READSTRING2(Type, enc)
- READSTRING2(Url, enc)
- enclosures.append( enc );
- }
- item.setEnclosures( enclosures );
-
- quint32 catCount = 0;
- stream >> catCount;
- QList<Category> categories;
- for ( quint32 i = 0; i < catCount; ++i ) {
- Category cat;
- READSTRING2(Label, cat)
- READSTRING2(Scheme, cat)
- READSTRING2(Term, cat)
- categories.append( cat );
- }
- item.setCategories( categories );
-
- quint32 authorCount;
- stream >> authorCount;
- QList<Person> authors;
- for ( quint32 i = 0; i < authorCount; ++i ) {
- Person auth;
- READSTRING2(Email, auth)
- READSTRING2(Name, auth)
- READSTRING2(Uri, auth)
- authors.append( auth );
- }
- item.setAuthors( authors );
-
- quint32 apCount;
- stream >> apCount;
- for ( quint32 i = 0; i < apCount; ++i ) {
- QString key;
- stream >> key;
- QString value;
- stream >> value;
- item.setCustomProperty( key, value );
+ if ( readHeaders ) {
+ READ(qint64,Hash)
+ READ(bool,GuidIsHash)
+ READSTRING(Title)
+ READDATE(DatePublished)
+ READDATE(DateUpdated)
+ READSTRING(Guid)
+ quint32 authorCount;
+ stream >> authorCount;
+ QList<Person> authors;
+ for ( quint32 i = 0; i < authorCount; ++i ) {
+ Person auth;
+ READSTRING2(Email, auth)
+ READSTRING2(Name, auth)
+ READSTRING2(Uri, auth)
+ authors.append( auth );
+ }
+ item.setAuthors( authors );
}
+ if ( readContent ) {
+ READSTRING(Content)
+ READSTRING(Description)
+ READSTRING(Link)
+ READSTRING(Language)
+ READ(qint32,CommentsCount)
+ READSTRING(CommentPostUri)
+ READSTRING(CommentsFeed)
+ READSTRING(CommentsLink)
+ quint32 encCount;
+ stream >> encCount;
+ QList<Enclosure> enclosures;
+ for ( quint32 i = 0; i < encCount; ++i ) {
+ Enclosure enc;
+ READ2(qint32, Duration, enc)
+ READ2(qint32, Length, enc)
+ READSTRING2(Title, enc)
+ READSTRING2(Type, enc)
+ READSTRING2(Url, enc)
+ enclosures.append( enc );
+ }
+ item.setEnclosures( enclosures );
+
+ quint32 catCount = 0;
+ stream >> catCount;
+ QList<Category> categories;
+ for ( quint32 i = 0; i < catCount; ++i ) {
+ Category cat;
+ READSTRING2(Label, cat)
+ READSTRING2(Scheme, cat)
+ READSTRING2(Term, cat)
+ categories.append( cat );
+ }
+ item.setCategories( categories );
+
+
+ quint32 apCount;
+ stream >> apCount;
+ for ( quint32 i = 0; i < apCount; ++i ) {
+ QString key;
+ stream >> key;
+ QString value;
+ stream >> value;
+ item.setCustomProperty( key, value );
+ }
+ }
itemOut = item;
+
+ if ( readHeaders )
+ item.setHeadersLoaded( true );
+
+ if ( readContent )
+ item.setContentLoaded( true );
+
return true;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic