certmanager/lib

dn.h

00001 /*
00002     dn.h
00003 
00004     This file is part of libkleopatra, the KDE keymanagement library
00005     Copyright (c) 2004 Klarälvdalens Datakonsult AB
00006 
00007     Libkleopatra is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU General Public License as
00009     published by the Free Software Foundation; either version 2 of the
00010     License, or (at your option) any later version.
00011 
00012     Libkleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 */
00032 
00033 #ifndef __KLEO_DN_H__
00034 #define __KLEO_DN_H__
00035 
00036 #include <qstring.h>
00037 #include <qvaluevector.h>
00038 #include <kdepimmacros.h>
00039 
00040 class QStringList;
00041 class QWidget;
00042 
00043 namespace Kleo {
00044   class DNAttributeOrderConfigWidget;
00045 }
00046 
00047 namespace Kleo {
00048 
00052   class KDE_EXPORT DNAttributeMapper {
00053     DNAttributeMapper();
00054     ~DNAttributeMapper();
00055   public:
00056     static const DNAttributeMapper * instance();
00057 
00058     QString name2label( const QString & s ) const;
00059     QStringList names() const;
00060 
00061     const QStringList & attributeOrder() const;
00062 
00063     void setAttributeOrder( const QStringList & order );
00064 
00065     DNAttributeOrderConfigWidget * configWidget( QWidget * parent=0, const char * name=0 ) const;
00066 
00067   private:
00068     class Private;
00069     Private * d;
00070     static DNAttributeMapper * mSelf;
00071   };
00072 
00076   class KDE_EXPORT DN  {
00077   public:
00078     class Attribute;
00079     typedef QValueVector<Attribute> AttributeList;
00080     typedef AttributeList::const_iterator const_iterator;
00081 
00082     DN();
00083     DN( const QString & dn );
00084     DN( const char * utf8DN );
00085     DN( const DN & other );
00086     ~DN();
00087 
00088     const DN & operator=( const DN & other );
00089 
00092     QString prettyDN() const;
00094     QString dn() const;
00095 
00096     QString operator[]( const QString & attr ) const;
00097 
00098     void append( const Attribute & attr );
00099 
00100     const_iterator begin() const;
00101     const_iterator end() const;
00102 
00103   private:
00104     void detach();
00105   private:
00106     class Private;
00107     Private * d;
00108   };
00109 
00110   class KDE_EXPORT DN::Attribute {
00111   public:
00112     typedef DN::AttributeList List;
00113 
00114     Attribute( const QString & name=QString::null, const QString & value=QString::null )
00115       : mName( name.upper() ), mValue( value ) {}
00116     Attribute( const Attribute & other )
00117       : mName( other.name() ), mValue( other.value() ) {}
00118 
00119     const Attribute & operator=( const Attribute & other ) {
00120       if ( this != &other ) {
00121     mName = other.name();
00122     mValue = other.value();
00123       }
00124       return *this;
00125     }
00126 
00127     const QString & name() const { return mName; }
00128     const QString & value() const { return mValue; }
00129 
00130     void setValue( const QString & value ) { mValue = value; }
00131     
00132   private:
00133     QString mName;
00134     QString mValue;
00135   };
00136 
00137 }
00138 
00139 #endif // __KLEO_DN_H__
KDE Home | KDE Accessibility Home | Description of Access Keys