orconnevent.cpp

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  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 orconnevent.cpp
00024  * \version $Id: orconnevent.cpp 1563 2006-12-26 06:06:04Z edmanm $
00025  * \brief Event dispatched upon receiving an ORCONN update from Tor
00026  */
00027 
00028 #include "orconnevent.h"
00029 
00030 #include "eventtype.h"
00031 
00032 /** Constructor
00033  * \param status OR connection status.
00034  * \param server OR server.
00035  */
00036 OrConnEvent::OrConnEvent(Status status, QString server)
00037 : QEvent((QEvent::Type)CustomEventType::OrConnEvent)
00038 {
00039   _status   = status;
00040   _server = server;
00041 }
00042 
00043 /** Converts a string description of a connection's status to an enum value */
00044 OrConnEvent::Status
00045 OrConnEvent::toStatus(QString status)
00046 {
00047   Status s;
00048   status = status.toUpper();
00049   if (status == "NEW") {
00050     s = New;
00051   } else if (status == "LAUNCHED") {
00052     s = Launched;
00053   } else if (status == "CONNECTED") {
00054     s = Connected;
00055   } else if (status == "FAILED") {
00056     s = Failed;
00057   } else if (status == "CLOSED") {
00058     s = Closed;
00059   } else {
00060     s = Unknown;
00061   }
00062   return s;
00063 }
00064 
00065 /** Returns the status for this OR connection. */
00066 OrConnEvent::Status
00067 OrConnEvent::status()
00068 {
00069   return _status;
00070 }
00071 
00072 /** Returns the OR server with which this connection is associated. */
00073 QString
00074 OrConnEvent::server()
00075 {
00076   return _server;
00077 }
00078 

Generated on Wed Sep 5 15:49:28 2007 for Vidalia by  doxygen 1.5.3