00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2007, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU 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, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file addressmapevent.h 00024 * \version $Id: bandwidthevent.h 1563 2006-12-26 06:06:04Z edmanm $ 00025 * \brief Event dispatched upon receiving a new or updated address mapping 00026 * from Tor. 00027 */ 00028 00029 #ifndef _ADDRESSMAPEVENT_H 00030 #define _ADDRESSMAPEVENT_H 00031 00032 #include <QEvent> 00033 #include <QString> 00034 #include <QDateTime> 00035 00036 00037 class AddressMapEvent : public QEvent 00038 { 00039 public: 00040 /** Constructor */ 00041 AddressMapEvent(QString from, QString to, QDateTime expires) 00042 : QEvent((QEvent::Type)CustomEventType::AddressMapEvent) 00043 { _from = from; _to = to; _expires = expires; } 00044 00045 /** Returns the number of bytes read in the last second */ 00046 QString from() const { return _from; } 00047 /** Returns the number of bytes written in the last second */ 00048 QString to() const { return _to; } 00049 /** Returns the date and time at which this mapping should expire, in local 00050 * time. */ 00051 QDateTime expires() const { return _expires; } 00052 /** Returns true if this address mapping is expired. */ 00053 bool isExpired() const { return (_expires > QDateTime::currentDateTime()); } 00054 00055 private: 00056 QString _from; /**< The source address of this mapping. */ 00057 QString _to; /**< The target address of this mapping. */ 00058 QDateTime _expires; /**< The time at which this mapping expires (if ever). */ 00059 }; 00060 00061 #endif 00062