Skip to content

Commit

Permalink
obex_root and some minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lu-Fi committed Aug 11, 2013
1 parent 5b03309 commit e2d22b8
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 32 deletions.
Empty file modified .gitattributes
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.openelec.settings"
name="OpenELEC Configuration"
version="0.2.2"
version="0.2.3"
provider-name="OpenELEC">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
Expand Down
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2013-08-11 v0.2.3
(fix) samba menu entry
(fix) ssh default value
(fix) discovery error on exit
(add) some values added to defaults.py
(add) folder select option
(fix) obex_root default value added

2013-08-09 v0.2.2
(chg) some code cleanup
(add) make obex optional
Expand Down
4 changes: 4 additions & 0 deletions defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'OBEX_DAEMON' : '/usr/lib/bluetooth/obexd',
'BLUETOOTH_INIT' : '/etc/init.d/54_bluez',
'OBEX_INIT' : '/etc/init.d/55_obexd',
'OBEX_ROOT' : '/storage/downloads',
'ENABLED' : lambda:(True if os.path.exists(connman['BLUETOOTH_DAEMON']) else False),
}

Expand Down Expand Up @@ -98,6 +99,9 @@
'ENABLED' : True,
'KERNEL_CMD' : '/proc/cmdline',

#CLOCK
'SET_CLOCK_CMD' : '/sbin/hwclock --systohc --utc',

#LCD
'LCD_DRIVER_DIR' : '/usr/lib/lcdproc/',

Expand Down
48 changes: 39 additions & 9 deletions oe.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ def set_language(language):
__oe__ = sys.modules[globals()['__name__']]
_ = __addon__.getLocalizedString

#load_modules()

winOeMain = oeWindows.wizard('wizard.xml', __cwd__, 'Default',
oeMain=__oe__)

Expand All @@ -154,18 +152,48 @@ def set_language(language):
del winOeMain


def execute(command_line):
def execute(command_line, get_result=0):
try:

result = ''
dbg_log('oe::execute', 'enter_function', 0)

dbg_log('oe::execute::command', command_line, 0)

process = subprocess.Popen(command_line,
shell=True,
close_fds=True)
return result
if get_result == 0:
process = subprocess.Popen(command_line,
shell=True,
close_fds=True)

return process.pid
else:
result = ''
process = subprocess.Popen(command_line,
shell=True,
close_fds=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
for line in process.stdout.readlines():
result = result + line

return result

dbg_log('oe::execute', 'exit_function', 0)
except Exception, e:
dbg_log('oe::execute', 'ERROR: (' + repr(e) + ')')

def enable_service(service):
try:

if os.path.exists('%s/services/%s' % (CONFIG_CACHE, service)):
pass

if os.path.exists('%s/services/%s.disabled' % (CONFIG_CACHE, service)):
pass

service_file = '%s/services/%s' % (CONFIG_CACHE, service)
except Exception, e:
dbg_log('oe::set_service_cmd', 'ERROR: (' + repr(e) + ')')

def set_service_option(service, option, value):
try:

Expand All @@ -188,7 +216,6 @@ def set_service_option(service, option, value):
conf_file.write('\n'.join(lines) + '\n')

except Exception, e:

dbg_log('oe::set_service_option', 'ERROR: (' + repr(e) + ')')

def get_service_option(service, option, default=None):
Expand Down Expand Up @@ -950,6 +977,9 @@ def fixed_writexml(
configFile = '%s/userdata/addon_data/service.openelec.settings/oe_settings.xml' % XBMC_USER_HOME
if not os.path.exists('%s/userdata/addon_data/service.openelec.settings' % XBMC_USER_HOME):
os.makedirs('%s/userdata/addon_data/service.openelec.settings' % XBMC_USER_HOME)
if not os.path.exists('%s/services' % CONFIG_CACHE):
os.makedirs('%s/services' % CONFIG_CACHE)

except:
pass

Expand Down
16 changes: 11 additions & 5 deletions resources/lib/modules/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class bluetooth:
}}

ENABLED = False
OBEX_ROOT = None
OBEX_INIT = None
OBEX_DAEMON = None
BLUETOOTH_INIT = None
Expand Down Expand Up @@ -272,7 +273,8 @@ def start_discovery(self, listItem=None):
self.oe.set_busy(1)

self.dbusBluezAdapter.StartDiscovery()

self.discovering = True

self.oe.set_busy(0)

self.oe.dbg_log('bluetooth::start_discovery',
Expand All @@ -291,8 +293,10 @@ def stop_discovery(self, listItem=None):

self.oe.set_busy(1)

if self.dbusBluezAdapter != None:
if hasattr(self, 'discovering'):
del self.discovering
self.dbusBluezAdapter.StopDiscovery()


self.oe.set_busy(0)

Expand Down Expand Up @@ -756,7 +760,7 @@ def menu_connections(self, focusItem=None):
for dictProperty in dictProperties:
self.listItems[dbusDevice].setProperty(dictProperty,
dictProperties[dictProperty])

self.update_menu = False

self.oe.dbg_log('bluetooth::menu_connections',
Expand Down Expand Up @@ -928,11 +932,13 @@ def remove_signal_receivers(self):
signal_receiver.remove()
signal_receiver = None

#Remove will cause xbmc freeze
#bluez bug ?
#self.ObexNameOwnerWatch.cancel()
#self.ObexNameOwnerWatch = None

#self.NameOwnerWatch.cancel()
#self.NameOwnerWatch = None
self.NameOwnerWatch.cancel()
self.NameOwnerWatch = None

if hasattr(self, 'obAgent'):
self.remove_obex_agent()
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/modules/connman.py
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,8 @@ def set_technologie(self, **kwargs):
dbus.Boolean(False,
variant_level=1))
else:

xbmc.log("####" + repr(technologie['Powered']))

if technologie['Powered'] != False:
self.Technology.SetProperty('Powered',
dbus.Boolean(False, variant_level=1))
Expand Down
29 changes: 18 additions & 11 deletions resources/lib/modules/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
################################################################################
# -*- coding: utf-8 -*-
import os
import xbmc

class services:

Expand Down Expand Up @@ -203,7 +202,7 @@ def __init__(self, oeMain):
'name': 32385,
'value': None,
'action': 'init_bluetooth',
'type': 'text',
'type': 'folder',
'parent' : {'entry': 'obex_enabled',
'value': ['1']},
'InfoText': 752,
Expand All @@ -223,11 +222,11 @@ def __init__(self, oeMain):
def start_service(self):
try:

self.load_values()

self.oe.dbg_log('services::start_service', 'enter_function'
, 0)

self.load_values()

self.initialize_samba(service=1)
self.initialize_ssh(service=1)
self.initialize_avahi(service=1)
Expand Down Expand Up @@ -302,7 +301,7 @@ def load_values(self):

# read ssh settings from sshd_samba.conf
if os.path.isfile(self.SSH_DAEMON):
if self.oe.get_service_option('ssh', 'SSHD_START', 'true') == 'true':
if self.oe.get_service_option('ssh', 'SSHD_START', 'false') == 'true':
self.struct['ssh']['settings']['ssh_autostart']['value'] = '1'
else:
self.struct['ssh']['settings']['ssh_autostart']['value'] = '0'
Expand Down Expand Up @@ -332,7 +331,7 @@ def load_values(self):
else:
self.struct['samba']['settings']['samba_autostart']['value'] = '0'

if self.oe.get_service_option('samba', 'SAMBA_SECURE', 'true') == 'true':
if self.oe.get_service_option('samba', 'SAMBA_SECURE', 'false') == 'true':
self.struct['samba']['settings']['samba_secure']['value'] = '1'
else:
self.struct['samba']['settings']['samba_secure']['value'] = '0'
Expand Down Expand Up @@ -394,7 +393,8 @@ def load_values(self):
else:
self.struct['bluez']['settings']['obex_enabled']['value'] = '0'

tmpVal = self.oe.get_service_option('bluez', 'OBEXD_ROOT', self.oe.DOWNLOAD_DIR)
tmpVal = self.oe.get_service_option('bluez', 'OBEXD_ROOT',
self.oe.dictModules['bluetooth'].OBEX_ROOT)
if not tmpVal is None:
self.struct['bluez']['settings']['obex_root']['value'] = tmpVal
else:
Expand Down Expand Up @@ -424,7 +424,10 @@ def initialize_samba(self, **kwargs):

if self.struct['samba']['settings']['samba_autostart'
]['value'] != '1':


self.struct['samba']['settings']['samba_username']['hidden'] = True
self.struct['samba']['settings']['samba_password']['hidden'] = True

self.oe.set_service_option('samba',
'SAMBA_ENABLED',
'false')
Expand All @@ -439,6 +442,12 @@ def initialize_samba(self, **kwargs):

else:

if 'hidden' in self.struct['samba']['settings']['samba_username']:
del self.struct['samba']['settings']['samba_username']['hidden']

if 'hidden' in self.struct['samba']['settings']['samba_password']:
del self.struct['samba']['settings']['samba_password']['hidden']

self.oe.set_service_option('samba',
'SAMBA_ENABLED',
'true')
Expand Down Expand Up @@ -466,7 +475,7 @@ def initialize_samba(self, **kwargs):
'true')

