example/LinkedInAuthApp/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, Satish Kanteti 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 <qprogressbar.h>
       
    24 #include <qboxlayout.h>
       
    25 #include "authAppConstants.h"
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class FBSession;
       
    29 class FBError;
       
    30 class QNetworkReply;
       
    31 
       
    32 /**
       
    33   * The base Dialoggg
       
    34   */
       
    35 class FBDialog : public QWidget
       
    36 {
       
    37     Q_OBJECT
       
    38 
       
    39 protected:
       
    40 
       
    41     /**
       
    42     * The session for which the login is taking place.
       
    43     */
       
    44     FBSession*	iSession;
       
    45     QWebView*	iWebView;
       
    46     QWebSettings* iWebSettings;
       
    47     QString	iLoadingUrl;
       
    48     int count;
       
    49     bool        iIgnorePageLoadCompleteEvent;
       
    50     QProgressBar* progressbar;
       
    51     QVBoxLayout* layout;
       
    52 
       
    53 signals:
       
    54 
       
    55     /**
       
    56      * Called when the dialog succeeds and is about to be dismissed.
       
    57      */
       
    58     void dialogDidSucceed ();
       
    59 
       
    60     /**
       
    61      * Called when the dialog is cancelled and is about to be dismissed.
       
    62      */
       
    63     void dialogDidCancel();
       
    64 
       
    65     /**
       
    66      * Called when dialog failed to load due to an error.
       
    67      */
       
    68     void dialogDidFailWithError ( const FBError& error );
       
    69 
       
    70 
       
    71 	
       
    72 private slots:
       
    73     void cancel();
       
    74 
       
    75     /* slots for signals from QWebView.page() */
       
    76     void linkClicked ( const QUrl & url );
       
    77     void loadStarted ();
       
    78     void loadProgress(int progress);
       
    79     void loadFinished ( bool ok );
       
    80     
       
    81     //Network Error Slots
       
    82     void slotAuthenticationRequired( QNetworkReply* reply, QAuthenticator* authenticator );
       
    83     void slotsslErrors( QNetworkReply* reply, const QList<QSslError>& errors  );
       
    84     void slotproxyAuthenticationRequired( const QNetworkProxy& proxy, QAuthenticator* authenticator  );
       
    85 
       
    86 public:
       
    87 	
       
    88 	void proxysettings();
       
    89     /**
       
    90     * Creates the view but does not display it.
       
    91     */
       
    92     FBDialog(FBSession* aSession);
       
    93     FBDialog();
       
    94 
       
    95     /**
       
    96     * Displays the view with an animation.
       
    97     *
       
    98     * The view will be added to the top of the current key window.
       
    99     */
       
   100     void show();
       
   101 	
       
   102     /** Displays the first page of the dialog.
       
   103      *
       
   104      * Do not ever call this directly.  It is intended to be overriden by subclasses.
       
   105      */
       
   106     virtual void load ();
       
   107 		
       
   108     /**
       
   109      * Displays a URL in the dialog.
       
   110      */
       
   111     void loadURL(const QString& aUrl, QNetworkAccessManager::Operation aMethod, const QHash<QString, QString>& aGetParams,
       
   112                  const QHash<QString, QString>&  aPostParams);
       
   113 
       
   114 
       
   115     void dismiss(bool aAnimated);
       
   116 
       
   117     /**
       
   118      * Hides the view and notifies delegates of success or cancellation.
       
   119      */
       
   120     void dismissWithSuccess (bool aSuccess, bool aAnimated);
       
   121 
       
   122     /**
       
   123     * Hides the view and notifies delegates of an error.
       
   124     */
       
   125     void dismissWithError (const FBError& aError, bool aAnimated);
       
   126 
       
   127     /**
       
   128     * Subclasses may override to perform actions just prior to showing the dialog.
       
   129     */
       
   130     virtual void dialogWillAppear();
       
   131 
       
   132     /**
       
   133      * Subclasses may override to perform actions just after the dialog is hidden.
       
   134      */
       
   135     virtual void dialogWillDisappear();
       
   136 
       
   137     /**
       
   138      * Subclasses should override to process data returned from the server in a 'fbconnect' url.
       
   139      *
       
   140      * Implementations must call dismissWithSuccess:YES at some point to hide the dialog.
       
   141      */
       
   142     virtual void dialogDidSucceed(const QUrl& aUrl);
       
   143 	
       
   144     QString title() const;
       
   145     void setTitle ( const QString& aTitle );
       
   146     
       
   147     virtual void GetSessionKey(const QUrl& aUrl);
       
   148     virtual void FetchKeyFromUrl(const QUrl& aUrl);
       
   149     virtual void GetAccessToken();
       
   150 private:
       
   151     void createControls();
       
   152     QString generateURL( const QString& aUrl, const QHash<QString, QString>& aParams) const;
       
   153     QByteArray generatePostBody (const QHash<QString, QString>& aParams) const;
       
   154 
       
   155     void postDismissCleanup();
       
   156 
       
   157 
       
   158  };
       
   159 #endif