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

List:       kde-commits
Subject:    playground/pim/kblogger/src
From:       Antonio Aloisio <antonio.aloisio () gmail ! com>
Date:       2008-03-07 14:29:40
Message-ID: 1204900180.627163.22708.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 783229 by aloisio:

Add enum index to blogList
Add brief description to some classes
Integrate BlogList in BlogServer class.
importMediaWidget is able to get the correct thumbnail RegExp from BlogServer.
Fix some thumbnail RegExp in BlogList
Note: Import Thumbnail works partially. We need to insert others recognize thumbnail \
                regexp. At moment wordpres.com, wordpress and blogger.com will works. \
                
ISSUE: Thumbnails import can fail some time. For example kblogger can put the \
ImageA-Thumbnail.jps as child of ImageB.jpg.


 M  +3 -1      backend/backend.cpp  
 M  +3 -3      backend/bloglist.cpp  
 M  +14 -1     backend/bloglist.h  
 M  +29 -1     backend/blogserver.cpp  
 M  +29 -9     backend/blogserver.h  
 M  +15 -4     media/importmediawidget.cpp  


--- trunk/playground/pim/kblogger/src/backend/backend.cpp #783228:783229
@@ -420,7 +420,9 @@
 
 BlogServer Backend::blogServer(const QString& blogname)
 {
-    kDebug();
+    kDebug() << "BlogName:" << blogname 
+             << "Blog stored in the Map" << mBlogsMap.count();
+
     return mBlogsMap[blogname];
 }
 
--- trunk/playground/pim/kblogger/src/backend/bloglist.cpp #783228:783229
@@ -56,7 +56,7 @@
 blogHash["urlTransformRegExp"] =  QRegExp( \
"(http://.+\\.(blogger|Blogspot.com)\\.com).+" ); // set a general gateway  \
blogHash["urlReplacementString"] = QString( "\\1" ); // no gateway here  \
                blogHash["htmlRegExp"] = QRegExp( \
                "content='blogger'\\s+name='generator'" );
-blogHash["thumbnailRegExp"] = QRegExp( \
"http://[\\d\\w]*\\.blogger\\.com/([\\d\\w]*/){1,4}s320/IMG_\\d*.JPG" ); \
+blogHash["thumbnailRegExp"] = QRegExp( \
"http://[\\d\\w]*\\.blogger\\.com/([\\d\\w]*/){1,4}s320/IMG_\\d*.[\\w]{3,3}" ); \
//TODO TEST IT!  
 blogList << blogHash;
 blogHash.clear();
@@ -82,7 +82,7 @@
 blogHash["urlTransformRegExp"] =  QRegExp( "(http://.+\\.wordpress\\.com).+" ); // \
set a general gateway  blogHash["urlReplacementString"] = QString( "\\1/xmlrpc.php" \
);  blogHash["htmlRegExp"] = QRegExp( \
                "name=\"generator\"\\s+content=\"WordPress.com\"" );
-blogHash["thumbnailRegExp"] = QRegExp("http://\\.*/[^/]*\\.thumbnail\\.[\\w]{3,3}"); \
// TODO TEST IT! +blogHash["thumbnailRegExp"] = \
QRegExp("http://.*.files.wordpress.com/[\\d]{4,4}/[\\d]{2,2}/.*.thumbnail.[\\w]{3,3}"); \
// TODO TEST IT!  
 blogList << blogHash;
 blogHash.clear();
@@ -160,7 +160,7 @@
 blogHash["urlTransformRegExp"] =  QRegExp( "(http://.+)" ); // set a general gateway \
// TODO  blogHash["urlReplacementString"] = QString( "\\1/xmlrpc.php" );
 blogHash["htmlRegExp"] = QRegExp( \
                "name=\"generator\"\\s+content=\"WordPress\\s+\\d\\.\\d\\.\\d\"" );
