authinfo.h
00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __TDEIO_AUTHINFO_H 00022 #define __TDEIO_AUTHINFO_H 00023 00024 #include <tqmap.h> 00025 #include <tqvaluelist.h> 00026 #include <kurl.h> 00027 00028 00029 namespace TDEIO { 00030 00051 class TDEIO_EXPORT AuthInfo 00052 { 00053 TDEIO_EXPORT friend TQDataStream& operator<< (TQDataStream& s, const AuthInfo& a); 00054 TDEIO_EXPORT friend TQDataStream& operator>> (TQDataStream& s, AuthInfo& a); 00055 00056 public: 00060 AuthInfo(); 00061 00065 AuthInfo( const AuthInfo& info ); 00066 00070 AuthInfo& operator=( const AuthInfo& info ); 00071 00076 bool isModified() const { return modified; } 00077 00082 void setModified( bool flag ) { modified = flag; } 00083 00094 KURL url; 00095 00099 TQString username; 00100 00104 TQString password; 00105 00115 TQString prompt; 00116 00126 TQString caption; 00127 00150 TQString comment; 00151 00159 TQString commentLabel; 00160 00177 TQString realmValue; 00178 00187 TQString digestInfo; 00188 00200 bool verifyPath; 00201 00207 bool readOnly; 00208 00220 bool keepPassword; 00221 00222 protected: 00223 bool modified; 00224 private: 00225 class AuthInfoPrivate* d; 00226 }; 00227 00228 TDEIO_EXPORT TQDataStream& operator<< (TQDataStream& s, const AuthInfo& a); 00229 TDEIO_EXPORT TQDataStream& operator>> (TQDataStream& s, AuthInfo& a); 00230 00240 class TDEIO_EXPORT NetRC 00241 { 00242 public: 00243 00254 enum LookUpMode 00255 { 00256 exactOnly = 0x0002, 00257 defaultOnly = 0x0004, 00258 presetOnly = 0x0008 00259 }; 00260 00265 struct AutoLogin 00266 { 00267 TQString type; 00268 TQString machine; 00269 TQString login; 00270 TQString password; 00271 TQMap<TQString, TQStringList> macdef; 00272 }; 00273 00278 static NetRC* self(); 00279 00290 bool lookup( const KURL& url, AutoLogin& login, 00291 bool userealnetrc = false, 00292 TQString type = TQString::null, 00293 int mode = (exactOnly|defaultOnly) ); 00297 void reload() { isDirty = true; } 00298 00299 protected: 00300 TQString extract( const char*, const char*, int& ); 00301 int openf( const TQString& ); 00302 bool parse( int ); 00303 00304 private: 00305 NetRC(); 00306 ~NetRC(); 00307 00308 private: 00309 bool isDirty; 00310 00311 typedef TQValueList<AutoLogin> LoginList; 00312 typedef TQMap<TQString, LoginList> LoginMap; 00313 LoginMap loginMap; 00314 00315 static NetRC* instance; 00316 class NetRCPrivate; 00317 NetRCPrivate* d; 00318 }; 00319 } 00320 #endif