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 #include "Service.h" 00012 00013 00014 /** Default Constructor */ 00015 Service::Service() 00016 { 00017 } 00018 00019 /** Constructor to create a new Service with initial settings */ 00020 Service::Service(QString serviceAddress, QString virtualPort, 00021 QString physicalAddressPort, QString serviceDirectory, bool enabled) 00022 { 00023 _serviceAddress = serviceAddress; 00024 _virtualPort = virtualPort; 00025 _physicalAddressPort = physicalAddressPort; 00026 _serviceDirectory = serviceDirectory; 00027 _enabled = enabled; 00028 } 00029 00030 /** Destructor */ 00031 Service::~Service() 00032 { 00033 } 00034 00035 /** Sets the deploy status of a service */ 00036 void Service::setEnabled(bool enabled) 00037 { 00038 _enabled = enabled; 00039 } 00040 00041 /** Sets the adress of a service */ 00042 void Service::setServiceAddress(QString serviceAddress) 00043 { 00044 _serviceAddress = serviceAddress; 00045 } 00046 00047 /** Sets the virtualPort of a service */ 00048 void Service::setVirtualPort(QString virtualPort) 00049 { 00050 _virtualPort = virtualPort; 00051 } 00052 00053 /** Sets the physical Adress and the local port of a service */ 00054 void Service::setPhysicalAddressPort(QString physicalAddressPort) 00055 { 00056 _physicalAddressPort = physicalAddressPort; 00057 } 00058 00059 /** Sets the service directory of a service */ 00060 void Service::setServiceDirectory(QString serviceDirectory) 00061 { 00062 _serviceDirectory = serviceDirectory; 00063 } 00064 00065 /** Sets the additional options of a service e.g. excludeNodes */ 00066 void Service::setAdditionalServiceOptions(QString options) 00067 { 00068 _additionalServiceOptions = options; 00069 } 00070 00071 /** Writes service class data from <b>myObj</b> to the QDataStream 00072 * <b>out</b>. */ 00073 QDataStream&operator<<(QDataStream &out, const Service &myObj) 00074 { 00075 out << myObj.serviceAddress(); 00076 out << myObj.virtualPort(); 00077 out << myObj.physicalAddressPort(); 00078 out << myObj.serviceDirectory(); 00079 out << myObj.enabled(); 00080 out << myObj.additionalServiceOptions(); 00081 00082 return out; 00083 } 00084 00085 /** Reads service class data in from the QDataStream <b>in</b> and 00086 populates * the <b>myObj</b> object accordingly. */ 00087 QDataStream&operator>>(QDataStream &in, Service &myObj) 00088 { 00089 QString serviceAddress; 00090 QString virtualPort; 00091 QString physicalAddressPort; 00092 QString serviceDirectory; 00093 bool enabled; 00094 QString additionalServiceOptions; 00095 00096 /* Read in from the data stream */ 00097 in >> serviceAddress >> virtualPort >> physicalAddressPort 00098 >> serviceDirectory >> enabled >> additionalServiceOptions; 00099 00100 /* Set the appropriate class member variables */ 00101 myObj.setServiceAddress(serviceAddress); 00102 myObj.setVirtualPort(virtualPort); 00103 myObj.setPhysicalAddressPort(physicalAddressPort); 00104 myObj.setServiceDirectory(serviceDirectory); 00105 myObj.setEnabled(enabled); 00106 myObj.setAdditionalServiceOptions(additionalServiceOptions); 00107 00108 /* Return the updated data stream */ 00109 return in; 00110 } 00111 00112 /** Creates a string by concatenating the values of the service. */ 00113 QString 00114 Service::toString() 00115 { 00116 return _serviceAddress +"#"+ _virtualPort +"#"+ _physicalAddressPort + 00117 "#"+ _serviceDirectory +"#"+ _enabled + "#"+ _additionalServiceOptions; 00118 } 00119