Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
torcontrol
SendCommandEvent.h
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
4
** you did not receive the LICENSE file with this file, you may obtain it
5
** from the 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
/*
12
** \file SendCommandEvent.h
13
** \brief An event posted to a socket living in another thread, indicating
14
** that it should send the given control command.
15
*/
16
17
#ifndef _SENDCOMMANDEVENT_H
18
#define _SENDCOMMANDEVENT_H
19
20
#include "
ControlCommand.h
"
21
22
#include <QEvent>
23
#include <QMutex>
24
#include <QWaitCondition>
25
26
27
class
SendCommandEvent
:
public
QEvent {
28
public
:
29
/** Object used to wait for the result of a send operation. */
30
class
SendWaiter
{
31
public
:
32
/** Status of the send SendWaiter. */
33
enum
SenderStatus
{
Waiting
,
Failed
,
Success
}
_status
;
34
/** Default constructor. */
35
SendWaiter
() {
_status
=
Waiting
; }
36
/** Sets the result of the send operation. */
37
void
setResult
(
bool
success,
const
QString &errmsg = QString());
38
/** Waits for and returns the result of the send operation. */
39
bool
getResult
(QString *errmsg = 0);
40
/** Returns the SendWaiter's current SenderStatus value. */
41
SenderStatus
status
();
42
private
:
43
QMutex
_mutex
;
/**< Mutex around the wait condition. */
44
QWaitCondition
_waitCond
;
/**< Waits for the send to complete. */
45
QString
_errmsg
;
/**< Error message if the send fails. */
46
};
47
48
/** Constructor. */
49
SendCommandEvent
(
const
ControlCommand
&cmd,
SendWaiter
*w = 0);
50
/** Returns the control command to send to Tor. */
51
ControlCommand
command
() {
return
_cmd
; }
52
/** Returns a SendWaiter (if any) for the result of this send. */
53
SendWaiter
*
waiter
() {
return
_waiter
; }
54
55
private
:
56
ControlCommand
_cmd
;
/**< Command to send to Tor. */
57
SendWaiter
*
_waiter
;
/**< SendWaiter for the result of this event. */
58
};
59
60
#endif
Generated on Thu Dec 6 2012 04:33:17 for Vidalia by
1.8.2