diff -r a180113055cb -r 83d6a149c755 example/TwitterAuthApp/inc/baseDialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/TwitterAuthApp/inc/baseDialog.h Mon Oct 11 21:59:54 2010 +0530 @@ -0,0 +1,157 @@ +/** +* Copyright (c) 2010 Sasken Communication Technologies Ltd. +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the "{License}" +* which accompanies this distribution, and is available +* at the URL "{LicenseUrl}". +* +* Initial Contributors: +* Narasimhulu Kavadapu, Sasken Communication Technologies Ltd - Initial contribution +* +* Contributors: +* Siddhartha Chandra, Sasken Communication Technologies Ltd +* Description: +* Base class of All dialogs +*/ + +#ifndef FB_DIALOG_H_ +#define FB_DIALOH_H_ + +#include +#include +#include +#include +#include "authAppConstants.h" + +// FORWARD DECLARATIONS +class FBSession; +class FBError; +class QNetworkReply; + +/** + * The base Dialoggg + */ +class FBDialog : public QWidget +{ + Q_OBJECT + +protected: + + /** + * The session for which the login is taking place. + */ + FBSession* iSession; + QWebView* iWebView; + QString iLoadingUrl; + bool iIgnorePageLoadCompleteEvent; + QProgressBar* progressbar; + QVBoxLayout* layout; + +signals: + + /** + * Called when the dialog succeeds and is about to be dismissed. + */ + void dialogDidSucceed (); + + /** + * Called when the dialog is cancelled and is about to be dismissed. + */ + void dialogDidCancel(); + + /** + * Called when dialog failed to load due to an error. + */ + void dialogDidFailWithError ( const FBError& error ); + + + +private slots: + void cancel(); + + /* slots for signals from QWebView.page() */ + void linkClicked ( const QUrl & url ); + void loadStarted (); + void loadProgress(int progress); + void loadFinished ( bool ok ); + + //Network Error Slots + void slotAuthenticationRequired( QNetworkReply* reply, QAuthenticator* authenticator ); + void slotsslErrors( QNetworkReply* reply, const QList& errors ); + void slotproxyAuthenticationRequired( const QNetworkProxy& proxy, QAuthenticator* authenticator ); + +public: + + void proxysettings(); + /** + * Creates the view but does not display it. + */ + FBDialog(FBSession* aSession); + FBDialog(); + + /** + * Displays the view with an animation. + * + * The view will be added to the top of the current key window. + */ + void show(); + + /** Displays the first page of the dialog. + * + * Do not ever call this directly. It is intended to be overriden by subclasses. + */ + virtual void load (); + + /** + * Displays a URL in the dialog. + */ + void loadURL(const QString& aUrl, QNetworkAccessManager::Operation aMethod, const QHash& aGetParams, + const QHash& aPostParams); + + + void dismiss(bool aAnimated); + + /** + * Hides the view and notifies delegates of success or cancellation. + */ + void dismissWithSuccess (bool aSuccess, bool aAnimated); + + /** + * Hides the view and notifies delegates of an error. + */ + void dismissWithError (const FBError& aError, bool aAnimated); + + /** + * Subclasses may override to perform actions just prior to showing the dialog. + */ + virtual void dialogWillAppear(); + + /** + * Subclasses may override to perform actions just after the dialog is hidden. + */ + virtual void dialogWillDisappear(); + + /** + * Subclasses should override to process data returned from the server in a 'fbconnect' url. + * + * Implementations must call dismissWithSuccess:YES at some point to hide the dialog. + */ + virtual void dialogDidSucceed(const QUrl& aUrl); + + QString title() const; + void setTitle ( const QString& aTitle ); + + virtual void GetSessionKey(const QUrl& aUrl); + virtual void FetchKeyFromUrl(const QUrl& aUrl); +private: + void createControls(); + QString generateURL( const QString& aUrl, const QHash& aParams) const; + QByteArray generatePostBody (const QHash& aParams) const; + + void postDismissCleanup(); + +public: + virtual void GetAccessToken(); + }; +#endif