summaryrefslogtreecommitdiff
path: root/SPICEConsoleAPI.cpp
blob: 473554d1bc50b3d296ed7b599a354e0efe4a3a5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**********************************************************\

  Auto-generated SPICEConsoleAPI.cpp

\**********************************************************/

#include "JSObject.h"
#include "variant_list.h"
#include "DOM/Document.h"
#include "global/config.h"

#include "SPICEConsoleAPI.h"

///////////////////////////////////////////////////////////////////////////////
/// @fn FB::variant SPICEConsoleAPI::echo(const FB::variant& msg)
///
/// @brief  Echos whatever is passed from Javascript.
///         Go ahead and change it. See what happens!
///////////////////////////////////////////////////////////////////////////////
FB::variant SPICEConsoleAPI::echo(const FB::variant& msg)
{
    static int n(0);
    fire_echo("So far, you clicked this many times: ", n++);

    // return "foobar";
    return msg;
}

///////////////////////////////////////////////////////////////////////////////
/// @fn SPICEConsolePtr SPICEConsoleAPI::getPlugin()
///
/// @brief  Gets a reference to the plugin that was passed in when the object
///         was created.  If the plugin has already been released then this
///         will throw a FB::script_error that will be translated into a
///         javascript exception in the page.
///////////////////////////////////////////////////////////////////////////////
SPICEConsolePtr SPICEConsoleAPI::getPlugin()
{
    SPICEConsolePtr plugin(m_plugin.lock());
    if (!plugin) {
        throw FB::script_error("The plugin is invalid");
    }
    return plugin;
}

DEFINE_PROPERTY_STRING(hostIP)
DEFINE_PROPERTY_STRING(port)
DEFINE_PROPERTY_STRING(SecurePort)
DEFINE_PROPERTY_STRING(Password)
DEFINE_PROPERTY_STRING(CipherSuite)
//DEFINE_PROPERTY_STRING(SSLChannels)
DEFINE_PROPERTY_STRING(TrustStore)
DEFINE_PROPERTY_STRING(HostSubject)
DEFINE_PROPERTY_BOOL(fullScreen)
DEFINE_PROPERTY_BOOL(Smartcard)
DEFINE_PROPERTY_BOOL(AdminConsole)
DEFINE_PROPERTY_STRING(Title)
DEFINE_PROPERTY_STRING(dynamicMenu)
DEFINE_PROPERTY_STRING(NumberOfMonitors)
DEFINE_PROPERTY_STRING(GuestHostName)
DEFINE_PROPERTY_STRING(HotKey)
DEFINE_PROPERTY_BOOL(NoTaskMgrExecution)
DEFINE_PROPERTY_BOOL(SendCtrlAltDelete)
DEFINE_PROPERTY_STRING(UsbListenPort)
DEFINE_PROPERTY_BOOL(UsbAutoShare)
DEFINE_PROPERTY_STRING(ColorDepth)
DEFINE_PROPERTY_STRING(DisableEffects)

/* attribute string SSLChannels; */
std::string SPICEConsoleAPI::get_SSLChannels() const
{
    return m_SSLChannels;
}

void SPICEConsoleAPI::set_SSLChannels(const std::string &aSSLChannels)
{
    m_SSLChannels = aSSLChannels;

    /*
     * Backward Compatibility: Begin
     * Remove leading 's' from m_SSLChannels, e.g. "main" not "smain"
     * RHEL5 uses 'smain' and 'sinpusts
     * RHEL6 uses 'main'  and 'inputs'
     */
    const char* chan_names[] = {
        "smain", "sdisplay", "sinputs",
        "scursor", "splayback", "srecord",
        "susbredir", "ssmartcard", "stunnel"
    };
    const int nnames = sizeof(chan_names) / sizeof(chan_names[0]);

    for (int i = 0; i < nnames; i++) {
        const char *name = chan_names[i];
        size_t found = 0;
        while ((found = m_SSLChannels.find(name, found)) != std::string::npos)
            m_SSLChannels.replace(found, strlen(name), name + 1);
    }
    /* Backward Compatibility: End */
}

void SPICEConsoleAPI::testEvent()
{
    fire_test();
}