~ubuntu-branches/debian/stretch/spice/stretch

« back to all changes in this revision

Viewing changes to client/application.cpp

  • Committer: Package Import Robot
  • Author(s): Liang Guo, Liang Guo, Michael Tokarev
  • Date: 2011-11-29 14:37:08 UTC
  • mfrom: (0.6.1) (0.4.2) (2.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20111129143708-jptkxyjl3a4rds2r
Tags: 0.10.0-1
[ Liang Guo ]
* New upstream release (Closes: #651262)
* Refresh debian/copyright
* Remove fix-typo-in-cmd_line_parser-cpp.patch, applied upstream
* Remove fix-typo-in-record-cpp.patch, applied upstream
* Remove use-requires-private-for-libspice-pkgconfig.patch, applied upstream
* Change Build-Depends on libspice-protocol-dev to (>= 0.9.1~)
* Refresh libspice-server1.symbols
* Update debian/rules clean target
* Ignore common/win/my_getopt-1.5/Makefile change when building package
* debian/control: set DMUA

[ Michael Tokarev ]
* use `rm -f' instead of `-rm' in debian/rules clean targets
* remove python_modules/*.pyc in clean target

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   You should have received a copy of the GNU Lesser General Public
15
15
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
16
16
*/
 
17
#ifdef HAVE_CONFIG_H
 
18
#include <config.h>
 
19
#endif
17
20
 
18
21
#include "common.h"
19
22
#ifdef WIN32
31
34
#include "red_gdi_canvas.h"
32
35
#endif
33
36
#include "platform.h"
34
 
#include "sw_canvas.h"
35
 
#include "gl_canvas.h"
 
37
#include "red_sw_canvas.h"
 
38
#ifdef USE_OPENGL
 
39
#include "red_gl_canvas.h"
 
40
#endif
36
41
#include "quic.h"
37
42
#include "mutex.h"
38
43
#include "cmd_line_parser.h"
350
355
    , _monitors (NULL)
351
356
    , _title ("SPICEc:%d")
352
357
    , _sys_key_intercept_mode (false)
353
 
        , _enable_controller (false)
 
358
    , _enable_controller (false)
354
359
#ifdef USE_GUI
355
360
    , _gui_mode (GUI_MODE_FULL)
356
361
#endif // USE_GUI
383
388
    _canvas_types[0] = CANVAS_OPTION_SW;
384
389
#endif
385
390
 
386
 
    _host_auth_opt.type_flags = RedPeer::HostAuthOptions::HOST_AUTH_OP_NAME;
 
391
    _host_auth_opt.type_flags = SPICE_SSL_VERIFY_OP_HOSTNAME;
387
392
 
388
393
    Platform::get_app_data_dir(_host_auth_opt.CA_file, app_name);
389
394
    Platform::path_append(_host_auth_opt.CA_file, CA_FILE_NAME);
1187
1192
void Application::sync_keyboard_modifiers()
1188
1193
{
1189
1194
    uint32_t modifiers = Platform::get_keyboard_modifiers();
1190
 
    for (int i = 0; i < sizeof(modifier_keys) / sizeof(modifier_keys[0]); i++) {
 
1195
    for (size_t i = 0; i < sizeof(modifier_keys) / sizeof(modifier_keys[0]); i++) {
1191
1196
        if (modifiers & modifier_keys[i].modifier) {
1192
1197
            on_key_down(modifier_keys[i].key);
1193
1198
        } else {
1227
1232
    }
1228
1233
 
1229
1234
    if (!_sticky_info.sticky_mode) {
1230
 
        int command = get_hotkeys_commnad();
 
1235
        int command = get_hotkeys_command();
1231
1236
        if (command != APP_CMD_INVALID) {
1232
1237
            do_command(command);
1233
1238
            return;
1404
1409
                exit_full_screen();
1405
1410
            }
1406
1411
        }
1407
 
    } 
 
1412
    }
1408
1413
 
1409
1414
    if (force_capture || capture) {
1410
1415
        if (!toggle_full_screen) {
1698
1703
    return iter == key_set.end();
1699
1704
}
1700
1705
 
1701
 
int Application::get_hotkeys_commnad()
 
1706
int Application::get_hotkeys_command()
1702
1707
{
1703
1708
    HotKeys::const_iterator iter = _hot_keys.begin();
1704
1709
 
2015
2020
 
2016
2021
bool Application::set_host_cert_subject(const char* subject, const char* arg0)
2017
2022
{
2018
 
     if (!_host_auth_opt.set_cert_subject(subject)) {
2019
 
        Platform::term_printf("%s: bad cert subject %s", arg0, subject);
2020
 
        _exit_code = SPICEC_ERROR_CODE_INVALID_ARG;
2021
 
        return false;
2022
 
     }
2023
 
 
2024
 
     return true;
 
2023
    std::string subject_str(subject);
 
2024
    std::string::const_iterator iter = subject_str.begin();
 
2025
    std::string entry;
 
2026
    _host_auth_opt.type_flags = SPICE_SSL_VERIFY_OP_SUBJECT;
 
2027
    _host_auth_opt.host_subject = subject;
 
2028
 
 
2029
    /* the follow is only checking code, subject is parsed later
 
2030
       ssl_verify.c.  We keep simply because of better error message... */
 
2031
    while (true) {
 
2032
        if ((iter == subject_str.end()) || (*iter == ',')) {
 
2033
            RedPeer::HostAuthOptions::CertFieldValuePair entry_pair;
 
2034
            size_t value_pos = entry.find_first_of('=');
 
2035
            if ((value_pos == std::string::npos) || (value_pos == (entry.length() - 1))) {
 
2036
                Platform::term_printf("%s: host_subject bad format: assignment for %s is missing\n",
 
2037
                                      arg0, entry.c_str());
 
2038
                _exit_code = SPICEC_ERROR_CODE_INVALID_ARG;
 
2039
                return false;
 
2040
            }
 
2041
            size_t start_pos = entry.find_first_not_of(' ');
 
2042
            if ((start_pos == std::string::npos) || (start_pos == value_pos)) {
 
2043
                Platform::term_printf("%s: host_subject bad format: first part of assignment must be non empty in %s\n",
 
2044
                                      arg0, entry.c_str());
 
2045
                _exit_code = SPICEC_ERROR_CODE_INVALID_ARG;
 
2046
                return false;
 
2047
            }
 
2048
            entry_pair.first = entry.substr(start_pos, value_pos - start_pos);
 
2049
            entry_pair.second = entry.substr(value_pos + 1);
 
2050
            DBG(0, "subject entry: %s=%s", entry_pair.first.c_str(), entry_pair.second.c_str());
 
2051
            if (iter == subject_str.end()) {
 
2052
                break;
 
2053
            }
 
2054
            entry.clear();
 
2055
        } else if (*iter == '\\') {
 
2056
            iter++;
 
2057
            if (iter == subject_str.end()) {
 
2058
                LOG_WARN("single \\ in host subject");
 
2059
                entry.append(1, '\\');
 
2060
                continue;
 
2061
            } else if ((*iter == '\\') || (*iter == ',')) {
 
2062
                entry.append(1, *iter);
 
2063
            } else {
 
2064
                LOG_WARN("single \\ in host subject");
 
2065
                entry.append(1, '\\');
 
2066
                continue;
 
2067
            }
 
2068
        } else {
 
2069
            entry.append(1, *iter);
 
2070
        }
 
2071
        iter++;
 
2072
    }
 
2073
 
 
2074
    return true;
2025
2075
}
2026
2076
 
2027
2077
bool Application::set_canvas_option(CmdLineParser& parser, char *val, const char* arg0)
2033
2083
#ifdef WIN32
2034
2084
    canvas_types["gdi"] = CANVAS_OPTION_GDI;
2035
2085
#endif
2036
 
#ifdef USE_OGL
 
2086
#ifdef USE_OPENGL
2037
2087
    canvas_types["gl_fbo"] = CANVAS_OPTION_OGL_FBO;
2038
2088
    canvas_types["gl_pbuff"] = CANVAS_OPTION_OGL_PBUFF;
2039
2089
#endif
2269
2319
#ifdef USE_SMARTCARD
2270
2320
    parser.add(SPICE_OPT_SMARTCARD, "smartcard", "enable smartcard channel");
2271
2321
    parser.add(SPICE_OPT_NOSMARTCARD, "nosmartcard", "disable smartcard channel");
2272
 
    parser.add(SPICE_OPT_SMARTCARD_CERT, "smartcard-cert", "Use virtual reader+card with given cert(s)",
2273
 
        "smartcard-cert", true);
 
2322
    parser.add(SPICE_OPT_SMARTCARD_CERT, "smartcard-cert",
 
2323
               "Use virtual reader+card with given cert(s)",
 
2324
               "smartcard-cert", true);
2274
2325
    parser.set_multi(SPICE_OPT_SMARTCARD_CERT, ',');
2275
2326
    parser.add(SPICE_OPT_SMARTCARD_DB, "smartcard-db", "Use given db for smartcard certs", "smartcard-db", true);
2276
2327
#endif
2496
2547
    va_end(ap);
2497
2548
 
2498
2549
    if (type >= log_level && log_file != NULL) {
2499
 
        fprintf(log_file, "%ld %s [%llu:%llu] %s: %s\n", (long)time(NULL), type_as_char[type],
2500
 
                (long long int)Platform::get_process_id(), (long long int)Platform::get_thread_id(),
 
2550
        fprintf(log_file,"%ld %s [%" PRIu64 ":%" PRIu64 "] %s: %s\n",
 
2551
                (long)time(NULL), type_as_char[type],
 
2552
                Platform::get_process_id(),
 
2553
                Platform::get_thread_id(),
2501
2554
                function_to_func_name(function).c_str(),
2502
2555
                formated_message.c_str());
2503
 
                fflush(log_file);
 
2556
        fflush(log_file);
2504
2557
    }
2505
2558
 
2506
2559
    if (type >= LOG_WARN) {
2532
2585
    SSL_load_error_strings();
2533
2586
 
2534
2587
    sw_canvas_init();
2535
 
#ifdef USE_OGL
 
2588
#ifdef USE_OPENGL
2536
2589
    gl_canvas_init();
2537
2590
#endif
2538
2591
    quic_init();