agent.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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.4.