Dialog: manual PMS entry

This commit is contained in:
tomkat83 2017-07-16 16:57:57 +02:00
parent 7a9e0611ed
commit d1346b2cd6
4 changed files with 61 additions and 34 deletions

View file

@ -83,10 +83,35 @@ msgctxt "#30017"
msgid "Unauthorized for PMS"
msgstr ""
# Title of dialog for manual PMS connection
msgctxt "#30018"
msgid "Manually connect to PMS"
msgstr ""
# Button text for connect dialog
msgctxt "#30019"
msgid "PMS IP address or host name"
msgstr ""
# Button text for connect dialog
msgctxt "#30020"
msgid "Connect"
msgstr ""
# Button text for connect dialog
msgctxt "#30021"
msgid "Please fill in both server and port"
msgstr ""
msgctxt "#30022"
msgid "Advanced"
msgstr ""
# Used to show that PKC is currently trying to connect to a PMS
msgctxt "#30023"
msgid "Connecting to"
msgstr ""
msgctxt "#30024"
msgid "Username"
msgstr ""
@ -96,7 +121,7 @@ msgid "Display message if PMS goes offline"
msgstr ""
msgctxt "#30030"
msgid "Port Number"
msgid "Port number"
msgstr ""
msgctxt "#30031"

View file

@ -160,7 +160,7 @@ class ConnectManager(object):
dia.set_connect_manager(self.__connect)
dia.doModal()
if dia._is_connected():
if dia.is_connected():
return dia.get_server()
else:
raise RuntimeError("Server is not connected")

View file

@ -1,18 +1,17 @@
# -*- coding: utf-8 -*-
###############################################################################
from logging import getLogger
import os
from os.path import join
import xbmcgui
import xbmcaddon
import connect.connectionmanager as connectionmanager
from utils import language as lang
from utils import language as lang, tryEncode
import variables as v
###############################################################################
log = getLogger("PLEX."+__name__)
addon = xbmcaddon.Addon('plugin.video.plexkodiconnect')
CONN_STATE = connectionmanager.CONNECTIONSTATE
ACTION_PARENT_DIR = 9
@ -54,10 +53,10 @@ class ServerManual(xbmcgui.WindowXMLDialog):
self.cancel_button = self.getControl(CANCEL)
self.error_toggle = self.getControl(ERROR_TOGGLE)
self.error_msg = self.getControl(ERROR_MSG)
self.host_field = self._add_editcontrol(725, 400, 40, 500)
self.port_field = self._add_editcontrol(725, 525, 40, 500)
self.host_field = self._add_editcontrol(725, 325, 40, 500)
self.port_field = self._add_editcontrol(725, 450, 40, 500)
self.port_field.setText('8096')
self.port_field.setText('32400')
self.setFocus(self.host_field)
self.host_field.controlUp(self.cancel_button)
@ -78,7 +77,7 @@ class ServerManual(xbmcgui.WindowXMLDialog):
if not server or not port:
# Display error
self._error(ERROR['Empty'], lang(30617))
self._error(ERROR['Empty'], lang(30021))
log.error("Server or port cannot be null")
elif self._connect_to_server(server, port):
@ -97,14 +96,14 @@ class ServerManual(xbmcgui.WindowXMLDialog):
self.close()
def _add_editcontrol(self, x, y, height, width):
media = os.path.join(addon.getAddonInfo('path'), 'resources', 'skins', 'default', 'media')
media = tryEncode(join(
v.ADDON_PATH, 'resources', 'skins', 'default', 'media'))
control = xbmcgui.ControlEdit(0, 0, 0, 0,
label="User",
font="font10",
textColor="ffc2c2c2",
focusTexture=os.path.join(media, "button-focus.png"),
noFocusTexture=os.path.join(media, "button-focus.png"))
focusTexture=join(media, "button-focus.png"),
noFocusTexture=join(media, "button-focus.png"))
control.setPosition(x, y)
control.setHeight(height)
control.setWidth(width)
@ -115,11 +114,11 @@ class ServerManual(xbmcgui.WindowXMLDialog):
def _connect_to_server(self, server, port):
server_address = "%s:%s" % (server, port)
self._message("%s %s..." % (lang(30610), server_address))
self._message("%s %s..." % (lang(30023), server_address))
result = self.connect_manager.connectToAddress(server_address)
if result['State'] == CONN_STATE['Unavailable']:
self._message(lang(30609))
self._message(lang(30204))
return False
else:
self._server = result['Servers'][0]

