auth.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2009 Andrew Stromme <astromme@chatonka.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Library General Public License as
  6. * published by the Free Software Foundation; either version 2, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this program; if not, write to the
  16. * Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef RTM_AUTH_H
  20. #define RTM_AUTH_H
  21. #include <QString>
  22. #include <QObject>
  23. #include <QHash>
  24. #include <QBuffer>
  25. #include <QNetworkReply>
  26. #include <KParts/BrowserExtension>
  27. #include "request.h"
  28. class QWebView;
  29. namespace RTM {
  30. class RTM_EXPORT Auth : public Request
  31. {
  32. Q_OBJECT
  33. public:
  34. Auth(RTM::Permissions permissions, const QString &apiKey, const QString &sharedSecret);
  35. void showLoginWebpage();
  36. QString getAuthUrl();
  37. void continueAuthForToken();
  38. ~Auth();
  39. protected:
  40. QString getTextPermissions(RTM::Permissions permissions);
  41. QString requestUrl();
  42. QString frob;
  43. QString apiKey;
  44. Request *frobRequest;
  45. Request *tokenRequest;
  46. signals:
  47. void authUrlReady(QString authUrl);
  48. void tokenReceived(QString token);
  49. protected slots:
  50. void pageClosed();
  51. void showLoginWindowInternal(RTM::Request* rawReply);
  52. public slots:
  53. void tokenResponse(RTM::Request*);
  54. };
  55. } // Namespace RTM
  56. #endif