RouterInfoDialog.cpp

Go to the documentation of this file.
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.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file RouterInfoDialog.cpp
00013 ** \version $Id: RouterInfoDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $
00014 ** \brief Displays detailed information about a particular router
00015 */
00016 
00017 #include "RouterInfoDialog.h"
00018 
00019 #include "stringutil.h"
00020 
00021 
00022 RouterInfoDialog::RouterInfoDialog(QWidget *parent)
00023   : QDialog(parent)
00024 {
00025   ui.setupUi(this);
00026 }
00027 
00028 quint64
00029 RouterInfoDialog::adjustUptime(quint64 uptime, const QDateTime &published)
00030 {
00031   QDateTime now = QDateTime::currentDateTime().toUTC();
00032 
00033   if (now < published)
00034     return uptime;
00035 
00036   return (uptime + (now.toTime_t() - published.toTime_t()));
00037 }
00038 
00039 void
00040 RouterInfoDialog::setRouterInfo(const QStringList &desc,
00041                                 const RouterStatus &status)
00042 {
00043   RouterDescriptor rd(desc);
00044 
00045   ui.lblName->setText(rd.name());
00046   ui.lblIPAddress->setText(rd.ip().toString());
00047   ui.lblPlatform->setText(rd.platform());
00048   ui.lblBandwidth->setText(string_format_bandwidth(rd.observedBandwidth()));
00049   ui.lblLastUpdated->setText(string_format_datetime(rd.published()) + " GMT");
00050   ui.lblUptime->setText(string_format_uptime(adjustUptime(rd.uptime(),
00051                                                           rd.published())));
00052 
00053   if (rd.hibernating()) {
00054     ui.lblStatus->setText(tr("Hibernating"));
00055   } else if (status.isValid()) {
00056     if (status.flags() & RouterStatus::Running)
00057       ui.lblStatus->setText(tr("Online"));
00058     else
00059       ui.lblStatus->setText(tr("Offline"));
00060   } else {
00061     ui.lblStatus->setText(tr("Unknown"));
00062   }
00063 
00064   if (! rd.contact().isEmpty()) {
00065     ui.lblContact->setText(rd.contact());
00066   } else {
00067     ui.lblContact->setVisible(false);
00068     ui.lblContactLabel->setVisible(false);
00069   }
00070 
00071   ui.textDescriptor->setPlainText(desc.join("\n"));
00072 }
00073 
00074 void
00075 RouterInfoDialog::setLocation(const QString &location)
00076 {
00077   ui.lblLocation->setText(location);
00078 }
00079 

Generated on 31 Mar 2010 for Vidalia by  doxygen 1.6.1