[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim/akregator_port] krss/plugin: remove protobuf rss serializer
From: Frank Osterfeld <osterfeld () kde ! org>
Date: 2012-03-31 15:17:59
Message-ID: 20120331151759.16C93580AF () git ! kde ! org
[Download RAW message or body]
Git commit 2d651e3274a4d05b38498fd86693d27b15385ef2 by Frank Osterfeld.
Committed on 31/03/2012 at 15:28.
Pushed by osterfeld into branch 'akregator_port'.
remove protobuf rss serializer
M +0 -11 krss/plugin/CMakeLists.txt
D +0 -49 krss/plugin/krss.proto
D +0 -201 krss/plugin/rssitemserializer_protobuf.cpp
M +0 -12 krss/plugin/tests/CMakeLists.txt
http://commits.kde.org/kdepim/2d651e3274a4d05b38498fd86693d27b15385ef2
diff --git a/krss/plugin/CMakeLists.txt b/krss/plugin/CMakeLists.txt
index 33af092..bc490bf 100644
--- a/krss/plugin/CMakeLists.txt
+++ b/krss/plugin/CMakeLists.txt
@@ -4,16 +4,6 @@ set(akonadi_serializer_rss_SRCS
akonadi_serializer_rss.cpp
)
-if(KRSS_ENABLE_PROTOBUF_SERIALIZER)
- WRAP_PROTO(krss_LIB_PROTOBUF_SRCS krss.proto)
-
- set(akonadi_serializer_rss_SRCS
- ${akonadi_serializer_rss_SRCS}
- ${krss_LIB_PROTOBUF_SRCS}
- rssitemserializer_protobuf.cpp
- )
- set(KRSS_EXTRA_LIBS ${PROTOBUF_LIBRARY})
-else(KRSS_ENABLE_PROTOBUF_SERIALIZER)
if(KRSS_ENABLE_QDATASTREAM_SERIALIZER)
set(akonadi_serializer_rss_SRCS
${akonadi_serializer_rss_SRCS}
@@ -34,7 +24,6 @@ else(KRSS_ENABLE_JSON_SERIALIZER)
)
endif(KRSS_ENABLE_JSON_SERIALIZER)
endif(KRSS_ENABLE_QDATASTREAM_SERIALIZER)
-endif(KRSS_ENABLE_PROTOBUF_SERIALIZER)
kde4_add_plugin(akonadi_serializer_rss ${akonadi_serializer_rss_SRCS})
target_link_libraries(akonadi_serializer_rss ${KDE4_KIO_LIBS} \
${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_SYNDICATION_LIBS} \
${KDEPIMLIBS_KRSS_LIBS})
diff --git a/krss/plugin/krss.proto b/krss/plugin/krss.proto
deleted file mode 100644
index 4837532..0000000
--- a/krss/plugin/krss.proto
+++ /dev/null
@@ -1,49 +0,0 @@
-package KRss.Protobuf;
-
-
-message ItemHeader {
- repeated string tags = 1;
- required int32 hash = 2;
- required bool guidIsHash = 3;
- required string guid = 4;
- required string title = 5;
- required string link = 6;
- required int64 datePublished = 7;
- required int64 dateUpdated = 8;
- required string language = 9;
- repeated Person authors = 10;
- repeated Enclosure enclosures = 11;
- repeated Category categories = 12;
- required int32 commentsCount = 13;
- required string commentsLink = 14;
- required string commentsFeed = 15;
- required string commentPostUri = 16;
- repeated string additionalProperties = 17;
-}
-
-message ItemContent {
- required string description = 1;
- required string content = 2;
-}
-
-message Person {
- required string name = 1;
- required string email = 2;
- required string uri = 3;
-}
-
-message Enclosure {
- required string url = 1;
- required string title = 2;
- required string type = 3;
- required uint32 length = 4;
- required uint32 duration = 5;
-}
-
-message Category {
- required string label = 1;
- required string scheme = 2;
- required string term = 3;
-}
-
-
diff --git a/krss/plugin/rssitemserializer_protobuf.cpp \
b/krss/plugin/rssitemserializer_protobuf.cpp deleted file mode 100644
index d779a8b..0000000
--- a/krss/plugin/rssitemserializer_protobuf.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * This file is part of the krss library
- *
- * Copyright (C) 2009 Frank Osterfeld <osterfeld@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "rssitemserializer.h"
-#include "rssitem.h"
-#include "category.h"
-#include "enclosure.h"
-#include "person.h"
-
-#include "krss.pb.h"
-
-#include <KDateTime>
-
-#include <QString>
-
-#include <string>
-
-using namespace KRss;
-//TODO: in the plugin, do at init time:
-// GOOGLE_PROTOBUF_VERIFY_VERSION;
-//on plugin destruction, do
-//google::protobuf::ShutdownProtobufLibrary();
-
-
-static Protobuf::Person writePerson( const Person& o ) {
- Protobuf::Person r;
- r.set_name( o.name().toUtf8().constData() );
- r.set_email( o.email().toUtf8().constData() );
- r.set_uri( o.uri().toUtf8().constData() );
- return r;
-}
-
-static Protobuf::Enclosure writeEnclosure( const Enclosure& o ) {
- Protobuf::Enclosure r;
- r.set_url( o.url().toUtf8().constData() );
- r.set_title( o.title().toUtf8().constData() );
- r.set_type( o.type().toUtf8().constData() );
- r.set_duration( o.duration() );
- r.set_length( o.length() );
- return r;
-}
-
-static Protobuf::Category writeCategory( const Category& o ) {
- Protobuf::Category r;
- r.set_label( o.label().toUtf8().constData() );
- r.set_scheme( o.scheme().toUtf8().constData() );
- r.set_term( o.term().toUtf8().constData() );
- return r;
-}
-
-void RssItemSerializer::serialize( const KRss::RssItem& item, QByteArray& array, \
ItemPart part ) const
-{
- const bool writeHeaders = part == Full || part == Headers;
- const bool writeContent = part == Full || part == Content;
-
- if ( writeHeaders ) {
- Protobuf::ItemHeader header;
-
- header.set_hash( item.hash() );
- header.set_guidishash( item.guidIsHash() );
- header.set_guid( item.guid().toUtf8().constData() );
- header.set_title( item.title().toUtf8().constData() );
- header.set_link( item.link().toUtf8().constData() );
- header.set_datepublished( item.datePublished().toTime_t() );
- header.set_dateupdated( item.dateUpdated().toTime_t() );
- header.set_language( item.language().toUtf8().constData() );
- Q_FOREACH( const Person& i, item.authors() )
- *header.add_authors() = writePerson( i );
- Q_FOREACH( const Enclosure& i, item.enclosures() )
- *header.add_enclosures() = writeEnclosure( i );
- Q_FOREACH( const Category& i, item.categories() )
- *header.add_categories() = writeCategory( i );
- header.set_commentscount( item.commentsCount() );
- header.set_commentslink( item.commentsLink().toUtf8().constData() );
- header.set_commentsfeed( item.commentsFeed().toUtf8().constData() );
- header.set_commentposturi( item.commentPostUri().toUtf8().constData() );
-
- std::string out;
- header.SerializeToString( &out );
- array.append( out.c_str(), out.size() );
- }
-
- if ( writeContent ) {
- Protobuf::ItemContent content;
-
- content.set_description( item.description().toUtf8().constData() );
- content.set_content( item.content().toUtf8().constData() );
-
- std::string out;
- content.SerializeToString( &out );
- array.append( out.c_str(), out.size() );
- }
-}
-
-static Enclosure readEnclosure( const Protobuf::Enclosure& pe ) {
- Enclosure enc;
- enc.setUrl( QString::fromUtf8( pe.url().c_str() ) );
- enc.setTitle( QString::fromUtf8( pe.title().c_str() ) );
- enc.setType( QString::fromUtf8( pe.type().c_str() ) );
- enc.setDuration( pe.duration() );
- enc.setLength( pe.length() );
- return enc;
-}
-
-static Category readCategory( const Protobuf::Category& pc ) {
- Category cat;
- cat.setLabel( QString::fromUtf8( pc.label().c_str() ) );
- cat.setScheme( QString::fromUtf8( pc.scheme().c_str() ) );
- cat.setTerm( QString::fromUtf8( pc.term().c_str() ) );
- return cat;
-}
-
-
-static Person readPerson( const Protobuf::Person& pp ) {
- Person p;
- p.setName( QString::fromUtf8( pp.name().c_str() ) );
- p.setEmail( QString::fromUtf8( pp.email().c_str() ) );
- p.setUri( QString::fromUtf8( pp.uri().c_str() ) );
- return p;
-}
-
-bool KRss::RssItemSerializer::deserialize( KRss::RssItem& item, const QByteArray& \
array, ItemPart part ) const
-{
- const bool readHeaders = part == Full || part == Headers;
- const bool readContent = part == Full || part == Content;
-
- //TODO: these ifs are wrong, the Full case must be handled differently (FullItem \
message)
-
- if ( readHeaders ) {
- Protobuf::ItemHeader header;
- const bool parsed = header.ParsePartialFromArray( array.constData(), \
array.size() );
- if ( !parsed )
- return false;
- item.setHash( header.hash() );
- item.setGuidIsHash( header.guidishash() );
- item.setGuid( QString::fromUtf8( header.guid().c_str() ) );
- item.setTitle( QString::fromUtf8( header.title().c_str() ) );
- item.setLink( QString::fromUtf8( header.link().c_str() ) );
- KDateTime published;
- published.setTime_t( header.datepublished() );
- item.setDatePublished( published );
- KDateTime updated;
- updated.setTime_t( header.dateupdated() );
- item.setDateUpdated( updated );
-
- QList<Enclosure> enclosures;
- for ( int i = 0; i < header.enclosures_size(); ++i )
- enclosures.append( readEnclosure( header.enclosures( i ) ) );
- item.setEnclosures( enclosures );
-
- QList<Category> categories;
- for ( int i = 0; i < header.categories_size(); ++i )
- categories.append( readCategory( header.categories( i ) ) );
- item.setCategories( categories );
-
- QList<Person> authors;
- for ( int i = 0; i < header.authors_size(); ++i )
- authors.append( readPerson( header.authors( i ) ) );
- item.setAuthors( authors );
-
- item.setCommentsCount( header.commentscount() );
- item.setCommentsLink( QString::fromUtf8( header.commentslink().c_str() ) );
- item.setCommentsFeed( QString::fromUtf8( header.commentsfeed().c_str() ) );
- item.setCommentPostUri( QString::fromUtf8( header.commentposturi().c_str() ) \
);
- }
-
- item.setHeadersLoaded( readHeaders );
-
- if ( readContent ) {
- Protobuf::ItemContent content;
- const bool parsed = content.ParsePartialFromArray( array.constData(), \
array.size() );
- if ( !parsed )
- return false;
- item.setDescription( QString::fromUtf8( content.description().c_str() ) );
- item.setContent( QString::fromUtf8( content.content().c_str() ) );
- }
-
- item.setContentLoaded( readContent );
-
- return true;
-}
-
diff --git a/krss/plugin/tests/CMakeLists.txt b/krss/plugin/tests/CMakeLists.txt
index 203c875..3511962 100644
--- a/krss/plugin/tests/CMakeLists.txt
+++ b/krss/plugin/tests/CMakeLists.txt
@@ -17,22 +17,11 @@ set(testxmlitemserializer_SRCS
testxmlitemserializer.cpp
)
-if(KRSS_ENABLE_PROTOBUF_SERIALIZER)
- WRAP_PROTO(krss_LIB_PROTOBUF_SRCS krss.proto)
-
- set(testxmlitemserializer_SRCS
- ${testxmlitemserializer_SRCS}
- ${krss_LIB_PROTOBUF_SRCS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../rssitemserializer_protobuf.cpp
- )
- set(KRSS_EXTRA_LIBS ${PROTOBUF_LIBRARY})
-else(KRSS_ENABLE_PROTOBUF_SERIALIZER)
if(KRSS_ENABLE_QDATASTREAM_SERIALIZER)
set(testxmlitemserializer_SRCS
${testxmlitemserializer_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/../rssitemserializer_qdatastream.cpp
)
- set(KRSS_EXTRA_LIBS ${PROTOBUF_LIBRARY})
else(KRSS_ENABLE_QDATASTREAM_SERIALIZER)
if(KRSS_ENABLE_JSON_SERIALIZER)
set(testxmlitemserializer_SRCS
@@ -47,6 +36,5 @@ else(KRSS_ENABLE_JSON_SERIALIZER)
)
endif(KRSS_ENABLE_JSON_SERIALIZER)
endif(KRSS_ENABLE_QDATASTREAM_SERIALIZER)
-endif(KRSS_ENABLE_PROTOBUF_SERIALIZER)
add_simple_test(testxmlitemserializer ${testxmlitemserializer_SRCS})
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic