/usr/share/pyshared/ControlAula/Desktop.py is in ltsp-controlaula 1.8.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | ##############################################################################
# -*- coding: utf-8 -*-
# Project: Controlaula
# Module: Desktop.py
# Purpose: Model a desktop pc with its user to be sent to the frontend
# Language: Python 2.5
# Date: 21-Jan-2010.
# Ver: 27-Jan-2010.
# Author: José L. Redrejo Rodríguez
# Copyright: 2009-2010 - José L. Redrejo Rodríguez <jredrejo @nospam@ debian.org>
#
# ControlAula is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# ControlAula is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with ControlAula. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
class Desktop(object):
def __init__(self,classroom):
self.hostkey=''
self.userkey=''
self.login=''
self.username=''
self.hostname='Unknown'
self.ip=''
self.ltsp=False
self.internet=0
self.sound=0
self.mouse=0
self.messages=0
self.photo=''
self.mainIP=''
self.video=False
self.bigbrother=False
self.projector=False
self.classroom=classroom
self.host=None
def __str__(self):
return str((self.hostkey,self.userkey,self.login,self.username,self.hostname,self.ip,self.ltsp, self.internet,self.sound,self.mouse,self.messages,self.photo))
def _KeyboardMouse(self,value,command):
if self.hostkey!='':
self.classroom.CommandStack[self.mainIP].append([command])
self.mouse=value
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append([command])
self.classroom.LoggedUsers[self.userkey].mouse=value
def enableKeyboardMouse(self):
self._KeyboardMouse('1','enableMouse')
def disableKeyboardMouse(self):
self._KeyboardMouse('0','disableMouse')
def _Sound(self,value,command):
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append([command])
self.sound=value
self.classroom.LoggedUsers[self.userkey].sound=value
def enableSound(self):
self._Sound('1','enableSound')
def disableSound(self):
self._Sound('0','disableSound')
def enableChat(self):
if self.userkey!='':
self.classroom.LoggedUsers[self.userkey].chat_enabled=True
self._Messages('1', 'enableMessages')
def disableChat(self):
if self.userkey!='':
self.classroom.LoggedUsers[self.userkey].chat_enabled=False
self._Messages('0', 'enableMessages')
def _Internet(self,value,command):
if self.mainIP !='':
self.internet=value
self.classroom.Hosts[self.mainIP].internetEnabled=value
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append([command])
#the host must disable internet to this user:
self.classroom.CommandStack[self.ip].append(['root'+command,self.login])
self.classroom.LoggedUsers[self.userkey].internet=value
def enableInternet(self):
self._Internet('1','enableInternet')
def disableInternet(self):
self._Internet('0','disableInternet')
def _Messages(self,value,command):
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append([command])
self.messages=value
self.classroom.LoggedUsers[self.userkey].messages=value
def enableMessages(self):
self._Messages('1', 'disableMessages')
def disableMessages(self):
self._Messages('0', 'enableMessages')
def sendMessage(self,text):
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append(['receiveMessage',text])
def setProjector(self):
if self.hostkey!='':
self.classroom.CommandStack[self.mainIP].append(['projector'])
self.projector=True
self.disableKeyboardMouse()
def resetProjector(self):
if self.hostkey!='':
self.classroom.CommandStack[self.mainIP].append(['resetProjector'])
self.projector=False
self.enableKeyboardMouse()
def setBigBrother(self):
if self.userkey!='':
from shutil import copyfile
from Utils import Configs
import os.path
if not self.bigbrother:
photo=os.path.basename(self.photo)
self.classroom.LoggedUsers[self.userkey].shotname=photo
try:
copyfile(os.path.join(Configs.IMAGES_DIR,photo),os.path.join(Configs.IMAGES_DIR + '/screenshots',photo))
except:
pass
self.classroom.CommandStack[self.userkey].append(['bigbrother'])
self.bigbrother=True
def resetBigBrother(self):
if self.userkey !='':
self.classroom.CommandStack[self.userkey].append(['disablebigbrother'])
self.bigbrother=False
def sendBroadcast(self,url,isDVD,encodec=False):
if self.hostkey != '':
if self.userkey != '' and not self.ltsp and encodec:
key = self.userkey
else:
key = self.mainIP
if self.ltsp:
self.classroom.CommandStack[self.ip].append(['rootmulticast','192.168.0.254'])
#self.classroom.CommandStack[key].append(['broadcast',url,isDVD,encodec])
self.classroom.CommandStack[self.mainIP].append(['broadcast',url,isDVD,encodec])
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append(['disableMouse'])
self.classroom.LoggedUsers[self.userkey].mouse=False
self.video=True
def stopBroadcast(self):
if self.hostkey!='':
self.classroom.CommandStack[self.mainIP].append(['stopBroadcast'])
self.enableKeyboardMouse()
self.video=False
def sleep(self):
if self.hostkey!='':
self.classroom.CommandStack[self.mainIP].append(['sleep'])
def sendFile(self,command,filename):
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append([command,filename])
def launchWeb(self,url):
if self.userkey!='':
self.classroom.CommandStack[self.userkey].append(['launchweb',url])
def putHost(self,host,key):
'''Place the host pc of this Desktop , where host is a list containing the host data, and key if the
key of this host in the Hosts dictionary at Classroom
self.Hosts[hostip]=[login,hostname,hostip,mac,ltsp,classname,internetEnabled,printerShared,datetime.datetime.now() ]
'''
self.hostkey=key
self.hostname=host.hostname
self.ip=host.ip
self.mainIP=host.ip
self.ltsp=host.ltsp
self.internet=host.internet
self.host=host
def putUser(self,user,key):
'''Place the logged user of this Desktop , where user is a list containing the user data, and key if the
key of this user in the LoggedUsers dictionary at Classroom
self.LoggedUsers[key]=[login,hostname,hostip,ltsp,classname,username,ipLTSP,internetEnabled,
mouseEnabled,printerShared,messagesEnabled,photo,datetime.datetime.now() ]
'''
self.userkey=key
self.login=user.login
self.username=user.username
self.internet=user.internet
self.mouse=user.mouse
self.sound=user.sound
self.messages=user.messages
self.photo=user.photo
self.ip=user.ip
self.ltsp=user.ltsp
if user.ltsp:
self.mainIP=user.ipLTSP
else:
self.mainIP=user.ip
def delHost(self):
'''After the host is off
'''
self.hostkey=''
self.ip=''
self.mainIP=''
self.delUser()
def delUser(self):
'''After the user logouts
'''
self.userkey=''
self.login=''
self.username=''
self.photo=''
#recover host settings:
self.ip=self.host.ip
self.mainIP=self.host.ip
self.ltsp=self.host.ltsp
self.internet= self.host.internet
def getFrontendInfo(self):
''' builds the line that must be passed to the frontend for this desktop
'''
dict={}
if self.hostkey=='':
dict['ON']='0'
else:
dict['ON']='1'
dict['mouseEnabled']=str(self.mouse)
dict['internetEnabled']=str(self.internet)
dict['messagesEnabled']=str(self.messages)
dict['printerShared']=str(self.sound)
dict['photo']=self.photo
dict['visible']='1'
dict['loginname']=self.login
dict['username']=self.username
dict['PCname']=self.hostname
dict['video']=self.video
dict['bigBrother']=self.bigbrother
dict['projector']=self.projector
return dict
def getScreenshotInfo(self):
''' builds the line that must be passed to the frontend for this desktop
'''
dict={}
dict['name']=self.login
dict['pcname']=self.hostname
if self.userkey=='':
dict['url']='no_screenshot'
else:
dict['url']='loginimages/screenshots/'+ self.classroom.LoggedUsers[self.userkey].shotname
return dict
|