• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.3 API Reference
  • KDE Home
  • Contact Us
 

kabc

secrecy.cpp
00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2002 Tobias Koenig <tokoe@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 #include "secrecy.h"
00022 
00023 #include <klocale.h>
00024 
00025 #include <QtCore/QDataStream>
00026 #include <QtCore/QSharedData>
00027 
00028 using namespace KABC;
00029 
00030 class Secrecy::PrivateData : public QSharedData
00031 {
00032   public:
00033     PrivateData()
00034       : mType( Secrecy::Invalid )
00035     {
00036     }
00037 
00038     PrivateData( const PrivateData &other )
00039       : QSharedData( other )
00040     {
00041       mType = other.mType;
00042     }
00043 
00044     Type mType;
00045 };
00046 
00047 Secrecy::Secrecy( Type type )
00048   : d( new PrivateData )
00049 {
00050   d->mType = type;
00051 }
00052 
00053 Secrecy::Secrecy( const Secrecy &other )
00054   : d( other.d )
00055 {
00056 }
00057 
00058 Secrecy::~Secrecy()
00059 {
00060 }
00061 
00062 Secrecy &Secrecy::operator=( const Secrecy &other )
00063 {
00064   if ( this != &other ) {
00065     d = other.d;
00066   }
00067 
00068   return *this;
00069 }
00070 
00071 bool Secrecy::operator==( const Secrecy &other ) const
00072 {
00073   return d->mType == other.d->mType;
00074 }
00075 
00076 bool Secrecy::operator!=( const Secrecy &other ) const
00077 {
00078   return !( *this == other );
00079 }
00080 
00081 bool Secrecy::isValid() const
00082 {
00083   return d->mType != Invalid;
00084 }
00085 
00086 void Secrecy::setType( Type type )
00087 {
00088   d->mType = type;
00089 }
00090 
00091 Secrecy::Type Secrecy::type() const
00092 {
00093   return d->mType;
00094 }
00095 
00096 Secrecy::TypeList Secrecy::typeList()
00097 {
00098   static TypeList list;
00099 
00100   if ( list.isEmpty() ) {
00101     list << Public << Private << Confidential;
00102   }
00103 
00104   return list;
00105 }
00106 
00107 QString Secrecy::typeLabel( Type type )
00108 {
00109   switch ( type ) {
00110     case Public:
00111       return i18nc( "access is for everyone", "Public" );
00112       break;
00113     case Private:
00114       return i18nc( "access is by owner only", "Private" );
00115       break;
00116     case Confidential:
00117       return i18nc( "access is by owner and a controlled group", "Confidential" );
00118       break;
00119     default:
00120       return i18nc( "unknown secrecy type", "Unknown type" );
00121       break;
00122   }
00123 }
00124 
00125 QString Secrecy::toString() const
00126 {
00127   QString str;
00128 
00129   str += QString::fromLatin1( "Secrecy {\n" );
00130   str += QString::fromLatin1( "  Type: %1\n" ).arg( typeLabel( d->mType ) );
00131   str += QString::fromLatin1( "}\n" );
00132 
00133   return str;
00134 }
00135 
00136 QDataStream &KABC::operator<<( QDataStream &s, const Secrecy &secrecy )
00137 {
00138     return s << (uint)secrecy.d->mType;
00139 }
00140 
00141 QDataStream &KABC::operator>>( QDataStream &s, Secrecy &secrecy )
00142 {
00143     uint type;
00144     s >> type;
00145 
00146     switch ( type ) {
00147       case 0:
00148         secrecy.d->mType = Secrecy::Public;
00149         break;
00150       case 1:
00151         secrecy.d->mType = Secrecy::Private;
00152         break;
00153       case 2:
00154         secrecy.d->mType = Secrecy::Confidential;
00155         break;
00156       default:
00157         secrecy.d->mType = Secrecy::Invalid;
00158         break;
00159     }
00160 
00161     return s;
00162 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue May 8 2012 00:05:43 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal