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 00004 ** you did not receive the LICENSE file with this file, you may obtain it 00005 ** from the 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 00008 ** the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file orconnevent.cpp 00013 ** \version $Id: orconnevent.cpp 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief Event dispatched upon receiving an ORCONN update from Tor 00015 */ 00016 00017 #include "orconnevent.h" 00018 00019 #include "eventtype.h" 00020 00021 /** Constructor 00022 * \param status OR connection status. 00023 * \param server OR server. 00024 */ 00025 OrConnEvent::OrConnEvent(Status status, QString server) 00026 : QEvent((QEvent::Type)CustomEventType::OrConnEvent) 00027 { 00028 _status = status; 00029 _server = server; 00030 } 00031 00032 /** Converts a string description of a connection's status to an enum value */ 00033 OrConnEvent::Status 00034 OrConnEvent::toStatus(QString status) 00035 { 00036 Status s; 00037 status = status.toUpper(); 00038 if (status == "NEW") { 00039 s = New; 00040 } else if (status == "LAUNCHED") { 00041 s = Launched; 00042 } else if (status == "CONNECTED") { 00043 s = Connected; 00044 } else if (status == "FAILED") { 00045 s = Failed; 00046 } else if (status == "CLOSED") { 00047 s = Closed; 00048 } else { 00049 s = Unknown; 00050 } 00051 return s; 00052 } 00053 00054 /** Returns the status for this OR connection. */ 00055 OrConnEvent::Status 00056 OrConnEvent::status() 00057 { 00058 return _status; 00059 } 00060 00061 /** Returns the OR server with which this connection is associated. */ 00062 QString 00063 OrConnEvent::server() 00064 { 00065 return _server; 00066 } 00067