[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-04 22:33:42
Message-ID: 1204670022.425401.8669.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 782365 by aloisio:

Add Autoconfiguration progress dialog
Cleanup

 M  +1 -1      backend/bloglist.cpp  
 M  +75 -32    profiles/profileconfigdialog.cpp  
 M  +7 -1      profiles/profileconfigdialog.h  


--- trunk/playground/pim/kblogger/src/backend/bloglist.cpp #782364:782365
@@ -167,7 +167,7 @@
 
 blogHash["api"] = "Blogger1";
 blogHash["sitename"] = "General XML-RPC Gateway";
-blogHash["configInfo"] = i18n( "You may have tried to autoconfigure the XML-RPC \
gateway. For autoconfigure to work correctly you need to insert the URL to your \
blog's homepage and not the XML-RPC gateway. This might also happen if you \
autoconfigure twice. Otherwise this is your personal undetectable XML-RPC \
installation. We assume Blogger API 1.0 for now. If you are confident that your \
server supports more than that, chose Wordpress as type."  ); +blogHash["configInfo"] \
= i18n( "For autoconfigure to work correctly you need to insert the URL to your \
blog's homepage and not the XML-RPC gateway.\n Otherwise this is your personal \
undetectable XML-RPC installation.\n We assume Blogger API 1.0 for now. If you are \
confident that your server supports more than that, chose Wordpress as type."  );  \
blogHash["hasUserProfiles"] = false;  blogHash["hasTitleSupport"] = true;
 blogHash["hasCategorySupport"] = true;
--- trunk/playground/pim/kblogger/src/profiles/profileconfigdialog.cpp #782364:782365
@@ -29,6 +29,7 @@
 #include <kconfigdialog.h>
 #include <kio/job.h>
 #include <kmessagebox.h>
+#include <kprogressdialog.h>
 
 #include <kblog/gdata.h>
 #include <kblog/blogger1.h>
@@ -44,7 +45,8 @@
 {
 
 ProfileConfigDialog::ProfileConfigDialog(KConfigDialog* parent): mWallet(0), \
                mBlog(0),
-                               mFetchIdTimer(0),mFetchAPITimer(0),mLastShot(false)
+                               mFetchIdTimer(0),mFetchAPITimer(0),mLastShot(false),
+			       mAutoConfProgressDialog(0)
 {
     kDebug();
 
@@ -159,26 +161,22 @@
              mBlogList[i]["urlRegExp"].toRegExp().indexIn( kcfg_Url->text() ) != -1 \
                ){
             kDebug() << "matched :" << mBlogList[i]["sitename"].toString();
             // select the combobox string
-            kcfg_Type->setCurrentIndex(
-                               kcfg_Type->findText( \
mBlogList[i]["sitename"].toString() ) +            kcfg_Type->setCurrentIndex( \
kcfg_Type->findText( mBlogList[i]["sitename"].toString() )  );
             // adjust the url string 
-            kcfg_Url->setText(
-                                kcfg_Url->text().replace( \
                mBlogList[i]["urlTransformRegExp"].toRegExp(),
-                                                                        \
mBlogList[i]["urlReplacementString"].toString() ) +            kcfg_Url->setText( \
kcfg_Url->text().replace( mBlogList[i]["urlTransformRegExp"].toRegExp(), +			       \
mBlogList[i]["urlReplacementString"].toString() )  );
-            label->setText( mBlogList[i]["configInfo"].toString() );
+	    
+            showMessageDialog(i);
+	    
             fetchBlogId();
             return;
         }
     }
 
-    mFetchAPITimer = new QTimer( this );
-    mFetchAPITimer->setSingleShot( true );
-    connect( mFetchAPITimer, SIGNAL( timeout() ),
-                    this, SLOT( handleFetchAPITimeout() ) );
-    mFetchAPITimer->start( TIMEOUT );
-
+    showProgressDialog();
+    
     // try to get the api from the html otherwise
     httpGetJob = KIO::storedGet( kcfg_Url->text(), KIO::NoReload, \
KIO::HideProgressInfo );  
@@ -214,7 +212,7 @@
                 connect( mBlog, SIGNAL(listedBlogs( const QList<QMap<QString, \
                QString> >&)),
                      this, SLOT(fetchedBlogId( const QList<QMap<QString, QString> \
                >&)));
                 connect( mBlog, SIGNAL(error( KBlog::Blog::ErrorType, const QString& \
                ) ),
-                     this, SLOT( handleFetchError( KBlog::Blog::ErrorType, const \
QString& ) ) ); +                     this, SLOT( handleFetchBlogIdError( \
KBlog::Blog::ErrorType, const QString& ) ) );  \
qobject_cast<KBlog::Blogger1*>(mBlog)->listBlogs();  }
 
@@ -229,7 +227,7 @@
 //                 connect( mBlog, SIGNAL(listedBlogs( const QList<QMap<QString, \
QString> >&)),  //                      this, SLOT(fetchedBlogId( const \
QList<QMap<QString, QString> >&)));  //                 connect( mBlog, SIGNAL(error( \
                KBlog::Blog::ErrorType, const QString& ) ),
