/usr/include/libkgapi2/ui/authwidget.h is in libkgapi-dev 2.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | /*
Copyright 2012 Dan Vratil <dan@progdan.cz>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBKGAPI2_UI_AUTHWIDGET_H
#define LIBKGAPI2_UI_AUTHWIDGET_H
#include <QtGui/QWidget>
#include <libkgapi2/types.h>
#include <libkgapi2/account.h>
#include <libkgapi2/libkgapi2_export.h>
#include <libkgapi2/account.h>
namespace KGAPI {
typedef KGAPI2::Account Account;
}
namespace KGAPI2 {
/**
* A widget for authentication that can be easilly embedded
* to any application.
*
* @since 0.3.2
*/
class LIBKGAPI2_EXPORT AuthWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY(bool showProgressBar WRITE setShowProgressBar READ getShowProgressBar)
public:
/**
* Describes progress of the authentication so that external observers can react
* (for example you can hide the widget after user login)
*/
enum Progress {
None, /**< Initial state, before authenticate() is called */
UserLogin, /**< The webview where user has to login to Google is displayed */
TokensRetrieval, /**< Tokens are being retrieved (webview no longer visible) */
Finished, /**< Tokens were retrieved and authenticated() signal has been emitted */
Error /**< An error occurred and error() signal has been emitted */
};
explicit AuthWidget(QWidget* parent = 0);
virtual ~AuthWidget();
/**
* Runs the authentication.
*
* Displays the webview and starts the actual process of authentication.
*
* The method will throw an KGAPI::InvalidAccount exception if
* no account was set via setAccount() before invoking this method.
*/
void authenticate();
/**
* Sets the username that will be used when authenticate is called
*
* The username will be automatically filled in the Google login
* form in the authentication widget.
*
* Be aware that the username will be set every time \sa authenticate is
* called so if you want to change or remove it call \sa setUsername again
* with empty string or \sa clearCredentials.
*
* @param username username to use
*/
void setUsername(const QString &username);
/**
* Sets the password that will be used when authenticate is called
*
* The password will be automatically filled in the Google login
* form in the authentication widget.
*
* Be aware that the password will be set every time \sa authenticate is
* called so if you want to change or remove it call \sa setPassword again
* with empty string or \sa clearCredentials.
*
* @param password password to use
*/
void setPassword(const QString &password);
/**
* Sets to empty username and password
*
* Sets to empty the username and the password which were set by
* calling \sa setUsername and \sa setPassword.
*/
void clearCredentials();
/**
* Sets an account for which to obtain authentication.
*/
void setAccount(const KGAPI2::AccountPtr &account);
/**
* Sets whether to show progressbar above the webview when loading
* and displaying the Google login form.
*
* Default is true
*
* @param showProgressBar
*/
void setShowProgressBar(bool showProgressBar);
/**
* Returns whether a progressbar above webview will be shown.
*
* @see setShowProgressBar
*/
bool getShowProgressBar() const;
/**
* Returns current progress state.
*
* @see progress()
*/
AuthWidget::Progress getProgress() const;
Q_SIGNALS:
/**
* Account was successfully authenticated.
*
* This signal is emitted when the authentication was successful
* and tokens were stored within the \p account
*/
void authenticated(const KGAPI2::AccountPtr &account);
/**
* Emitted when an error occurs
*
* Signalizes any authentication error
*/
void error(const KGAPI2::Error errCode, const QString &msg);
/**
* Emitted whenever a state of the authentication process changes.
*
* @param progress The new state of authentication
*/
void progress(KGAPI2::AuthWidget::Progress progress);
private:
class Private;
Private * const d;
friend class Private;
friend class AuthJob;
};
} // namespace KGAPI2
#endif // LIBKGAPI2_UI_AUTHWIDGET_H
|