[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepimlibs/kblog
From:       Mehrdad Momeny <mehrdad.momeny () gmail ! com>
Date:       2009-09-13 19:39:44
Message-ID: 1252870784.851112.24541.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1023062 by momeny:

Applying latest fixes on BilboKBlog to KBlog:
+ Fix on Blogger 1.0 API! Some servers sent "postId" instead of "postid" : bc3ddec33
+ Fix on Blogger1 modify and remove post for LJ : 1c8533b2f
+ Problem on Post fetching in Blogger1 API fixed : bb3a3a07
    Reported here: http://bilbo.gnufolks.org/forum/topic/hey-there#post-106
+ Some requests such as ListBlogs() do not relate to a Post, So client may not accept \
post errors Better way is to emit error() no postError() for them : 942258c6e + Fixed \
annoying timestamp problem : 6eaf0a0906

Base fixes are at: http://gitorious.org/bilbo/mainline


 M  +24 -13    blogger1.cpp  
 M  +1 -0      gdata.cpp  
 M  +4 -3      metaweblog.cpp  
 M  +3 -2      movabletype.cpp  
 M  +3 -3      wordpressbuggy.cpp  


--- trunk/KDE/kdepimlibs/kblog/blogger1.cpp #1023061:1023062
@@ -281,9 +281,10 @@
     QMap<QString,QString> blogInfo;
     blogInfo[ "id" ] = postInfo["blogid"].toString();
     blogInfo[ "url" ] = postInfo["url"].toString();
-    blogInfo[ "name" ] = postInfo["blogName"].toString();
+    blogInfo[ "apiUrl" ] = postInfo["xmlrpc"].toString();
+    blogInfo[ "title" ] = postInfo["blogName"].toString();
     kDebug() << "Blog information retrieved: ID =" << blogInfo["id"]
-        << ", Name =" << blogInfo["name"];
+        << ", Name =" << blogInfo["title"];
     blogsList << blogInfo;
   }
   emit q->listedBlogs( blogsList );
@@ -402,7 +403,7 @@
   // dateCreated, String userid, String postid, String content;
   // TODO: Time zone for the dateCreated!
   kDebug() << "TOP:" << result[0].typeName();
