This repository has been archived by the owner on Aug 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CP-1290: Display EULAs on boot if password not set
- Loading branch information
Andy Southgate
committed
Sep 30, 2009
1 parent
8e48a18
commit e9321f9
Showing
8 changed files
with
122 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Copyright (c) Citrix Systems 2009. All rights reserved. | ||
# xsconsole is proprietary software. | ||
# | ||
# Xen, the Xen logo, XenCenter, XenMotion are trademarks or registered | ||
# trademarks of Citrix Systems, Inc., in the United States and other | ||
# countries. | ||
|
||
if __name__ == "__main__": | ||
raise Exception("This script is a plugin for xsconsole and cannot run independently") | ||
|
||
from XSConsoleStandard import * | ||
|
||
class EULADialogue(Dialogue): | ||
def __init__(self, inFilename): | ||
Dialogue.__init__(self) | ||
|
||
xSize = Layout.Inst().APP_XSIZE | ||
ySize = Layout.Inst().APP_YSIZE | ||
|
||
self.filename = inFilename | ||
try: | ||
file = open(inFilename) | ||
try: | ||
contents = ''.join(file.readlines()) | ||
finally: | ||
file.close() | ||
except Exception, e: | ||
contents = str(e) | ||
|
||
self.maxLine = 0 | ||
for line in contents.split('\n'): | ||
self.maxLine = max(self.maxLine, len(line)) | ||
self.padding = ' ' * max(0, (xSize - 4 - self.maxLine) / 2) | ||
|
||
self.text = Lang("End User License Agreement") | ||
self.info = contents | ||
paneSizer = PaneSizerFixed(0, 1, xSize, ySize - 1) | ||
pane = self.NewPane(DialoguePane(self.parent, paneSizer)) | ||
pane.AddBox() | ||
self.UpdateFields() | ||
|
||
def UpdateFields(self): | ||
pane = self.Pane() | ||
pane.ResetFields() | ||
|
||
pane.AddWrappedCentredBoldTextField(self.text) | ||
|
||
if self.info is not None: | ||
pane.NewLine() | ||
# Add one field per line to preserve preformatting | ||
for line in self.info.split('\n'): | ||
pane.AddTextField(self.padding+line) | ||
pane.NewLine() | ||
|
||
helpKeys = { Lang("<Enter>") : Lang("Accept") , Lang("<Esc>") : Lang("Decline") } | ||
if pane.NeedsScroll(): | ||
helpKeys.update({ | ||
Lang("<Page Up/Page Down>") : Lang("Scroll") | ||
}) | ||
|
||
pane.AddKeyHelpField( helpKeys ) | ||
|
||
def HandleKey(self, inKey): | ||
handled = True | ||
if inKey == 'KEY_ESCAPE': | ||
Importer.ActivateNamedPlugIn('SHUTDOWN', Lang("You must accept the End User License Agreement to continue. Would you like to shutdown?")) | ||
elif inKey == 'KEY_ENTER': | ||
XSLog("User accepted EULA '"+self.filename+"'") | ||
Layout.Inst().PopDialogue() | ||
elif inKey == 'KEY_PPAGE': | ||
for i in range(20): | ||
self.Pane().ScrollPageUp() | ||
elif inKey == 'KEY_NPAGE': | ||
for i in range(20): | ||
self.Pane().ScrollPageDown() | ||
elif inKey == 'KEY_UP': | ||
self.Pane().ScrollPageUp() | ||
elif inKey in ('KEY_DOWN', ' '): | ||
self.Pane().ScrollPageDown() | ||
else: | ||
handled = False | ||
return handled | ||
|
||
class XSFeatureEULA: | ||
@classmethod | ||
def ActivateHandler(cls, *inParams): | ||
for eula in Config.Inst().FirstBootEULAs(): | ||
Layout.Inst().PushDialogue(EULADialogue(eula, *inParams)) | ||
|
||
def Register(self): | ||
Importer.RegisterNamedPlugIn( | ||
self, | ||
'EULA', # This key is referred to by name in XSConsoleTerm.py | ||
{ | ||
'activatehandler' : self.ActivateHandler | ||
} | ||
) | ||
|
||
# Register this plugin when module is imported | ||
XSFeatureEULA().Register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters