Vidalia
0.2.17
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file RouterInfoDialog.cpp 00013 ** \brief Displays detailed information about a particular router 00014 */ 00015 00016 #include "RouterInfoDialog.h" 00017 00018 #include "stringutil.h" 00019 00020 00021 RouterInfoDialog::RouterInfoDialog(QWidget *parent) 00022 : QDialog(parent) 00023 { 00024 ui.setupUi(this); 00025 } 00026 00027 quint64 00028 RouterInfoDialog::adjustUptime(quint64 uptime, const QDateTime &published) 00029 { 00030 QDateTime now = QDateTime::currentDateTime().toUTC(); 00031 00032 if (now < published) 00033 return uptime; 00034 00035 return (uptime + (now.toTime_t() - published.toTime_t())); 00036 } 00037 00038 void 00039 RouterInfoDialog::setRouterInfo(const QStringList &desc, 00040 const RouterStatus &status) 00041 { 00042 RouterDescriptor rd(desc); 00043 00044 ui.lblName->setText(rd.name()); 00045 ui.lblIPAddress->setText(rd.ip().toString()); 00046 ui.lblPlatform->setText(rd.platform()); 00047 ui.lblBandwidth->setText(string_format_bandwidth(rd.observedBandwidth())); 00048 ui.lblLastUpdated->setText(string_format_datetime(rd.published()) + " GMT"); 00049 ui.lblUptime->setText(string_format_uptime(adjustUptime(rd.uptime(), 00050 rd.published()))); 00051 00052 if (rd.hibernating()) { 00053 ui.lblStatus->setText(tr("Hibernating")); 00054 } else if (status.isValid()) { 00055 if (status.flags() & RouterStatus::Running) 00056 ui.lblStatus->setText(tr("Online")); 00057 else 00058 ui.lblStatus->setText(tr("Offline")); 00059 } else { 00060 ui.lblStatus->setText(tr("Unknown")); 00061 } 00062 00063 if (! rd.contact().isEmpty()) { 00064 ui.lblContact->setText(rd.contact()); 00065 } else { 00066 ui.lblContact->setVisible(false); 00067 ui.lblContactLabel->setVisible(false); 00068 } 00069 00070 ui.textDescriptor->setPlainText(desc.join("\n")); 00071 } 00072 00073 void 00074 RouterInfoDialog::setLocation(const QString &location) 00075 { 00076 ui.lblLocation->setText(location); 00077 } 00078