View file

@ -43,34 +43,37 @@
</control>
<control type="image">
<description>Emby logo</description>
<description>Plex logo</description>
<texture>logo-white.png</texture>
<aspectratio>keep</aspectratio>
<width>120</width>
<height>49</height>
<top>30</top>
<left>25</left>
<top>20</top>
<left>0</left>
<aligny>left</aligny>
<align>left</align>
</control>
<control type="group">
<width>500</width>
<left>50</left>
<control type="label">
<description>Connect to server</description>
<label>$ADDON[plugin.video.emby 30614]</label>
<description>Connect to PMS</description>
<label>$ADDON[plugin.video.plexkodiconnect 30018]</label>
<textcolor>white</textcolor>
<font>font12</font>
<aligny>top</aligny>
<align>center</align>
<align>left</align>
<width>100%</width>
<top>100</top>
<top>30</top>
<left>60</left>
</control>
<control type="group">
<top>150</top>
<top>75</top>
<control type="label">
<description>Host</description>
<label>$ADDON[plugin.video.emby 30615]</label>
<description>PMS IP address or host name</description>
<label>$ADDON[plugin.video.plexkodiconnect 30019]</label>
<textcolor>ffa6a6a6</textcolor>
<font>font10</font>
<aligny>top</aligny>
@ -87,7 +90,7 @@
<control type="label">
<description>Host example</description>
<label>192.168.1.100 or https://myserver.com</label>
<label>https://192.168.1.2, https://myserver.com</label>
<textcolor>ff464646</textcolor>
<font>font10</font>
<aligny>top</aligny>
@ -97,10 +100,10 @@
<control type="group">
<description>Port</description>
<top>275</top>
<top>200</top>
<control type="label">
<description>Port label</description>
<label>$ADDON[plugin.video.emby 30030]</label>
<description>Port Number</description>
<label>$ADDON[plugin.video.plexkodiconnect 30030]</label>
<textcolor>ffa6a6a6</textcolor>
<font>font10</font>
<aligny>top</aligny>
@ -121,9 +124,9 @@
<top>380</top>
<control type="button" id="200">
<description>Connect</description>
<texturenofocus border="5" colordiffuse="ff0b8628">box.png</texturenofocus>
<texturefocus border="5" colordiffuse="ff13a134">box.png</texturefocus>
<label>[UPPERCASE][B]$ADDON[plugin.video.emby 30616][/B][/UPPERCASE]</label>
<texturenofocus border="5" colordiffuse="ff464646">box.png</texturenofocus>
<texturefocus border="5" colordiffuse="ff525252">box.png</texturefocus>
<label>$ADDON[plugin.video.plexkodiconnect 30020]</label>
<font>font10</font>
<textcolor>ffa6a6a6</textcolor>
<focusedcolor>white</focusedcolor>
@ -137,7 +140,7 @@
<description>Cancel</description>
<texturenofocus border="5" colordiffuse="ff464646">box.png</texturenofocus>
<texturefocus border="5" colordiffuse="ff525252">box.png</texturefocus>
<label>[UPPERCASE][B]$ADDON[plugin.video.emby 30606][/B][/UPPERCASE]</label>
<label>$ADDON[plugin.video.plexkodiconnect 30602]</label>
<font>font10</font>
<textcolor>ffa6a6a6</textcolor>
<focusedcolor>white</focusedcolor>