-//                      this, SLOT( handleFetchError( KBlog::Blog::ErrorType, const \
QString& ) ) ); +//                      this, SLOT( handleFetchBlogIdError( \
KBlog::Blog::ErrorType, const QString& ) ) );  //                 \
qobject_cast<KBlog::GData*>(mBlog)->listBlogs();  }
 
@@ -258,15 +256,16 @@
     mAutoconfigureButton->setEnabled( true );
 }
 
-void ProfileConfigDialog::handleFetchError( KBlog::Blog::ErrorType, const QString& \
error ) +void ProfileConfigDialog::handleFetchBlogIdError( KBlog::Blog::ErrorType, \
const QString& error )  {
     kDebug();
+    
     delete mFetchIdTimer;
     mFetchIdTimer = 0;
-    KMessageBox::error( 0,
-                        error );
+    
+    KMessageBox::error( this, error );
+    
     kcfg_BlogId->setText( QString() );
-//     kcfg_BlogId->setEditable( true );
     kcfg_BlogId->setEnabled( true );
     mFetchIDButton->setEnabled( true );
     mAutoconfigureButton->setEnabled( true );
@@ -275,12 +274,13 @@
 void ProfileConfigDialog::handleFetchIDTimeout()
 {
     kDebug();
+    
     delete mFetchIdTimer;
     mFetchIdTimer = 0;
+    
     KMessageBox::error( this,
                         i18n( "Fetching the blog's id timed out. Are you online?" \
));  kcfg_BlogId->setText( QString() );
-//     kcfg_BlogId->setEditable( true );
     kcfg_BlogId->setEnabled( true );
     mFetchIDButton->setEnabled( true );
     mAutoconfigureButton->setEnabled( true );
@@ -289,11 +289,12 @@
 void ProfileConfigDialog::handleFetchAPITimeout()
 {
     kDebug();
-    delete mFetchAPITimer;
-    mFetchAPITimer = 0;
+    
+    hideProgressDialog();
+    
     KMessageBox::error( this,
                         i18n( "Autoconfiguration timed out. Are you online?" ));
-//     kcfg_BlogId->setEditable( true );
+    
     kcfg_BlogId->setEnabled( true );
     mFetchIDButton->setEnabled( true );
     mAutoconfigureButton->setEnabled( true );
@@ -302,11 +303,12 @@
 void ProfileConfigDialog::fetchedProfileId( const QString &id )
 {
     kDebug();
+    Q_UNUSED(id);
     mFetchIdTimer->start( TIMEOUT ); // restart the timer for the second id fetching
     connect( qobject_cast<KBlog::GData*>(mBlog), SIGNAL(listedBlogs( const \
                QList<QMap<QString, QString> >&)),
              this, SLOT(fetchedBlogId( const QList<QMap<QString, QString> >&)));
     connect( qobject_cast<KBlog::GData*>(mBlog), SIGNAL(error( \
                KBlog::Blog::ErrorType, const QString& ) ),
-             this, SLOT( handleFetchError( KBlog::Blog::ErrorType, const QString& ) \
) ); +             this, SLOT( handleFetchBlogIdError( KBlog::Blog::ErrorType, const \
QString& ) ) );  qobject_cast<KBlog::GData*>(mBlog)->listBlogs();
 }
 
@@ -314,14 +316,19 @@
 {
     kDebug();
     if(!job) return;
+    
+    //Delete Uneeded objects
+    hideProgressDialog();
+    
+    //There is a job error?
     if ( job->error() ) {
-        KMessageBox::error( 0,
+        KMessageBox::error( this,
                             job->errorString());
+	
         mAutoconfigureButton->setEnabled( true );
-        delete mFetchAPITimer;
-        mFetchAPITimer = 0;
         return;
     }
+    
     QString httpData( qobject_cast<KIO::StoredTransferJob*>(job)->data() );
     delete job;
 
@@ -339,8 +346,9 @@
                                 kcfg_Url->text().replace( \
                mBlogList[i]["urlTransformRegExp"].toRegExp(),
                                                                         \
mBlogList[i]["urlReplacementString"].toString() )  );
-            label->setText( mBlogList[i]["configInfo"].toString() );
 
+	    showMessageDialog(i);
+	    
             // HACK if we have recalled ourselves and we are here (have hit the \
generic xml-rpc) than we need to update the url  if( mLastShot ){
                 kcfg_Url->setText( kcfg_Url->text() + "/xmlrpc.php" );
@@ -355,29 +363,64 @@
                 mAutoconfigureButton->setEnabled( true );
             }
             else fetchBlogId();
-            delete mFetchAPITimer;
-            mFetchAPITimer = 0;
             return;
         }
     }
 
     if( !mLastShot ){
         // HACK do a last attempt and recall with +/xmlrpc.php
+        showProgressDialog();
         httpGetJob = KIO::storedGet( kcfg_Url->text() + "/xmlrpc.php", \
KIO::NoReload, KIO::HideProgressInfo ); +
         mLastShot = true;
 
         connect( httpGetJob, SIGNAL( result( KJob* ) ),
                  this, SLOT( gotHtml( KJob* ) ) );
     }
     else {
-        delete mFetchAPITimer;
-        mFetchAPITimer = 0;
         mAutoconfigureButton->setEnabled( true );
         KMessageBox::error( this,
                             i18n("Impossible to get the API. Check your settings, \
especially the url."));  }
 }
 
