example/LastFmAuthApp/inc/baseDialog.h
changeset 26 83d6a149c755
equal deleted inserted replaced
25:a180113055cb 26:83d6a149c755
       
     1 /**
       
     2 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "{License}"
       
     6 * which accompanies  this distribution, and is available
       
     7 * at the URL "{LicenseUrl}".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Narasimhulu Kavadapu, Sasken Communication Technologies Ltd - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Siddhartha Chandra, Sasken Communication Technologies Ltd
       
    14 * Description:
       
    15 * Base class of All dialogs
       
    16 */
       
    17 
       
    18 #ifndef FB_DIALOG_H_
       
    19 #define FB_DIALOH_H_
       
    20 
       
    21 #include <QDialog>
       
    22 #include <QWebView>
       
    23 #include <QWebSettings>
       
    24 #include <qprogressbar.h>
       
    25 #include <qboxlayout.h>
       
    26 #include "authAppConstants.h"
       
    27 //#include "QScrollArea"
       
    28 // FORWARD DECLARATIONS
       
    29 class FBSession;
       
    30 class FBError;
       
    31 class QNetworkReply;
       
    32 
       
    33 //#define __WINSCW__
       
    34 
       
    35 /**
       
    36   * The base Dialoggg
       
    37   */
       
    38 class FBDialog : public QWidget
       
    39 {
       
    40     Q_OBJECT
       
    41 
       
    42 protected:
       
    43 
       
    44     /**
       
    45     * The session for which the login is taking place.
       
    46     */
       
    47     FBSession*	iSession;
       
    48     QWebView*	iWebView;
       
    49     QWebSettings* iWebSettings;
       
    50     QString	iLoadingUrl;
       
    51     QProgressBar* progressbar;
       
    52     QVBoxLayout* layout;
       
    53 
       
    54 signals:
       
    55 
       
    56     /**
       
    57      * Called when the dialog succeeds and is about to be dismissed.
       
    58      */
       
    59     void dialogDidSucceed ();
       
    60 
       
    61     /**
       
    62      * Called when the dialog is cancelled and is about to be dismissed.
       
    63      */
       
    64     void dialogDidCancel();
       
    65 
       
    66     /**
       
    67      * Called when dialog failed to load due to an error.
       
    68      */
       
    69     void dialogDidFailWithError ( const FBError& error );
       
    70 
       
    71 
       
    72 	
       
    73 private slots:
       
    74     void cancel();
       
    75 
       
    76     /* slots for signals from QWebView.page() */
       
    77     void linkClicked ( const QUrl & url );
       
    78     void loadStarted ();
       
    79     void loadProgress(int progress);
       
    80     void loadFinished ( bool ok );
       
    81     //void urlChanged ( const QUrl & url );
       
    82     //Network Error Slots
       
    83     void slotAuthenticationRequired( QNetworkReply* reply, QAuthenticator* authenticator );
       
    84     void slotsslErrors( QNetworkReply* reply, const QList<QSslError>& errors  );
       
    85     void slotproxyAuthenticationRequired( const QNetworkProxy& proxy, QAuthenticator* authenticator  );
       
    86 
       
    87 public:
       
    88 	
       
    89 	void proxysettings();
       
    90     /**
       
    91     * Creates the view but does not display it.
       
    92     */
       
    93     FBDialog(FBSession* aSession);
       
    94     FBDialog();
       
    95 
       
    96     /**
       
    97     * Displays the view with an animation.
       
    98     *
       
    99     * The view will be added to the top of the current key window.
       
   100     */
       
   101     void show();
       
   102 	
       
   103     /** Displays the first page of the dialog.
       
   104      *
       
   105      * Do not ever call this directly.  It is intended to be overriden by subclasses.
       
   106      */
       
   107     virtual void load ();
       
   108 		
       
   109     /**
       
   110      * Displays a URL in the dialog.
       
   111      */
       
   112     void loadURL(const QString& aUrl, QNetworkAccessManager::Operation aMethod, const QHash<QString, QString>& aGetParams,
       
   113                  const QHash<QString, QString>&  aPostParams);
       
   114 
       
   115 
       
   116     void dismiss(bool aAnimated);
       
   117 
       
   118     /**
       
   119      * Hides the view and notifies delegates of success or cancellation.
       
   120      */
       
   121     void dismissWithSuccess (bool aSuccess, bool aAnimated);
       
   122 
       
   123     /**
       
   124     * Hides the view and notifies delegates of an error.
       
   125     */
       
   126     void dismissWithError (const FBError& aError);
       
   127 
       
   128     /**
       
   129     * Subclasses may override to perform actions just prior to showing the dialog.
       
   130     */
       
   131     virtual void dialogWillAppear();
       
   132 
       
   133     /**
       
   134      * Subclasses may override to perform actions just after the dialog is hidden.
       
   135      */
       
   136     virtual void dialogWillDisappear();
       
   137 
       
   138     /**
       
   139      * Subclasses should override to process data returned from the server in a 'fbconnect' url.
       
   140      *
       
   141      * Implementations must call dismissWithSuccess:YES at some point to hide the dialog.
       
   142      */
       
   143     virtual void dialogDidSucceed(const QUrl& aUrl);
       
   144 	
       
   145     QString title() const;
       
   146     void setTitle ( const QString& aTitle );
       
   147     
       
   148     virtual void GetSessionKey(const QUrl& aUrl);
       
   149     
       
   150     virtual void connectToGetSession();
       
   151 
       
   152 private:
       
   153     void createControls();
       
   154     QString generateURL( const QString& aUrl, const QHash<QString, QString>& aParams) const;
       
   155     QByteArray generatePostBody (const QHash<QString, QString>& aParams) const;
       
   156 
       
   157     void postDismissCleanup();
       
   158 private:
       
   159     bool flag;
       
   160     QUrl urlShoot;
       
   161  };
       
   162 #endif