LeechCraft  0.6.70-3565-g2d86529
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vkauthmanager.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #pragma once
31 
32 #include <functional>
33 #include <QObject>
34 #include <QDateTime>
35 #include <QUrl>
37 #include <util/sll/util.h>
38 #include "svcauthconfig.h"
39 
40 class QTimer;
41 
42 namespace LeechCraft
43 {
44 namespace Util
45 {
46 class QueueManager;
47 enum class QueuePriority;
48 
49 class CustomCookieJar;
50 
51 namespace SvcAuth
52 {
53  class UTIL_SVCAUTH_API VkAuthManager : public QObject
54  {
55  Q_OBJECT
56 
57  ICoreProxy_ptr Proxy_;
58 
59  const QString AccountHR_;
60 
61  QNetworkAccessManager * const AuthNAM_;
62  Util::CustomCookieJar * const Cookies_;
63 
64  QueueManager * const Queue_;
65 
66  QString Token_;
67  QDateTime ReceivedAt_;
68  qint32 ValidFor_;
69 
70  bool IsRequesting_;
71 
72  const QString ID_;
73  QUrl URL_;
74 
75  bool IsRequestScheduled_;
76  QTimer * const ScheduleTimer_;
77 
78  bool SilentMode_ = false;
79 
80  bool HasTracked_ = false;
81  public:
84 
87 
89  private:
90  QList<RequestQueue_ptr> ManagedQueues_;
91  QList<PrioRequestQueue_ptr> PrioManagedQueues_;
92  public:
93  VkAuthManager (const QString& accountName, const QString& clientId,
94  const QStringList& scope, const QByteArray& cookies,
95  ICoreProxy_ptr, QueueManager* = nullptr, QObject* = nullptr);
96 
97  bool IsAuthenticated () const;
98  bool HadAuthentication () const;
99 
100  void UpdateScope (const QStringList&);
101 
102  void GetAuthKey ();
103 
104  ScheduleGuard_t Q_REQUIRED_RESULT ManageQueue (RequestQueue_ptr);
105  ScheduleGuard_t Q_REQUIRED_RESULT ManageQueue (PrioRequestQueue_ptr);
106 
107  void SetSilentMode (bool);
108  private:
109  void InvokeQueues (const QString&);
110 
111  void RequestURL (const QUrl&);
112  void RequestAuthKey ();
113  bool CheckReply (QUrl);
114  bool CheckError (const QUrl&);
115 
116  void ScheduleTrack (const QString&);
117  public slots:
118  void clearAuthData ();
119  void reauth ();
120  private slots:
121  void execScheduledRequest ();
122  void handleGotForm ();
123  void handleViewUrlChanged (const QUrl&);
124  signals:
125  void gotAuthKey (const QString&);
126  void cookiesChanged (const QByteArray&);
127  void authCanceled ();
128  void justAuthenticated ();
129  };
130 }
131 }
132 }
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition: icoreproxy.h:225
detail::ScopeGuard< detail::DefaultScopeGuardDeleter > DefaultScopeGuard
Definition: util.h:101
#define UTIL_SVCAUTH_API
Definition: svcauthconfig.h:37
QueuePriority
The priority of the action in the queue.
Definition: queuemanager.h:48
A simple scheduling manager for a queue of functors.
Definition: queuemanager.h:64