+void ProfileConfigDialog::showProgressDialog(){
+    kDebug();
+    if ( !mAutoConfProgressDialog ){
+      mAutoConfProgressDialog= new KProgressDialog(this, "Weblog Autoconfiguration",
+	 					   "Please wait while kblogger is tryng to collect your weblog infos");
+    }
+    
+    mAutoConfProgressDialog->setAllowCancel(false);
+     
+    mFetchAPITimer = new QTimer( this );
+    mFetchAPITimer->setSingleShot( true );
+    connect( mFetchAPITimer, SIGNAL( timeout() ),
+                    this, SLOT( handleFetchAPITimeout() ) );
+    mFetchAPITimer->start( TIMEOUT );
+}
+
+void ProfileConfigDialog::hideProgressDialog(){
+    kDebug();
+    delete mFetchAPITimer;
+    mFetchAPITimer = 0;
+    delete mAutoConfProgressDialog;
+    mAutoConfProgressDialog=0;
+}
+
+void ProfileConfigDialog::showMessageDialog(int api){
+    kDebug();
+    
+    if ( api == 5 ){ // 5 is bloggerApi in blogList.cpp
+        //Autoconfiguration failed!
+	if ( mLastShot ) //Show only the last sorry message
+	    KMessageBox::sorry( this,  mBlogList[api]["configInfo"].toString() );
+        else{
+	    KMessageBox::information( this,  mBlogList[api]["configInfo"].toString() );
+        }
+    }
+}
+
 } //namespace
 
 #include "profileconfigdialog.moc"
--- trunk/playground/pim/kblogger/src/profiles/profileconfigdialog.h #782364:782365
@@ -32,6 +32,7 @@
 class QTimer;
 class QVariant;
 class KConfigDialog;
+class KProgressDialog;
 
 namespace KIO
 {
@@ -72,13 +73,17 @@
     void fetchBlogId();
     void fetchedBlogId( const QList<QMap<QString, QString> >& );
     void fetchedProfileId( const QString& );
-    void handleFetchError( KBlog::Blog::ErrorType, const QString& );
+    void handleFetchBlogIdError( KBlog::Blog::ErrorType, const QString& );
     void handleFetchIDTimeout();
     void handleFetchAPITimeout();
 
     void gotHtml(KJob *);
 
 private:
+    void showProgressDialog();
+    void hideProgressDialog();
+    void showMessageDialog(int api);
+    
     KWallet::Wallet* mWallet;
     KConfigDialog* parent;
     KBlog::Blog* mBlog;
@@ -87,6 +92,7 @@
     QTimer* mFetchAPITimer;
     KIO::Job *httpGetJob;
     bool mLastShot; // needed for a last attempt of autoconfiguration
+    KProgressDialog  *mAutoConfProgressDialog;
 };
 }
 #endif


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

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