summaryrefslogtreecommitdiff
path: root/SPICEConsoleAPI.cpp
blob: d71e8faa85f727195cdb2946b34ce36c9b97e4ca (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
/**********************************************************\

  Auto-generated SPICEConsoleAPI.cpp

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

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

#include "SPICEConsoleAPI.h"

///////////////////////////////////////////////////////////////////////////////
/// @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;
}


// Methods

void SPICEConsoleAPI::connect()
{}

void SPICEConsoleAPI::show()
{}

void SPICEConsoleAPI::disconnect()
{}

void SPICEConsoleAPI::SetLanguageStrings(const std::string &section,
                                         const std::string &lang)
{
    if ((section.size() == 0) || (lang.size() == 0)) {
        return;
    }

    m_languages[section] = lang;
}

void SPICEConsoleAPI::SetUsbFilter(const std::string &filter)
{
    m_usb_filter = filter;
}

int SPICEConsoleAPI::ConnectedStatus()
{
    return m_connected_status;
}

/* 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 */
}