# kabc Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# agent.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., 59 Temple Place - Suite 330,
    00018     Boston, MA 02111-1307, USA.
    00019 */
    00020
    00021 #include "addressee.h"
    00022
    00023 #include "agent.h"
    00024
    00025 using namespace KABC;
    00026
    00027 Agent::Agent()
    00028   : mAddressee( 0 ), mIntern( true )
    00029 {
    00030 }
    00031
    00032 Agent::Agent( const QString &url )
    00033   : mAddressee( 0 ),mUrl( url ), mIntern( false )
    00034 {
    00035 }
    00036
    00037 Agent::Agent( Addressee *addressee )
    00038   : mAddressee( addressee ), mIntern( true )
    00039 {
    00040 }
    00041
    00042 Agent::~Agent()
    00043 {
    00044 }
    00045
    00046 bool Agent::operator==( const Agent &a ) const
    00047 {
    00048   if ( mIntern != a.mIntern )
    00049     return false;
    00050
    00051   if ( !mIntern ) {
    00052     if ( mUrl != a.mUrl )
    00053       return false;
    00054   } else {
    00055     if ( mAddressee && !a.mAddressee ) return false;
    00056     if ( !mAddressee && a.mAddressee ) return false;
    00057     if ( !mAddressee && !a.mAddressee ) return false;
    00058     if ( (*mAddressee) != (*a.mAddressee) ) return false;
    00059   }
    00060
    00061   return true;
    00062 }
    00063
    00064 bool Agent::operator!=( const Agent &a ) const
    00065 {
    00066   return !( a == *this );
    00067 }
    00068
    00069 void Agent::setUrl( const QString &url )
    00070 {
    00071   mUrl = url;
    00072   mIntern = false;
    00073 }
    00074
    00075 void Agent::setAddressee( Addressee *addressee )
    00076 {
    00077   mAddressee = addressee;
    00078   mIntern = true;
    00079 }
    00080
    00081 bool Agent::isIntern() const
    00082 {
    00083   return mIntern;
    00084 }
    00085
    00086 QString Agent::url() const
    00087 {
    00088   return mUrl;
    00089 }
    00090
    00091 Addressee *Agent::addressee() const
    00092 {
    00093   return mAddressee;
    00094 }
    00095
    00096 QString Agent::asString() const
    00097 {
    00098   if ( mIntern )
    00099     return "intern agent";
    00100   else
    00101     return mUrl;
    00102 }
    00103
    00104 QDataStream &KABC::operator<<( QDataStream &s, const Agent &agent )
    00105 {
    00106   Q_UINT32 hasAddressee = ( agent.mAddressee != 0 );
    00107
    00108   s << agent.mIntern << agent.mUrl << hasAddressee;
    00109   if ( hasAddressee )
    00110     s << (*agent.mAddressee);
    00111
    00112   return s;
    00113 }
    00114
    00115 QDataStream &KABC::operator>>( QDataStream &s, Agent &agent )
    00116 {
    00117   Q_UINT32 hasAddressee;
    00118
    00119   s >> agent.mIntern >> agent.mUrl >> hasAddressee;
    00120
    00121   if ( hasAddressee ) {
    00122     agent.mAddressee = new Addressee;
    00123     s >> (*agent.mAddressee);
    00124   }
    00125
    00126   return s;
    00127 }

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:29:18 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001