Vidalia  0.3.1
Service.cpp
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 #include "Service.h"
12 
13 
14 /** Default Constructor */
16 {
17 }
18 
19 /** Constructor to create a new Service with initial settings */
20 Service::Service(QString serviceAddress, QString virtualPort,
21  QString physicalAddressPort, QString serviceDirectory, bool enabled)
22 {
27  _enabled = enabled;
28 }
29 
30 /** Destructor */
32 {
33 }
34 
35 /** Sets the deploy status of a service */
36 void Service::setEnabled(bool enabled)
37 {
38  _enabled = enabled;
39 }
40 
41 /** Sets the adress of a service */
42 void Service::setServiceAddress(QString serviceAddress)
43 {
45 }
46 
47 /** Sets the virtualPort of a service */
48 void Service::setVirtualPort(QString virtualPort)
49 {
51 }
52 
53 /** Sets the physical Adress and the local port of a service */
54 void Service::setPhysicalAddressPort(QString physicalAddressPort)
55 {
57 }
58 
59 /** Sets the service directory of a service */
60 void Service::setServiceDirectory(QString serviceDirectory)
61 {
63 }
64 
65 /** Sets the additional options of a service e.g. excludeNodes */
67 {
68  _additionalServiceOptions = options;
69 }
70 
71 /** Writes service class data from <b>myObj</b> to the QDataStream
72  * <b>out</b>. */
73 QDataStream&operator<<(QDataStream &out, const Service &myObj)
74 {
75  out << myObj.serviceAddress();
76  out << myObj.virtualPort();
77  out << myObj.physicalAddressPort();
78  out << myObj.serviceDirectory();
79  out << myObj.enabled();
80  out << myObj.additionalServiceOptions();
81 
82  return out;
83 }
84 
85 /** Reads service class data in from the QDataStream <b>in</b> and
86  populates * the <b>myObj</b> object accordingly. */
87 QDataStream&operator>>(QDataStream &in, Service &myObj)
88 {
89  QString serviceAddress;
90  QString virtualPort;
91  QString physicalAddressPort;
92  QString serviceDirectory;
93  bool enabled;
94  QString additionalServiceOptions;
95 
96  /* Read in from the data stream */
97  in >> serviceAddress >> virtualPort >> physicalAddressPort
98  >> serviceDirectory >> enabled >> additionalServiceOptions;
99 
100  /* Set the appropriate class member variables */
101  myObj.setServiceAddress(serviceAddress);
102  myObj.setVirtualPort(virtualPort);
103  myObj.setPhysicalAddressPort(physicalAddressPort);
104  myObj.setServiceDirectory(serviceDirectory);
105  myObj.setEnabled(enabled);
106  myObj.setAdditionalServiceOptions(additionalServiceOptions);
107 
108  /* Return the updated data stream */
109  return in;
110 }
111 
112 /** Creates a string by concatenating the values of the service. */
113 QString
115 {
118 }
119 
virtual ~Service()
Definition: Service.cpp:31
void setServiceAddress(QString serviceAddress)
Definition: Service.cpp:42
QString _serviceAddress
Definition: Service.h:65
void setEnabled(bool enabled)
Definition: Service.cpp:36
QString _physicalAddressPort
Definition: Service.h:69
QString _additionalServiceOptions
Definition: Service.h:75
void setPhysicalAddressPort(QString physicalAddressPort)
Definition: Service.cpp:54
bool _enabled
Definition: Service.h:73
void setServiceDirectory(QString serviceDirectory)
Definition: Service.cpp:60
QDataStream & operator<<(QDataStream &out, const Service &myObj)
Definition: Service.cpp:73
void setAdditionalServiceOptions(QString options)
Definition: Service.cpp:66
QString virtualPort() const
Definition: Service.h:32
bool enabled() const
Definition: Service.h:38
QString physicalAddressPort() const
Definition: Service.h:34
QString toString()
Definition: Service.cpp:114
QString _serviceDirectory
Definition: Service.h:71
QString additionalServiceOptions() const
Definition: Service.h:40
QString serviceAddress() const
Definition: Service.h:30
Service()
Definition: Service.cpp:15
QDataStream & operator>>(QDataStream &in, Service &myObj)
Definition: Service.cpp:87
QString serviceDirectory() const
Definition: Service.h:36
QString _virtualPort
Definition: Service.h:67
void setVirtualPort(QString virtualPort)
Definition: Service.cpp:48