-blogHash["thumbnailRegExp"] = QRegExp("http://\\.*/[^/]*\\.thumbnail\\.[\\w]{3,3}"); \
// TODO Test It +blogHash["thumbnailRegExp"] = \
QRegExp("http://.*/wp-content/uploads/[\\d]{4,4}/[\\d]{2,2}/.*.thumbnail.[\\w]{3,3}"); \
// TESTED  
 blogList << blogHash;
 blogHash.clear();
--- trunk/playground/pim/kblogger/src/backend/bloglist.h #783228:783229
@@ -25,7 +25,20 @@
 #include <QtCore/QVariant>
 #include <QtCore/QString>
 #include <QtCore/QStringList>
-
+ /**
+  * @brief
+  * BlogList return a List of blog parameters such as api, sitename ecc..
+  *
+  * Usage:
+  *
+  *  QList<QHash<QString,QVariant> >  mBlogList;
+  *  QString mApi;
+  *
+  *  mBlogList= blogList();
+  *  mApi=mBlogList[ Wordpress_com ][ "api" ];
+  *
+  */
+ enum blogType{ Blogspot, Wordpress_com, LiveJournal_com, Drupal, Wordpress, General \
};  QList<QHash<QString,QVariant> > BlogList();
 
 #endif
--- trunk/playground/pim/kblogger/src/backend/blogserver.cpp #783228:783229
@@ -20,16 +20,21 @@
 
 #include "blogserver.h"
 
+#include <QList>
+
 #include <kwallet.h>
 #include <kicon.h>
 #include <kmimetype.h>
 #include <kdebug.h>
 
