ssllabel.cpp
00001 /* -*- mode: C++; c-file-style: "gnu" -*- 00002 * 00003 * This file is part of KMail, the KDE mail client. 00004 * 00005 * Copyright (c) 2003 Zack Rusin <zack@kde.org> 00006 * 00007 * KMail is free software; you can redistribute it and/or modify it 00008 * under the terms of the GNU General Public License, version 2, as 00009 * published by the Free Software Foundation. 00010 * 00011 * KMail is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 * In addition, as a special exception, the copyright holders give 00021 * permission to link the code of this program with any edition of 00022 * the TQt library by Trolltech AS, Norway (or with modified versions 00023 * of TQt that use the same license as TQt), and distribute linked 00024 * combinations including the two. You must obey the GNU General 00025 * Public License in all respects for all of the code used other than 00026 * TQt. If you modify this file, you may extend this exception to 00027 * your version of the file, but you are not obligated to do so. If 00028 * you do not wish to do so, delete this exception statement from 00029 * your version. 00030 */ 00031 #ifdef HAVE_CONFIG_H 00032 #include <config.h> 00033 #endif 00034 00035 #include "ssllabel.h" 00036 00037 #include <kiconloader.h> 00038 #include <tdelocale.h> 00039 00040 #include <tqtooltip.h> 00041 00042 namespace KPIM { 00043 00044 SSLLabel::SSLLabel( TQWidget* parent ) 00045 : TQLabel( parent ) 00046 { 00047 setState( Done ); 00048 } 00049 00050 void SSLLabel::setEncrypted( bool enc ) 00051 { 00052 if ( enc ) { 00053 m_lastEncryptionState = Encrypted; 00054 } else { 00055 m_lastEncryptionState = Unencrypted; 00056 } 00057 } 00058 00059 SSLLabel::State SSLLabel::lastState() const 00060 { 00061 return m_lastEncryptionState; 00062 } 00063 00064 void SSLLabel::setState( State state ) 00065 { 00066 switch( state ) { 00067 case Encrypted: 00068 TQToolTip::remove( this ); 00069 TQToolTip::add( this, i18n("Connection is encrypted") ); 00070 setPixmap( SmallIcon( "encrypted", TDEGlobal::instance() ) ); 00071 show(); 00072 break; 00073 case Unencrypted: 00074 TQToolTip::remove( this ); 00075 TQToolTip::add( this, i18n("Connection is unencrypted") ); 00076 setPixmap( SmallIcon( "decrypted" ) ); 00077 show(); 00078 break; 00079 case Done: 00080 TQToolTip::remove( this ); 00081 hide(); 00082 break; 00083 case Clean: 00084 default: 00085 TQToolTip::remove( this ); 00086 hide(); 00087 //we return because we do not save the state as the only 00088 //action we want to perform is to hide ourself 00089 return; 00090 } 00091 m_lastEncryptionState = state; 00092 } 00093 00094 00095 } //end namespace KPIM 00096 00097 //#include "ssllabel.moc"