else:

self.oe.set_service_option('samba',
'SAMBA_SECURE',
'false')
Expand Down Expand Up @@ -731,9 +740,7 @@ def init_bluetooth(self, **kwargs):
self.oe.dictModules['bluetooth'].disabled = False

if not 'service' in kwargs:
xbmc.log("NOSERVICE")
if 'bluetooth' in self.oe.dictModules:
xbmc.log("BTMODULEEEEEEEEE")
self.oe.dictModules['bluetooth'].stop_bluetoothd()
self.oe.dictModules['bluetooth'].start_bluetoothd()

Expand Down
6 changes: 4 additions & 2 deletions resources/lib/modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class system:
BACKUP_DESTINATION = None
RESTORE_DIR = None
GET_CPU_FLAG = None
SET_CLOCK_CMD = None

menu = {'1': {
'name': 32002,
Expand Down Expand Up @@ -621,10 +622,11 @@ def set_hdd_standby(self, listItem=None):

cmd_file.close()

blkid = self.oe.execute('blkid')
blkid = self.oe.execute('blkid', 1)
for volume in blkid.splitlines():

if ('LABEL="%s"' % sys_hdd) in volume or \
('LABEL=%s' % sys_hdd) in volume or \
('UUID="%s"' % sys_hdd) in volume:

sys_hdd_dev = volume.split(':')[0].replace('/dev/', '')
Expand Down Expand Up @@ -938,7 +940,7 @@ def set_hw_clock(self):

self.oe.dbg_log('system::set_hw_clock', 'enter_function', 0)

self.oe.execute('/sbin/hwclock --systohc --utc')
self.oe.execute(self.SET_CLOCK_CMD)

self.oe.dbg_log('system::set_hw_clock', 'exit_function', 0)
except Exception, e:
Expand Down
3 changes: 0 additions & 3 deletions resources/lib/modules/xdbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
# OpenELEC Licensing <license@openelec.tv> http://www.openelec.tv
################################################################################
# -*- coding: utf-8 -*-
import xbmc
import dbus
import gobject
import threading
Expand Down Expand Up @@ -138,10 +137,8 @@ def run(self):

module = self.oe.dictModules[strModule]

xbmc.log("MODULE: %s -> %s" % (strModule, str(module.ENABLED)))
if hasattr(module, 'monitor') and \
module.ENABLED:
xbmc.log("MOEP")
monitor = \
module.monitor(self.oe, module)
monitor.add_signal_receivers()
Expand Down
18 changes: 18 additions & 0 deletions resources/lib/oeWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ def onClick(self, controlID):
if xbmcKeyboard.isConfirmed():
selectedItem.setProperty('value',
xbmcKeyboard.getText())

elif strTyp == 'file':

xbmcDialog = xbmcgui.Dialog()
Expand All @@ -397,6 +398,23 @@ def onClick(self, controlID):
if returnValue != '' and returnValue != '/':
selectedItem.setProperty('value',
unicode(returnValue))

elif strTyp == 'folder':

xbmcDialog = xbmcgui.Dialog()
returnValue = xbmcDialog.browse(
0,
'OpenELEC.tv',
'files',
'',
False,
False,
'/storage',
)
if returnValue != '' and returnValue != '/':
selectedItem.setProperty('value',
unicode(returnValue))

elif strTyp == 'ip':

xbmcDialog = xbmcgui.Dialog()
Expand Down

0 comments on commit e2d22b8

Please sign in to comment.