Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
OnlineAccountClient.h
1 /*
2  * Copyright (C) 2014 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
17  */
18 
19 #ifndef UNITY_SCOPES_ONLINEACCOUNTCLIENT_H
20 #define UNITY_SCOPES_ONLINEACCOUNTCLIENT_H
21 
22 #include <unity/scopes/CannedQuery.h>
23 #include <unity/scopes/PreviewWidget.h>
24 #include <unity/scopes/Result.h>
25 #include <unity/util/NonCopyable.h>
26 
27 #include <memory>
28 
29 namespace unity
30 {
31 
32 namespace scopes
33 {
34 
35 namespace internal
36 {
37 class OnlineAccountClientImpl;
38 }
39 
40 namespace testing
41 {
42 class OnlineAccountClientTest;
43 }
44 
52 {
53 public:
55  NONCOPYABLE(OnlineAccountClient);
57 
62  {
63  uint account_id;
66  std::string client_id;
67  std::string client_secret;
68  std::string access_token;
69  std::string token_secret;
70  std::string error;
71  };
72 
80  {
83  };
84 
93  OnlineAccountClient(std::string const& service_name,
94  std::string const& service_type,
95  std::string const& provider_name,
96  MainLoopSelect main_loop_select = CreateInternalMainLoop);
97 
101 
106  typedef std::function<void(ServiceStatus const&)> ServiceUpdateCallback;
107 
112  void set_service_update_callback(ServiceUpdateCallback callback);
113 
121 
127  std::vector<ServiceStatus> get_service_statuses();
128 
133  {
139  };
140 
148  void register_account_login_item(Result& result,
149  CannedQuery const& query,
150  PostLoginAction login_passed_action,
151  PostLoginAction login_failed_action);
152 
160  PostLoginAction login_passed_action,
161  PostLoginAction login_failed_action);
162 
163 private:
164  std::unique_ptr<internal::OnlineAccountClientImpl> p;
165 
166  friend class testing::OnlineAccountClientTest;
167 };
168 
169 } // namespace scopes
170 
171 } // namespace unity
172 
173 #endif
A simple interface for integrating online accounts access and monitoring into scopes.
Definition: OnlineAccountClient.h:51
Simply return to the scope with no further action.
Definition: OnlineAccountClient.h:135
std::string client_secret
"ClientSecret" / "ConsumerSecret" OAuth (1 / 2) parameter.
Definition: OnlineAccountClient.h:67
std::string access_token
"AccessToken" OAuth parameter.
Definition: OnlineAccountClient.h:68
uint account_id
A unique ID of the online account parenting this service.
Definition: OnlineAccountClient.h:63
void set_service_update_callback(ServiceUpdateCallback callback)
Set the callback function to be invoked when a service status changes.
Definition: OnlineAccountClient.cpp:40
std::string error
Error message (empty if no error occurred).
Definition: OnlineAccountClient.h:70
The attributes of a result returned by a Scope.
Definition: Result.h:51
Definition: OnlineAccountClient.h:40
PostLoginAction
Indicates what action to take when the login process completes.
Definition: OnlineAccountClient.h:132
std::string token_secret
"TokenSecret" OAuth parameter.
Definition: OnlineAccountClient.h:69
Top-level namespace for all things Unity-related.
Definition: Version.h:50
An external main loop already exists and is running.
Definition: OnlineAccountClient.h:81
Definition: ActionMetadata.h:32
MainLoopSelect
Indicates whether an external main loop already exists, or one should be created internally.
Definition: OnlineAccountClient.h:79
OnlineAccountClient(std::string const &service_name, std::string const &service_type, std::string const &provider_name, MainLoopSelect main_loop_select=CreateInternalMainLoop)
Create OnlineAccountClient for the specified account service.
Definition: OnlineAccountClient.cpp:28
An external main loop does not exist.
Definition: OnlineAccountClient.h:82
Parameters of a search query.
Definition: CannedQuery.h:46
void register_account_login_item(Result &result, CannedQuery const &query, PostLoginAction login_passed_action, PostLoginAction login_failed_action)
Register a result item that requires the user to be logged in.
Definition: OnlineAccountClient.cpp:55
bool service_enabled
True if this service is enabled.
Definition: OnlineAccountClient.h:64
A widget for a preview.
Definition: PreviewWidget.h:48
std::function< void(ServiceStatus const &)> ServiceUpdateCallback
Function signature for the service update callback.
Definition: OnlineAccountClient.h:106
Invalidate the scope results.
Definition: OnlineAccountClient.h:136
An action unknown to the run-time was used.
Definition: OnlineAccountClient.h:134
Continue with regular result / widget activation.
Definition: OnlineAccountClient.h:137
bool service_authenticated
True if this service is authenticated.
Definition: OnlineAccountClient.h:65
void refresh_service_statuses()
Refresh all service statuses.
Definition: OnlineAccountClient.cpp:45
A container for details about a service's status and authorization parameters.
Definition: OnlineAccountClient.h:61
Dummy end marker.
Definition: OnlineAccountClient.h:138
std::string client_id
"ConsumerKey" / "ClientId" OAuth (1 / 2) parameter.
Definition: OnlineAccountClient.h:66
std::vector< ServiceStatus > get_service_statuses()
Get statuses for all services matching the name, type and provider specified on construction.
Definition: OnlineAccountClient.cpp:50