+#include "bloglist.h"
+
 namespace KBlogger
 {
 
 BlogServer::BlogServer(): mWallet(0)
 {
+    kDebug();
     mWallet = KWallet::Wallet::openWallet( "kdewallet", 0 );
     if ( mWallet ) {
         mWallet->setFolder( "kblogger" );
@@ -39,38 +44,47 @@
 }
 
 BlogServer::~BlogServer()
-{}
+{
+    kDebug();
+}
 
 void BlogServer::setBlogname( const QString& blogname )
 {
+    kDebug();
     mBlogname = blogname;
 }
 
 QString BlogServer::blogname()
 {
+    kDebug();
     return mBlogname;
 }
 
 void BlogServer::setUrl( const QString& url )
 {
+    kDebug();
     mUrl = url;
 }
 
 KUrl BlogServer::url()
 {
+    kDebug();
     return mUrl;
 }
 
 void BlogServer::setUsername( const QString& username )
 {
+    kDebug();
     mUsername = username;
 }
 
 QString BlogServer::username()
 {
+    kDebug();
     return mUsername;
 }
 
+/*
 void BlogServer::setFullName( const QString& fullName )
 {
     mFullName = fullName;
@@ -80,6 +94,7 @@
 {
     return mFullName;
 }
+*/
 
 QString BlogServer::password()
 {
@@ -97,26 +112,39 @@
 
 void BlogServer::setType( int type)
 {
+    kDebug();
     mType = type;
 }
 
 int BlogServer::type()
 {
+    kDebug();
     return mType;
 }
 
 void BlogServer::setBlogId( const QString& id )
 {
+    kDebug();
     mBlogId = id;
 }
 
 QString BlogServer::blogId()
 {
+    kDebug();
     return mBlogId;
 }
 
+QVariant BlogServer::getBlogServerValue( QString parameter )
+{
+   kDebug() << "Blog Type:" << type() << "Parameter to get:" << parameter;
+   QList<QHash<QString,QVariant> > mBlogList;
+   mBlogList= BlogList();
+   return mBlogList[ type() ][ parameter ];
+}
+
 KIcon BlogServer::icon()
 {
+    kDebug();
     QString iconName;
     iconName = KMimeType::iconNameForUrl(mUrl);
     kDebug() << "icon=" << iconName;
--- trunk/playground/pim/kblogger/src/backend/blogserver.h #783228:783229
@@ -22,6 +22,7 @@
 #ifndef KBLOGGER_BLOG_H
 #define KBLOGGER_BLOG_H
 
+#include <qvariant.h>
 #include <kurl.h>
 
 #include "backend/backend.h"
@@ -37,11 +38,19 @@
 {
 
 /**
-  @brief
-  This class represents a BlogServer (or simply a Blog) and not only an API. 
-  We need this to add more stuff like the icons and the blog name and map it
-  to a type (which then maps to an API (KBlog::Blog)).
-*/
+ * @brief
+ * This class represents a BlogServer (or simply a Blog) and not only an API. 
+ * We need this to add more stuff like the icons and the blog name and map it
+ * to a type (which then maps to an API (KBlog::Blog)).
+ *
+ *  Usage:
+ *  Every kblogger class can access to blogServer information using backend.
+ *  So for example if a kblogger class need to know the url
+ *  you need something simple like this:
+ *  
+ *  KUrl mUrl;
+ *  mUrl=backend::self()->blogServer( blogname_or_profilename )->url();
+ */
 
 
 class BlogServer
@@ -52,29 +61,40 @@
 
     ~BlogServer();
 
+    //It's the profile name of this blogserver settings.
     void setBlogname( const QString& blogname );
     QString blogname();
 
+    //BlogServer Url
     void setUrl( const QString& url );
     KUrl url();
 
+    //Account username
     void setUsername( const QString& username );
     QString username();
-
+    
+    //Account password
+    //void setPassword( const QString& password );
+    QString password();
+    
+    /*
     void setFullName( const QString& fullname );
     QString fullName();
+    */
 
-    //void setPassword( const QString& password );
-    QString password();
-
+    //blog type. watch 
     void setType( int type );
     int type();
 
+    //Blog ID
     void setBlogId( const QString& id );
     QString blogId();
 
     KIcon icon();
 
+    //get a BlogServer parameter
+    QVariant getBlogServerValue( QString parameter );
+
 private:
     QString mBlogname;
     KUrl    mUrl;
--- trunk/playground/pim/kblogger/src/media/importmediawidget.cpp #783228:783229
@@ -32,6 +32,8 @@
 
 #include "media/media.h"
 #include "itemsmanager.h"
+#include "backend/backend.h"
+#include "backend/blogserver.h"
 
 namespace KBlogger
 {
@@ -65,7 +67,10 @@
 
 bool ImportMediaWidget::addUrl(const QString& imageUrl, const QString& blogname, \
const QString& postId)  {
-    kDebug();
+    kDebug() << "ImageUrl" << imageUrl
+             << "Blogname" << blogname
+             << "Post ID" << postId;
+
     Q_ASSERT( !imageUrl.isEmpty() );
     Q_ASSERT( !blogname.isEmpty() );
 
@@ -78,9 +83,13 @@
         return false;
     }
 
-    QRegExp thumbnailUrlRx("thumb");/*TODO Get thumbnailUrlRx from BlogList*/
-
+    //QRegExp thumbnailUrlRx("thumb");/*TODO Get thumbnailUrlRx from BlogList*/
+    QString thumbRegExpString;
+    BlogServer blogServ= Backend::self()->blogServer( blogname );
+    QRegExp thumbnailUrlRx = \
blogServ.getBlogServerValue("thumbnailRegExp").toRegExp(); +    kDebug() << \
"thumbnailUrlRx pattern:" << thumbnailUrlRx.pattern();  QTreeWidgetItem *item;
+    
     /*NOTE  usually the code that contains a thumbnail looks like this:
      * <a href="myimage.jpg" >
      *   <img src="myimage.thumb.jpg">   <--thumbnailUrlRx will match the string \
between the '"'. @@ -88,7 +97,9 @@
      * So kblogger will process the thumbnail before the image.
      */
     //FIXME does this only simple condition work reliably?
-    if ( imageUrl.contains( thumbnailUrlRx ) ) {
+    if ( !thumbnailUrlRx.pattern().isEmpty() &&
+	  imageUrl.contains( thumbnailUrlRx ) 
+       ) {
         item = new QTreeWidgetItem( treeItemList.last() ); //Thumbnail
     }else{
         item = new QTreeWidgetItem( mediaTreeWidget ); //No Thumbnail


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

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