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