KIO

authinfo.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2000-2001 Dawit Alemayehu <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KIO_AUTHINFO_H
9 #define KIO_AUTHINFO_H
10 
11 #include "kiocore_export.h"
12 
13 #include <QMap>
14 #include <QList>
15 #include <QStringList>
16 #include <QUrl>
17 #include <QVariant> // Q_DECLARE_METATYPE
18 
19 class QDBusArgument;
20 
21 namespace KIO
22 {
23 
24 class AuthInfoPrivate;
25 
48 class KIOCORE_EXPORT AuthInfo
49 {
50  KIOCORE_EXPORT friend QDataStream &operator<< (QDataStream &s, const AuthInfo &a);
51  KIOCORE_EXPORT friend QDataStream &operator>> (QDataStream &s, AuthInfo &a);
52 
53  KIOCORE_EXPORT friend QDBusArgument &operator<<(QDBusArgument &argument, const AuthInfo &a);
54  KIOCORE_EXPORT friend const QDBusArgument &operator>>(const QDBusArgument &argument, AuthInfo &a);
55 
56 public:
57 
61  AuthInfo();
62 
66  AuthInfo(const AuthInfo &info);
67 
72  ~AuthInfo();
73 
77  AuthInfo &operator=(const AuthInfo &info);
78 
83  bool isModified() const;
84 
89  void setModified(bool flag);
90 
102 
107 
112 
123 
134 
158 
167 
181 
191 
204 
210  bool readOnly;
211 
224 
229  enum FieldFlags {
230  ExtraFieldNoFlags = 0,
231  ExtraFieldReadOnly = 1 << 1,
232  ExtraFieldMandatory = 1 << 2
233  };
234 
244  void setExtraField(const QString &fieldName, const QVariant &value);
245 
250  void setExtraFieldFlags(const QString &fieldName, const FieldFlags flags);
251 
257  QVariant getExtraField(const QString &fieldName) const;
258 
263  AuthInfo::FieldFlags getExtraFieldFlags(const QString &fieldName) const;
264 
271  static void registerMetaTypes();
272 
273 protected:
274  bool modified;
275 
276 private:
277  friend class ::KIO::AuthInfoPrivate;
278  AuthInfoPrivate *const d;
279 };
280 
281 KIOCORE_EXPORT QDataStream &operator<< (QDataStream &s, const AuthInfo &a);
282 KIOCORE_EXPORT QDataStream &operator>> (QDataStream &s, AuthInfo &a);
283 
284 KIOCORE_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const AuthInfo &a);
285 KIOCORE_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, AuthInfo &a);
286 
296 class KIOCORE_EXPORT NetRC
297 {
298 public:
299 
312  exactOnly = 0x0002,
313  defaultOnly = 0x0004,
314  presetOnly = 0x0008
315  };
319  Q_DECLARE_FLAGS(LookUpMode, LookUpModeFlag)
320 
321 
325  struct AutoLogin {
326  QString type;
327  QString machine;
328  QString login;
329  QString password;
331  };
332 
337  static NetRC *self();
338 
349  bool lookup(const QUrl &url, AutoLogin &login,
350  bool userealnetrc = false,
351  const QString &type = QString(),
352  LookUpMode mode = LookUpMode(exactOnly) | defaultOnly);
356  void reload();
357 
358 protected:
359  bool parse(const QString &fileName);
360 
361 private:
362  NetRC();
363  ~NetRC();
364 
365  NetRC(const NetRC &) = delete;
366  NetRC& operator=(const NetRC &) = delete;
367 
368 private:
369  static NetRC *instance;
370 
371  class NetRCPrivate;
372  NetRCPrivate *const d;
373 };
374 
375 Q_DECLARE_OPERATORS_FOR_FLAGS(NetRC::LookUpMode)
376 
377 }
378 
379 Q_DECLARE_METATYPE(KIO::AuthInfo)
380 
381 #endif
QString comment
Additional comment to be displayed when prompting the user for authentication information.
Definition: authinfo.h:157
FieldFlags
Flags for extra fields.
Definition: authinfo.h:229
bool keepPassword
Flag to indicate the persistence of the given password.
Definition: authinfo.h:223
A namespace for KIO globals.
Definition: authinfo.h:21
QString digestInfo
Field to store any extra authentication information for protocols that need it.
Definition: authinfo.h:190
This class is intended to make it easier to prompt for, cache and retrieve authorization information...
Definition: authinfo.h:48
bool readOnly
Flag which if set forces the username field to be read-only.
Definition: authinfo.h:210
QUrl url
The URL for which authentication is to be stored.
Definition: authinfo.h:101
LookUpModeFlag
Specifies the mode to be used when searching for a matching automatic login info for a given site : ...
Definition: authinfo.h:311
QString realmValue
A unique identifier that allows caching of multiple passwords for different resources in the same ser...
Definition: authinfo.h:180
bool verifyPath
Flag that, if set, indicates whether a path match should be performed when requesting for cached auth...
Definition: authinfo.h:203
A Singleton class that provides access to passwords stored in .netrc files for automatic login purpos...
Definition: authinfo.h:296
QString password
This is required for caching.
Definition: authinfo.h:111
QString username
This is required for caching.
Definition: authinfo.h:106
QString caption
The text to displayed in the title bar of the password prompting dialog.
Definition: authinfo.h:133
QString commentLabel
Descriptive label to be displayed in front of the comment when prompting the user for password...
Definition: authinfo.h:166
QString prompt
Information to be displayed when prompting the user for authentication information.
Definition: authinfo.h:122
Contains auto login information.
Definition: authinfo.h:325
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Dec 3 2020 23:01:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.