KIO

authinfo.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2000-2001 Dawit Alemayehu <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef KIO_AUTHINFO_H
22 #define KIO_AUTHINFO_H
23 
24 #include "kiocore_export.h"
25 
26 #include <QMap>
27 #include <QList>
28 #include <QStringList>
29 #include <QUrl>
30 #include <QVariant> // Q_DECLARE_METATYPE
31 
32 class QDBusArgument;
33 
34 namespace KIO
35 {
36 
37 class AuthInfoPrivate;
38 
61 class KIOCORE_EXPORT AuthInfo
62 {
63  KIOCORE_EXPORT friend QDataStream &operator<< (QDataStream &s, const AuthInfo &a);
64  KIOCORE_EXPORT friend QDataStream &operator>> (QDataStream &s, AuthInfo &a);
65 
66  KIOCORE_EXPORT friend QDBusArgument &operator<<(QDBusArgument &argument, const AuthInfo &a);
67  KIOCORE_EXPORT friend const QDBusArgument &operator>>(const QDBusArgument &argument, AuthInfo &a);
68 
69 public:
70 
74  AuthInfo();
75 
79  AuthInfo(const AuthInfo &info);
80 
85  ~AuthInfo();
86 
90  AuthInfo &operator=(const AuthInfo &info);
91 
96  bool isModified() const;
97 
102  void setModified(bool flag);
103 
115 
120 
125 
136 
147 
171 
180 
194 
204 
217 
223  bool readOnly;
224 
237 
242  enum FieldFlags {
243  ExtraFieldNoFlags = 0,
244  ExtraFieldReadOnly = 1 << 1,
245  ExtraFieldMandatory = 1 << 2
246  };
247 
257  void setExtraField(const QString &fieldName, const QVariant &value);
258 
263  void setExtraFieldFlags(const QString &fieldName, const FieldFlags flags);
264 
270  QVariant getExtraField(const QString &fieldName) const;
271 
276  AuthInfo::FieldFlags getExtraFieldFlags(const QString &fieldName) const;
277 
284  static void registerMetaTypes();
285 
286 protected:
287  bool modified;
288 
289 private:
290  friend class ::KIO::AuthInfoPrivate;
291  AuthInfoPrivate *const d;
292 };
293 
294 KIOCORE_EXPORT QDataStream &operator<< (QDataStream &s, const AuthInfo &a);
295 KIOCORE_EXPORT QDataStream &operator>> (QDataStream &s, AuthInfo &a);
296 
297 KIOCORE_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const AuthInfo &a);
298 KIOCORE_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, AuthInfo &a);
299 
309 class KIOCORE_EXPORT NetRC
310 {
311 public:
312 
325  exactOnly = 0x0002,
326  defaultOnly = 0x0004,
327  presetOnly = 0x0008
328  };
332  Q_DECLARE_FLAGS(LookUpMode, LookUpModeFlag)
333 
334 
338  struct AutoLogin {
339  QString type;
340  QString machine;
341  QString login;
342  QString password;
344  };
345 
350  static NetRC *self();
351 
362  bool lookup(const QUrl &url, AutoLogin &login,
363  bool userealnetrc = false,
364  const QString &type = QString(),
365  LookUpMode mode = LookUpMode(exactOnly) | defaultOnly);
369  void reload();
370 
371 protected:
372  bool parse(const QString &fileName);
373 
374 private:
375  NetRC();
376  ~NetRC();
377 
378  NetRC(const NetRC &) = delete;
379  NetRC& operator=(const NetRC &) = delete;
380 
381 private:
382  static NetRC *instance;
383 
384  class NetRCPrivate;
385  NetRCPrivate *const d;
386 };
387 }
388 Q_DECLARE_OPERATORS_FOR_FLAGS(KIO::NetRC::LookUpMode)
389 Q_DECLARE_METATYPE(KIO::AuthInfo)
390 
391 #endif
QString comment
Additional comment to be displayed when prompting the user for authentication information.
Definition: authinfo.h:170
FieldFlags
Flags for extra fields.
Definition: authinfo.h:242
bool keepPassword
Flag to indicate the persistence of the given password.
Definition: authinfo.h:236
A namespace for KIO globals.
Definition: authinfo.h:34
QString digestInfo
Field to store any extra authentication information for protocols that need it.
Definition: authinfo.h:203
This class is intended to make it easier to prompt for, cache and retrieve authorization information...
Definition: authinfo.h:61
bool readOnly
Flag which if set forces the username field to be read-only.
Definition: authinfo.h:223
QUrl url
The URL for which authentication is to be stored.
Definition: authinfo.h:114
LookUpModeFlag
Specifies the mode to be used when searching for a matching automatic login info for a given site : ...
Definition: authinfo.h:324
QString realmValue
A unique identifier that allows caching of multiple passwords for different resources in the same ser...
Definition: authinfo.h:193
bool verifyPath
Flag that, if set, indicates whether a path match should be performed when requesting for cached auth...
Definition: authinfo.h:216
A Singleton class that provides access to passwords stored in .netrc files for automatic login purpos...
Definition: authinfo.h:309
QString password
This is required for caching.
Definition: authinfo.h:124
QString username
This is required for caching.
Definition: authinfo.h:119
QString caption
The text to displayed in the title bar of the password prompting dialog.
Definition: authinfo.h:146
QString commentLabel
Descriptive label to be displayed in front of the comment when prompting the user for password...
Definition: authinfo.h:179
QString prompt
Information to be displayed when prompting the user for authentication information.
Definition: authinfo.h:135
Contains auto login information.
Definition: authinfo.h:338
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 10 2020 22:59:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.