-  if ( result[0].type() != QVariant::Bool ) {
+  if ( result[0].type() != QVariant::Bool && result[0].type() != QVariant::Int ) {
     kError() << "Could not read the result, not a boolean.";
     emit q->errorPost( Blogger1::ParsingError,
                           i18n( "Could not read the result, not a boolean." ),
@@ -426,7 +427,7 @@
   // dateCreated, String userid, String postid, String content;
   // TODO: Time zone for the dateCreated!
   kDebug() << "TOP:" << result[0].typeName();
-  if ( result[0].type() != QVariant::Bool ) {
+  if ( result[0].type() != QVariant::Bool && result[0].type() != QVariant::Int ) {
     kError() << "Could not read the result, not a boolean.";
     emit q->errorPost( Blogger1::ParsingError,
                           i18n( "Could not read the result, not a boolean." ),
@@ -447,7 +448,10 @@
   kDebug() << "An error occured: " << errorString;
   BlogPost *post = mCallMap[ id.toInt() ];
 
-  emit q->errorPost( Blogger1::XmlRpc, errorString, post );
+  if(post)
+    emit q->errorPost( Blogger1::XmlRpc, errorString, post );
+  else
+    emit q->error( Blogger1::XmlRpc, errorString );
 }
 
 bool Blogger1Private::readPostFromMap(
@@ -469,26 +473,33 @@
   if ( dt.isValid() && !dt.isNull() ) {
     post->setModificationDateTime( dt.toLocalZone() );
   }
-  post->setPostId( postInfo["postid"].toString() );
+  post->setPostId( postInfo["postid"].toString().isEmpty() ? \
postInfo["postId"].toString() : +                   postInfo["postid"].toString() );
 
   QString title( postInfo["title"].toString() );
   QString description( postInfo["description"].toString() );
-  QString contents( postInfo["content"].toString() );
+  QString contents;
+  if( postInfo["content"].type() == QVariant::ByteArray ) {
+    QByteArray tmpContent = postInfo["content"].toByteArray();
+    contents = QString::fromUtf8(tmpContent.data(), tmpContent.size());
+  } else {
+    contents = postInfo["content"].toString();
+  }
   QStringList category;
 
   // Check for hacked title/category support (e.g. in Wordpress)
   QRegExp titleMatch = QRegExp( "<title>([^<]*)</title>" );
   QRegExp categoryMatch = QRegExp( "<category>([^<]*)</category>" );
-  contents.remove( titleMatch );
-  if ( titleMatch.numCaptures() > 0 ) {
+  if(contents.indexOf(titleMatch) != -1) {
     // Get the title value from the regular expression match
     title = titleMatch.cap( 1 );
   }
+  if ( contents.indexOf(categoryMatch) != -1 ) {
+      // Get the category value from the regular expression match
+      category = categoryMatch.capturedTexts();
+  }
+  contents.remove( titleMatch );
   contents.remove( categoryMatch );
-  if ( categoryMatch.numCaptures() > 0 ) {
-    // Get the category value from the regular expression match
-    category = categoryMatch.capturedTexts();
-  }
 
   post->setTitle( title );
   post->setContent( contents );
--- trunk/KDE/kdepimlibs/kblog/gdata.cpp #1023061:1023062
@@ -555,6 +555,7 @@
       kDebug() << "QRegExp rx( 'blog-(\\d+)' matches" << rx.cap(1);
       blogInfo["id"] = rx.cap(1);
       blogInfo["title"] = ( *it )->title();
+      blogInfo["url"] = ( *it )->link();
       blogInfo["summary"] = ( *it )->description(); //TODO fix/add more
       blogsList << blogInfo;
     } else {
--- trunk/KDE/kdepimlibs/kblog/metaweblog.cpp #1023061:1023062
@@ -230,7 +230,8 @@
     post->setModificationDateTime( dt.toLocalZone() );
   }
 
-  post->setPostId( postInfo["postid"].toString() );
+  post->setPostId( postInfo["postid"].toString().isEmpty() ? \
postInfo["postId"].toString() : +                   postInfo["postid"].toString() );
 
   QString title( postInfo["title"].toString() );
   QString description( postInfo["description"].toString() );
@@ -254,8 +255,8 @@
   map["categories"] = post.categories();
   map["description"] = post.content();
   map["title"] = post.title();
-  map["lastModified"] = post.modificationDateTime().toUtc().dateTime();
-  map["dateCreated"] = post.creationDateTime().toUtc().dateTime();
+  map["lastModified"] = post.modificationDateTime().dateTime().toUTC();
+  map["dateCreated"] = post.creationDateTime().dateTime().toUTC();
   *args << map;
   *args << QVariant( !post.isPrivate() );
   return true;
--- trunk/KDE/kdepimlibs/kblog/movabletype.cpp #1023061:1023062
@@ -334,7 +334,8 @@
     post->setModificationDateTime( dt.toLocalZone() );
   }
 
-  post->setPostId( postInfo["postid"].toString() );
+  post->setPostId( postInfo["postid"].toString().isEmpty() ? \
postInfo["postId"].toString() : +                   postInfo["postid"].toString() );
 
   QString title( postInfo["title"].toString() );
   QString description( postInfo["description"].toString() );
@@ -422,7 +423,7 @@
   if( !post.additionalContent().isEmpty() )
     map["mt_text_more"] = post.additionalContent();
   map["title"] = post.title();
-  map["dateCreated"] = post.creationDateTime().toUtc().dateTime();
+  map["dateCreated"] = post.creationDateTime().dateTime().toUTC();
   map["mt_allow_comments"] = (int)post.isCommentAllowed();
   map["mt_allow_pings"] = (int)post.isTrackBackAllowed();
   map["mt_excerpt"] = post.summary();
--- trunk/KDE/kdepimlibs/kblog/wordpressbuggy.cpp #1023061:1023062
@@ -104,7 +104,7 @@
   
     xmlMarkup += "<name>dateCreated</name>";
     xmlMarkup += "<value><dateTime.iso8601>" +
-                 post->creationDateTime().toUtc().dateTime().toString( \
"yyyyMMddThh:mm:ss" ) + +                 \
post->creationDateTime().dateTime().toUTC().toString( "yyyyMMddThh:mm:ss" ) +  \
"</dateTime.iso8601></value>";  xmlMarkup += "</member><member>";
     xmlMarkup += "<name>mt_allow_comments</name>";
@@ -205,12 +205,12 @@
   
     xmlMarkup += "<name>lastModified</name>";
     xmlMarkup += "<value><dateTime.iso8601>" +
-                 post->modificationDateTime().toUtc().dateTime().toString( \
"yyyyMMddThh:mm:ss" ) + +                 \
post->modificationDateTime().dateTime().toUTC().toString( "yyyyMMddThh:mm:ss" ) +  \
"</dateTime.iso8601></value>";  xmlMarkup += "</member><member>";
     xmlMarkup += "<name>dateCreated</name>";
     xmlMarkup += "<value><dateTime.iso8601>" +
-                 post->creationDateTime().toUtc().dateTime().toString( \
"yyyyMMddThh:mm:ss" ) + +                 \
post->creationDateTime().dateTime().toUTC().toString( "yyyyMMddThh:mm:ss" ) +  \
"</dateTime.iso8601></value>";  xmlMarkup += "</member><member>";
     xmlMarkup += "<name>mt_allow_comments</name>";


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic