libquentier  0.8.0
The library for rich desktop clients of Evernote service
IKeychainService.h
1 /*
2  * Copyright 2018-2025 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <quentier/exception/IQuentierException.h>
22 #include <quentier/types/ErrorString.h>
23 
24 #include <quentier/utility/Fwd.h>
25 #include <quentier/utility/Linkage.h>
26 
27 #include <QFuture>
28 
29 class QDebug;
30 
31 namespace quentier::utility {
32 
37 class QUENTIER_EXPORT IKeychainService
38 {
39 public:
40  virtual ~IKeychainService() noexcept;
41 
45  enum class ErrorCode
46  {
50  NoError,
54  EntryNotFound,
58  CouldNotDeleteEntry,
62  AccessDeniedByUser,
66  AccessDenied,
70  NoBackendAvailable,
74  NotImplemented,
78  OtherError
79  };
80 
81  friend QUENTIER_EXPORT QTextStream & operator<<(
82  QTextStream & strm, ErrorCode errorCode);
83 
84  friend QUENTIER_EXPORT QDebug & operator<<(
85  QDebug & dbg, ErrorCode errorCode);
86 
91  class QUENTIER_EXPORT Exception : public IQuentierException
92  {
93  public:
94  explicit Exception(ErrorCode errorCode) noexcept;
95 
96  explicit Exception(
97  ErrorCode errorCode, ErrorString errorDescription) noexcept;
98 
99  [[nodiscard]] ErrorCode errorCode() const noexcept;
100  [[nodiscard]] QString exceptionDisplayName() const override;
101 
102  void raise() const override;
103  [[nodiscard]] Exception * clone() const override;
104 
105  private:
106  const ErrorCode m_errorCode;
107  };
108 
109 public:
123  [[nodiscard]] virtual QFuture<void> writePassword(
124  QString service, QString key, QString password) = 0;
125 
139  [[nodiscard]] virtual QFuture<QString> readPassword(
140  QString service, QString key) const = 0;
141 
154  [[nodiscard]] virtual QFuture<void> deletePassword(
155  QString service, QString key) = 0;
156 };
157 
158 } // namespace quentier::utility
The IQuentierException class represents the interface for exceptions specific to libquentier and appl...
Definition: IQuentierException.h:36
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:42
ErrorCode
Definition: IKeychainService.h:45
Definition: ApplicationSettings.h:27
The IKeychainService interface provides the ability to interact with the storage of sensitive data - ...
Definition: IKeychainService.h:37
The IKeychainService::Exception class is the base class for exceptions returned inside QFutures from ...
Definition: IKeychainService.h:91