Lines 69-75
Link Here
|
69 |
_GENERAL_WARNING_RE = re.compile(r"^Warning:\s+(?P<warning>.*)$") |
69 |
_GENERAL_WARNING_RE = re.compile(r"^Warning:\s+(?P<warning>.*)$") |
70 |
_GEOMETRY_RE = re.compile(r"^Info:\s+Screen\s+\[0\]\s+resized\s+to\s+" |
70 |
_GEOMETRY_RE = re.compile(r"^Info:\s+Screen\s+\[0\]\s+resized\s+to\s+" |
71 |
r"geometry\s+\[(?P<geometry>[^\]]+)\]" |
71 |
r"geometry\s+\[(?P<geometry>[^\]]+)\]" |
72 |
r"( fullscreen \[\d\])?\.$") |
72 |
r"( fullscreen \[(?P<fullscreen>\d)\])?\.$") |
73 |
|
73 |
|
74 |
|
74 |
|
75 |
class UserApplication(daemon.Program): |
75 |
class UserApplication(daemon.Program): |
Lines 384-391
Link Here
|
384 |
m = _GEOMETRY_RE.match(line) |
384 |
m = _GEOMETRY_RE.match(line) |
385 |
if m: |
385 |
if m: |
386 |
geometry = m.group("geometry") |
386 |
geometry = m.group("geometry") |
387 |
self._ChangeGeometry(geometry) |
387 |
fullscreen = (m.group("fullscreen") == "1") |
388 |
logging.info("Matched info geometry change, new is %r", geometry) |
388 |
self._ChangeGeometry(geometry, fullscreen) |
|
|
389 |
logging.info("Matched info geometry change, new is %r, fullscreen %r", |
390 |
geometry, fullscreen) |
389 |
return |
391 |
return |
390 |
|
392 |
|
391 |
def _CheckStatus(self, line, _status_map=None): |
393 |
def _CheckStatus(self, line, _status_map=None): |
Lines 426-436
Link Here
|
426 |
if new == old: |
428 |
if new == old: |
427 |
pass |
429 |
pass |
428 |
|
430 |
|
429 |
elif (old == constants.SESS_STATE_CREATED and |
|
|
430 |
new == constants.SESS_STATE_STARTING): |
431 |
self.__EmitDisplayReady() |
432 |
|
433 |
elif new == constants.SESS_STATE_WAITING: |
431 |
elif new == constants.SESS_STATE_WAITING: |
|
|
432 |
if old == constants.SESS_STATE_STARTING: |
433 |
self.__EmitDisplayReady() |
434 |
|
434 |
port = m.group("port") |
435 |
port = m.group("port") |
435 |
|
436 |
|
436 |
try: |
437 |
try: |
Lines 468-482
Link Here
|
468 |
# Send SIGHUP to reopen port |
469 |
# Send SIGHUP to reopen port |
469 |
self._SendSighup() |
470 |
self._SendSighup() |
470 |
|
471 |
|
471 |
def _ChangeGeometry(self, geometry): |
472 |
def _ChangeGeometry(self, geometry, fullscreen): |
472 |
"""Called when geometry changed. |
473 |
"""Called when geometry changed. |
473 |
|
474 |
|
474 |
@type geometry: str |
475 |
@type geometry: str |
475 |
@param geometry: Geometry information |
476 |
@param geometry: Geometry information |
|
|
477 |
@type fullscreen: boolean |
478 |
@param fullscreen: Fullscreen state |
476 |
|
479 |
|
477 |
""" |
480 |
""" |
478 |
sess = self._ctx.session |
481 |
sess = self._ctx.session |
479 |
sess.geometry = geometry |
482 |
sess.geometry = geometry |
|
|
483 |
sess.fullscreen = fullscreen |
480 |
sess.Save() |
484 |
sess.Save() |
481 |
|
485 |
|
482 |
def _FormatNxAgentOptions(self, opts): |
486 |
def _FormatNxAgentOptions(self, opts): |
Lines 491-497
Link Here
|
491 |
formatted = ",".join(["%s=%s" % (name, value) |
495 |
formatted = ",".join(["%s=%s" % (name, value) |
492 |
for name, value in opts.iteritems()]) |
496 |
for name, value in opts.iteritems()]) |
493 |
|
497 |
|
494 |
return "nx/nx,%s:%s\n" % (formatted, sess.display) |
498 |
return "nx/nx,%s:%d\n" % (formatted, sess.display) |
495 |
|
499 |
|
496 |
def _GetDisplayWithOptions(self): |
500 |
def _GetDisplayWithOptions(self): |
497 |
"""Returns the value for the DISPLAY variable for nxagent. |
501 |
"""Returns the value for the DISPLAY variable for nxagent. |
Lines 499-505
Link Here
|
499 |
""" |
503 |
""" |
500 |
sess = self._ctx.session |
504 |
sess = self._ctx.session |
501 |
|
505 |
|
502 |
return "nx/nx,options=%s:%s" % (sess.optionsfile, sess.display) |
506 |
self.__CheckStrChars(sess.optionsfile, "Session options file") |
|
|
507 |
|
508 |
return "nx/nx,options=%s:%d" % (sess.optionsfile, sess.display) |
503 |
|
509 |
|
504 |
def _GetOptions(self): |
510 |
def _GetOptions(self): |
505 |
"""Returns session options for nxagent. |
511 |
"""Returns session options for nxagent. |
Lines 552-561
Link Here
|
552 |
opts["shadowuid"] = self._ctx.uid |
558 |
opts["shadowuid"] = self._ctx.uid |
553 |
opts["shadow"] = ":%s" % sess.shadow_display |
559 |
opts["shadow"] = ":%s" % sess.shadow_display |
554 |
|
560 |
|
555 |
if not sess.rootless: |
561 |
if sess.rootless: |
556 |
opts["geometry"] = sess.geometry |
|
|
557 |
else: |
558 |
opts["menu"] = "1" |
562 |
opts["menu"] = "1" |
|
|
563 |
else: |
564 |
opts["geometry"] = sess.geometry |
559 |
opts["fullscreen"] = protocol.FormatNxBoolean(sess.fullscreen) |
565 |
opts["fullscreen"] = protocol.FormatNxBoolean(sess.fullscreen) |
560 |
|
566 |
|
561 |
if sess.rootless and sess.type == constants.SESS_TYPE_CONSOLE: |
567 |
if sess.rootless and sess.type == constants.SESS_TYPE_CONSOLE: |
Lines 592-598
Link Here
|
592 |
# nxagent port). |
598 |
# nxagent port). |
593 |
"-nolisten", "tcp", |
599 |
"-nolisten", "tcp", |
594 |
|
600 |
|
595 |
":%s" % sess.display, |
601 |
":%d" % sess.display, |
596 |
] |
602 |
] |
597 |
|
603 |
|
598 |
if sess.type == constants.SESS_TYPE_SHADOW: |
604 |
if sess.type == constants.SESS_TYPE_SHADOW: |
Lines 615-620
Link Here
|
615 |
""" |
621 |
""" |
616 |
sess = self._ctx.session |
622 |
sess = self._ctx.session |
617 |
filename = sess.optionsfile |
623 |
filename = sess.optionsfile |
|
|
624 |
self.__CheckOptsChars(opts) |
618 |
formatted = self._FormatNxAgentOptions(opts) |
625 |
formatted = self._FormatNxAgentOptions(opts) |
619 |
|
626 |
|
620 |
logging.debug("Writing session options %r to %s", formatted, filename) |
627 |
logging.debug("Writing session options %r to %s", formatted, filename) |
Lines 622-624
Link Here
|
622 |
|
629 |
|
623 |
def __EmitDisplayReady(self): |
630 |
def __EmitDisplayReady(self): |
624 |
self.emit(self.DISPLAY_READY_SIGNAL) |
631 |
self.emit(self.DISPLAY_READY_SIGNAL) |
|
|
632 |
|
633 |
def __CheckOptsChars(self, opts): |
634 |
"""Checks to make sure option name/values don't contain illegal characters. |
635 |
|
636 |
@type opts: dict |
637 |
@param opts: Options |
638 |
|
639 |
""" |
640 |
|
641 |
for name, value in opts.iteritems(): |
642 |
self.__CheckStrChars(name, "Name of option %r" % name) |
643 |
self.__CheckStrChars(value, "Value of option %r (%r)" % (name, value)) |
644 |
|
645 |
def __CheckStrChars(self, s, description): |
646 |
"""Checks to make sure string don't contain illegal characters. |
647 |
|
648 |
@type s: string |
649 |
@param s: text to test |
650 |
@type description: string |
651 |
@param description: description of text |
652 |
|
653 |
""" |
654 |
illegal_chars = [","] |
655 |
for c in illegal_chars: |
656 |
if c in s: |
657 |
raise errors.IllegalCharacterError("%s contains illegal character %r" % |
658 |
(description, c)) |