#708: OGAgent notifica el idioma al iniciar sesión de usuario.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5528 a21b9725-9963-47de-94b9-378ad31fedc9remotes/github/oglive
parent
aac3fb9aab
commit
622bc35be6
|
@ -124,9 +124,9 @@ class MessagesProcessor(QtCore.QThread):
|
|||
def isAlive(self):
|
||||
return self.ipc is not None
|
||||
|
||||
def sendLogin(self, userName):
|
||||
def sendLogin(self, userName, language):
|
||||
if self.ipc:
|
||||
self.ipc.sendLogin(userName)
|
||||
self.ipc.sendLogin(userName, language)
|
||||
|
||||
def sendLogout(self, userName):
|
||||
if self.ipc:
|
||||
|
@ -231,7 +231,7 @@ class OGASystemTray(QtGui.QSystemTrayIcon):
|
|||
self.modules[:] = validMods # copy instead of assignment
|
||||
|
||||
# If this is running, it's because he have logged in, inform service of this fact
|
||||
self.ipc.sendLogin(operations.getCurrentUser())
|
||||
self.ipc.sendLogin(operations.getCurrentUser(), operations.getSessionLanguage())
|
||||
|
||||
def deinitialize(self):
|
||||
for mod in reversed(self.modules): # Deinitialize reversed of initialization
|
||||
|
|
|
@ -65,7 +65,7 @@ from opengnsys.log import logger
|
|||
MSG_LOGOFF = 0xA1 # Request log off from an user
|
||||
MSG_MESSAGE = 0xB2
|
||||
MSG_POPUP = 0xB3
|
||||
MSG_SCRIPT = 0xC3
|
||||
MSG_SCRIPT = 0xC3
|
||||
|
||||
# Request messages
|
||||
REQ_MESSAGE = 0xD4
|
||||
|
@ -317,12 +317,12 @@ class ClientIPC(threading.Thread):
|
|||
msg = six.int2byte(msg) + six.int2byte(l & 0xFF) + six.int2byte(l >> 8) + data
|
||||
self.clientSocket.sendall(msg)
|
||||
|
||||
def sendLogin(self, username):
|
||||
self.sendRequestMessage(REQ_LOGIN, username)
|
||||
def sendLogin(self, username, language):
|
||||
self.sendRequestMessage(REQ_LOGIN, username+','+language)
|
||||
|
||||
def sendLogout(self, username):
|
||||
self.sendRequestMessage(REQ_LOGOUT, username)
|
||||
|
||||
|
||||
def sendMessage(self, module, message, data=None):
|
||||
'''
|
||||
Sends a message "message" with data (data will be encoded as json, so ensure that it is serializable)
|
||||
|
|
|
@ -35,6 +35,7 @@ import socket
|
|||
import platform
|
||||
import fcntl
|
||||
import os
|
||||
import locale
|
||||
import ctypes # @UnusedImport
|
||||
import ctypes.util
|
||||
import subprocess
|
||||
|
@ -157,6 +158,7 @@ def reboot(flags=0):
|
|||
else:
|
||||
subprocess.call(['/sbin/reboot'])
|
||||
|
||||
|
||||
def poweroff(flags=0):
|
||||
'''
|
||||
Simple poweroff using os command
|
||||
|
@ -173,7 +175,6 @@ def poweroff(flags=0):
|
|||
subprocess.call(['/sbin/poweroff'])
|
||||
|
||||
|
||||
|
||||
def logoff():
|
||||
'''
|
||||
Kills all curent user processes, which must send a logogof
|
||||
|
@ -270,9 +271,16 @@ def getCurrentUser():
|
|||
'''
|
||||
return os.environ['USER']
|
||||
|
||||
|
||||
def getSessionLanguage():
|
||||
'''
|
||||
Returns the user's session language
|
||||
'''
|
||||
return locale.getdefaultlocale()[0]
|
||||
|
||||
|
||||
def showPopup(title, message):
|
||||
'''
|
||||
Displays a message box on user's session (during 1 min).
|
||||
'''
|
||||
return subprocess.call('zenity --info --timeout 60 --title "{}" --text "{}"'.format(title, message), shell=True)
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import socket
|
|||
import platform
|
||||
import fcntl
|
||||
import os
|
||||
import locale
|
||||
import ctypes # @UnusedImport
|
||||
import ctypes.util
|
||||
import subprocess
|
||||
|
@ -238,10 +239,17 @@ def getCurrentUser():
|
|||
'''
|
||||
return os.environ['USER']
|
||||
|
||||
|
||||
def getSessionLanguage():
|
||||
'''
|
||||
Returns the user's session language
|
||||
'''
|
||||
return locale.getdefaultlocale()[0]
|
||||
|
||||
|
||||
def showPopup(title, message):
|
||||
'''
|
||||
Displays a message box on user's session (during 1 min).
|
||||
'''
|
||||
# Show a dialog using AppleSctipt
|
||||
return subprocess.call('/usr/bin/osascript -e \'display notification "{}" with title "{}"\''.format(message, title), shell=True)
|
||||
|
||||
|
|
|
@ -113,13 +113,14 @@ class OpenGnSysWorker(ServerWorker):
|
|||
def processClientMessage(self, message, data):
|
||||
logger.debug('Got OpenGnsys message from client: {}, data {}'.format(message, data))
|
||||
|
||||
def onLogin(self, user):
|
||||
def onLogin(self, userData):
|
||||
'''
|
||||
Sends session login notification to OpenGnsys server
|
||||
'''
|
||||
logger.debug('Received login for {}'.format(user))
|
||||
user, sep, language = userData.partition(',')
|
||||
logger.debug('Received login for {} with language {}'.format(user, language))
|
||||
self.loggedin = True
|
||||
self.REST.sendMessage('ogagent/loggedin', {'ip': self.interface.ip, 'user': user, 'ostype': operations.osType, 'osversion': operations.osVersion})
|
||||
self.REST.sendMessage('ogagent/loggedin', {'ip': self.interface.ip, 'user': user, 'language': language, 'ostype': operations.osType, 'osversion': operations.osVersion})
|
||||
|
||||
def onLogout(self, user):
|
||||
'''
|
||||
|
@ -241,4 +242,3 @@ class OpenGnSysWorker(ServerWorker):
|
|||
|
||||
def process_client_popup(self, params):
|
||||
self.REST.sendMessage('popup_done', params)
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import locale
|
||||
import subprocess
|
||||
import ctypes
|
||||
from ctypes.wintypes import DWORD, LPCWSTR
|
||||
|
@ -233,9 +234,16 @@ def getCurrentUser():
|
|||
'''
|
||||
return os.environ['USERNAME']
|
||||
|
||||
|
||||
def getSessionLanguage():
|
||||
'''
|
||||
Returns the user's session language
|
||||
'''
|
||||
return locale.getdefaultlocale()[0]
|
||||
|
||||
|
||||
def showPopup(title, message):
|
||||
'''
|
||||
Displays a message box on user's session (during 1 min).
|
||||
'''
|
||||
return subprocess.call('mshta "javascript:var sh=new ActiveXObject(\'WScript.Shell\'); sh.Popup( \'{}\', 60, \'{}\', 64); close()"'.format(message.encode('unicode_escape'), title.encode('unicode_escape')), shell=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue