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

Generated on 2 Sep 2009 for Vidalia by  doxygen 1.6.1