Beispiel #1
0
    def Init(self, main_screen):
        global bus, devices, adapter

        self._Page = BluetoothPage()
        self._Page._Dbus = bus
        self._Page._Devices = devices
        self._Page._Adapter = adapter

        self._Page._Screen = main_screen
        self._Page._Name = "Bluetooth"

        self._Page._Leader = self

        self._Page.Init()

        self._PairPage = BleAgentPairPage()
        self._PairPage._Screen = main_screen
        self._PairPage._Name = "Bluetooth"
        self._PairPage.Init()

        self._Page3 = Keyboard()
        self._Page3._Name = "Enter"
        self._Page3._Screen = main_screen
        self._Page3.Init()

        bus.add_signal_receiver(
            self._Page.DbusPropertiesChanged,
            dbus_interface="org.freedesktop.DBus.Properties",
            signal_name="PropertiesChanged",
            arg0="org.bluez.Device1",
            path_keyword="path")

        self.RegisterMyAgent()
Beispiel #2
0
class APIOBJ(object):

    _Page = None
    _PairPage = None
    _Page3 = None
    _Prompts = {}  # string key,string value
    _PromptType = None
    _MyAgent = None

    def __init__(self):
        self._Prompts["PIN"] = ""
        self._Prompts["PASS"] = ""

    def OnKbdReturnBackCb(self):
        if self._PromptType == None:
            return
        else:
            if self._PromptType in self._Prompts:
                inputed = "".join(self._Page3._Textarea._MyWords)
                self._Prompts[self._PromptType] = inputed

            self._PromptType = None  ##clear

    def Ask(self, prompt, prompt_type=None):

        self._Screen.PushPage(self._Page3)
        self._Page3.SetPassword("")
        self._Page3._Name = prompt
        self._Page3._Caller = self

        self._Screen.Draw()
        self._Screen.SwapAndShow()

        if prompt_type != None:
            self._PromptType = prompt_type

    def RegisterMyAgent(self):
        global AGENT_PATH, bus, devices, adapter

        capability = "KeyboardDisplay"
        self._MyAgent = BleAgent(bus, AGENT_PATH)
        self._MyAgent._Leader = self

        obj = bus.get_object(BUS_NAME, "/org/bluez")
        manager = dbus.Interface(obj, "org.bluez.AgentManager1")
        manager.RegisterAgent(AGENT_PATH, capability)
        print("BleAgent %s registered" % AGENT_PATH)

    def Init(self, main_screen):
        global bus, devices, adapter

        self._Page = BluetoothPage()
        self._Page._Dbus = bus
        self._Page._Devices = devices
        self._Page._Adapter = adapter

        self._Page._Screen = main_screen
        self._Page._Name = "Bluetooth"

        self._Page._Leader = self

        self._Page.Init()

        self._PairPage = BleAgentPairPage()
        self._PairPage._Screen = main_screen
        self._PairPage._Name = "Bluetooth"
        self._PairPage.Init()

        self._Page3 = Keyboard()
        self._Page3._Name = "Enter"
        self._Page3._Screen = main_screen
        self._Page3.Init()

        bus.add_signal_receiver(
            self._Page.DbusPropertiesChanged,
            dbus_interface="org.freedesktop.DBus.Properties",
            signal_name="PropertiesChanged",
            arg0="org.bluez.Device1",
            path_keyword="path")

        self.RegisterMyAgent()

    def API(self, main_screen):
        if main_screen != None:
            main_screen.PushPage(self._Page)
            main_screen.Draw()
            main_screen.SwapAndShow()