예제 #1
0
 def CallGetCurrentItemUrl(self):
     proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, SERVICE_NAME, SERVICE_PATH, self.session_id)
     iface = self.bus.GetInterface("net.allplay.MCU")
     proxyBusObject.AddInterface(iface)
     replyMsg = Message.Message(g_bus)
     proxyBusObject.MethodCall('net.allplay.MCU', "GetCurrentItemUrl", None, 0, replyMsg, 25000, 0)
     return replyMsg.GetArg(0).GetString()
    def __init__(self, bus_attachment, bus_name, session_id, device_name, device_id):
        self.bus = bus_attachment
        self.bus_name = bus_name
        self.session_id = session_id
        self.device_name = device_name
        self.device_id = device_id

        self.proxyBusObject = ProxyBusObject.ProxyBusObject(
            self.bus, self.bus_name, SERVICE_PATH, self.session_id)
        self.proxyBusObject.IntrospectRemoteObject()

        iface = self.proxyBusObject.GetInterface('net.allplay.ZoneManager')
        success, zoneChangedSignal = iface.GetSignal('OnZoneChanged')
        self.bus.RegisterSignalHandler(MessageReceiver.MessageReceiverSignalHandlerFuncType(
             AllPlayer.OnZoneChanged), zoneChangedSignal, None)

        iface = self.proxyBusObject.GetInterface('net.allplay.MediaPlayer')

        # success, playStateChangedSignal = iface.GetSignal('PlayStateChanged')
        # self.playStateChangedFuncPtr = MessageReceiver.MessageReceiverSignalHandlerFuncType(self._OnPlayStateChanged())
        # self.bus.RegisterSignalHandler(self.playStateChangedFuncPtr, playStateChangedSignal, None)

        # Not present. Think it may be internal
        success, endOfPlaybackSignal = iface.GetSignal('EndOfPlayback')
        self.endOfPlaybackFuncPtr = MessageReceiver.MessageReceiverSignalHandlerFuncType(self._OnEndOfPlayback())
        self.bus.RegisterSignalHandler(self.endOfPlaybackFuncPtr, endOfPlaybackSignal, None)
예제 #3
0
    def GetAboutData(self):
        proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, SERVICE_NAME, "/About", self.session_id)
        iface = self.bus.GetInterface("org.alljoyn.About")
        proxyBusObject.AddInterface(iface)

        #     <method name="GetAboutData">
        #       <arg name="languageTag" type="s" direction="in"/>
        #       <arg name="aboutData" type="a{sv}" direction="out"/>
        #     </method>

        languageTag = MsgArg.MsgArg()
        languageTag.SetString("en")
        replyMsg = Message.Message(g_bus)
        proxyBusObject.MethodCall('org.alljoyn.About', "GetAboutData", languageTag, 1, replyMsg, 25000, 0)
        arg = replyMsg.GetArg(0)

        # Todo Tidy up MsgArg code. Could there be a way to dynamically create types based on the dbus signature ?
        num = C.c_uint()
        entries = MsgArg.MsgArg()
        arg.Get("a{sv}", [C.POINTER(C.c_uint), C.POINTER(MsgArg.MsgArgHandle)], [C.byref(num), C.byref(entries.handle)])
       
        for i in range(num.value):
            key = C.c_char_p()
            value_string = C.c_char_p()
            element = entries.ArrayElement(i)
            
            try:
                element.Get("{ss}", [C.POINTER(C.c_char_p), C.POINTER(C.c_char_p)], [C.byref(key), C.byref(value_string)])
                self.device_details[key.value] = value_string.value
            except QStatusException as ex:
                pass
예제 #4
0
 def SetMute(self):
     proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, SERVICE_NAME, SERVICE_PATH, self.session_id)
     iface = self.bus.GetInterface("org.alljoyn.Control.Volume")
     proxyBusObject.AddInterface(iface)
     param = MsgArg.MsgArg()
     param.SetBool(True)
     proxyBusObject.GetProperty("org.alljoyn.Control.Volume", "Mute", param)
예제 #5
0
   def PlayUrl(self):
       proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, SERVICE_NAME, SERVICE_PATH, self.session_id)
       iface = self.bus.GetInterface("net.allplay.MCU")      
       proxyBusObject.AddInterface(iface)
 
       inputs = MsgArg.MsgArg.ArrayCreate(7)
       inputs.ArraySet(7, "ssssxss", [C.c_char_p, C.c_char_p, C.c_char_p, C.c_char_p,  C.c_longlong, C.c_char_p, C.c_char_p],
                           ['http://192.168.1.149:8000/test.mp3', 'Dummy', 'Dummy', 'Dummy', 200, 'Dummy', 'Dummy'])
       
       proxyBusObject.MethodCallNoReply('net.allplay.MCU', "PlayItem", inputs, 7, 0)
예제 #6
0
    def AdjustVolumePercent(self, percent):
        proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, "SERVICE_NAME", SERVICE_PATH, self.session_id)
        iface = self.bus.GetInterface("org.alljoyn.Control.Volume")      
        proxyBusObject.AddInterface(iface)
  
        percent = min(max(0.0, percent), 100.0)

        param = MsgArg.MsgArg()
        param.SetDouble(percent)

        proxyBusObject.MethodCallNoReply("org.alljoyn.Control.Volume", "AdjustVolumePercent", param, 1, 0)
예제 #7
0
    def __init__(self, bus_attachment, bus_name, session_id, device_name,
                 device_id):
        self.bus = bus_attachment
        self.bus_name = bus_name
        self.session_id = session_id
        self.device_name = device_name
        self.device_id = device_id

        # if not AllPlayer.proxyBusObject:
        #     AllPlayer.proxyBusObject = ProxyBusObject.ProxyBusObject(
        #         self.bus, self.bus_name, SERVICE_PATH, self.session_id)
        #     AllPlayer.proxyBusObject.IntrospectRemoteObject()

        self.proxyBusObject = ProxyBusObject.ProxyBusObject(
            self.bus, self.bus_name, SERVICE_PATH, self.session_id)
        self.proxyBusObject.IntrospectRemoteObject()
예제 #8
0
    def CreateInterfaces(self):
        #AddMember(self, message_type, name, inputSig, outSig, argNames, annotation):

        iface = self.bus.CreateInterface("net.allplay.MCU")
        iface.AddMember(Message.MessageType.ALLJOYN_MESSAGE_METHOD_CALL, "GetCurrentItemUrl", None,  "s", None, 0)
        iface.AddMember(Message.MessageType.ALLJOYN_MESSAGE_METHOD_CALL, "PlayItem", "ssssxss", None, None, 0)
        iface.AddMember(Message.MessageType.ALLJOYN_MESSAGE_METHOD_CALL, "AdvanceLoopMode", None, None, None, 0)
        iface.AddMember(Message.MessageType.ALLJOYN_MESSAGE_METHOD_CALL, "ToggleShuffleMode", None, None, None, 0)
        iface.Activate()

        iface = self.bus.CreateInterface("org.alljoyn.Control.Volume")
        
        iface.AddMember(Message.MessageType.ALLJOYN_MESSAGE_METHOD_CALL, "AdjustVolumePercent", "d", None, None, 0)
        
        iface.AddProperty('Mute', 'b', InterfaceDescription.ALLJOYN_PROP_ACCESS_RW)

        iface.Activate()


        iface = self.bus.CreateInterface("net.allplay.ZoneManager")
        iface.AddSignal("OnZoneChanged", "sia{si}", "zoneId,timestamp,slaves", 0, None)
        iface.Activate()


        proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, SERVICE_NAME, SERVICE_PATH, self.session_id)
        iface = self.bus.GetInterface("net.allplay.ZoneManager")
        proxyBusObject.AddInterface(iface)

        interfaceMember = iface.GetSignal('OnZoneChanged')
 
        print "interfaceMember", interfaceMember.Signature

        # u'GetSignal': (u'alljoyn_interfacedescription_getsignal',
        #                         (u'int', C.c_int),
        #                         ((u'alljoyn_interfacedescription', InterfaceDescriptionHandle),
        #                          (u'const char *', C.c_char_p),
        #                          (u'alljoyn_interfacedescription_member *', POINTER(InterfaceDescriptionMember)))),



        self.bus.RegisterSignalHandler(MessageReceiver.MessageReceiverSignalHandlerFuncType(AllPlayer.OnZoneChanged), interfaceMember, None)
예제 #9
0
    def OnAboutListenerCallBack(self, context, busName, version, port, objectDescriptionArg, aboutDataArg):

        global s_interrupt

        objectDescription = AboutObjectDescription.AboutObjectDescription(objectDescriptionArg)

        print objectDescription.GetPaths()

        aboutData = AboutData.AboutData(aboutDataArg, language="en")

        print {f:aboutData.GetField(f).GetSingleCompleteValue() for f in aboutData.GetFields()}

        #self.printAboutData(aboutData, None, 2)

        print "*********************************************************************************"

        opts = Session.SessionOpts(Session.ALLJOYN_TRAFFIC_TYPE_MESSAGES,
                                   False,
                                   Session.ALLJOYN_PROXIMITY_ANY,
                                   TransportMask.ALLJOYN_TRANSPORT_ANY)

        self.bus.EnableConcurrentCallBacks()
        sessionId = self.bus.JoinSession(busName, port, self.sessionListener, opts)

        aboutProxy = AboutProxy.AboutProxy(self.bus, busName, sessionId)

        objArg = aboutProxy.GetObjectDescription()

        aboutObjectDescription = AboutObjectDescription.AboutObjectDescription(objArg)

        for path in aboutObjectDescription.GetPaths():
            print "\t", path
            for interface in aboutObjectDescription.GetInterfaces(path):
                print "\t\t", interface

        proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, busName, '/net/allplay/MediaPlayer', sessionId)
           
        try:
            proxyBusObject.IntrospectRemoteObject()
        except QStatusException, ex:
            print "Failed to introspect remote object."
예제 #10
0
    def OnAboutListenerCallBack(self, context, busName, version, port,
                                objectDescriptionArg, aboutDataArg):
        objectDescription = AboutObjectDescription.AboutObjectDescription(
            objectDescriptionArg)

        aboutData = AboutData.AboutData(aboutDataArg, language="en")

        print "Device Name", aboutData.GetDeviceName()

        opts = Session.SessionOpts(Session.ALLJOYN_TRAFFIC_TYPE_MESSAGES,
                                   False, Session.ALLJOYN_PROXIMITY_ANY,
                                   TransportMask.ALLJOYN_TRANSPORT_ANY)

        g_bus.EnableConcurrentCallBacks()
        sessionId = g_bus.JoinSession(busName, port, self.sessionListener,
                                      opts)

        aboutProxy = AboutProxy.AboutProxy(g_bus, busName, sessionId)

        objArg = aboutProxy.GetObjectDescription()

        aboutObjectDescription = AboutObjectDescription.AboutObjectDescription(
            objArg)

        for path in aboutObjectDescription.GetPaths():
            print "\t ObjectPath: ", path
            for interface in aboutObjectDescription.GetInterfaces(path):
                print "\t\t", interface

        proxyBusObject = ProxyBusObject.ProxyBusObject(g_bus, busName,
                                                       '/About', sessionId)

        try:
            proxyBusObject.IntrospectRemoteObject()
            iface = proxyBusObject.GetInterface("org.alljoyn.About")
            print iface.Introspect()
        except QStatusException, ex:
            print "Failed to introspect remote object."
예제 #11
0
    def OnAboutListenerCallBack(self, context, busName, version, port,
                                objectDescriptionArg, aboutDataArg):

        print "BusName", busName

        print "objectDescriptionArg", objectDescriptionArg, type(
            objectDescriptionArg)
        print "aboutDataArg", aboutDataArg, type(aboutDataArg)

        objectDescription = AboutObjectDescription.AboutObjectDescription(
            objectDescriptionArg)

        print "*********************************************************************************"
        print "Announce signal discovered"
        print "\tFrom bus", busName
        print "\tAbout version", version
        print "\tSessionPort", port
        print "\tObjectDescription:"
        print "*********************************************************************************"
        print "Announce signal discovered"

        for path in objectDescription.GetPaths():
            print "\t\t", path
            for interface in objectDescription.GetInterfaces(path):
                print "\t\t\t", interface

        print "\tAboutData:"
        aboutData = AboutData.AboutData(aboutDataArg, language="en")

        self.printAboutData(aboutData, None, 2)

        print "*********************************************************************************"

        opts = Session.SessionOpts(Session.ALLJOYN_TRAFFIC_TYPE_MESSAGES,
                                   False, Session.ALLJOYN_PROXIMITY_ANY,
                                   TransportMask.ALLJOYN_TRANSPORT_ANY)

        self.bus_attachment.EnableConcurrentCallBacks()

        print "JoiningSession", "busName", busName, "port", port, "opts", opts
        sessionId = self.bus_attachment.JoinSession(busName, port,
                                                    self.sessionListener, opts)
        print "SessionJoined sessionId = ", sessionId

        aboutProxy = AboutProxy.AboutProxy(self.bus_attachment, busName,
                                           sessionId)

        objArg = aboutProxy.GetObjectDescription()
        print "*********************************************************************************"
        print "AboutProxy.GetObjectDescription:"

        aboutObjectDescription = AboutObjectDescription.AboutObjectDescription(
            objArg)

        for path in aboutObjectDescription.GetPaths():
            print "\t", path
            for interface in aboutObjectDescription.GetInterfaces(path):
                print "\t\t", interface

        aArg = aboutProxy.GetAboutData()
        print "*********************************************************************************"
        print "AboutProxy.GetAboutData: (Default Language)"

        defaultLangAboutData = AboutData.AboutData()
        self.printAboutData(defaultLangAboutData, None, 1)

        defaultLanguage = defaultLangAboutData.GetDefaultLanguage()
        # Print out the AboutData for every language but the default it has already been printed.

        for lang in defaultLangAboutData.GetSupportedLanguages():
            if lang != defaultLanguage:
                aArg = aboutProxy.GetAboutData(language=lang)
                printAboutData(aArg, lang, 1)
            ver = aboutProxy.GetVersion()
            print "*********************************************************************************"
            print "AboutProxy.GetVersion %hd" % (ver, )
            print "*********************************************************************************"
            path = objectDescription.GetInterfacePaths(INTERFACE_NAME)[0]
            print "Calling %s/%s" % (path, INTERFACE_NAME)
            print "busName", busName, type(busName)
            print "path", path, type(path)
            print "sessionId", sessionId, type(sessionId)
            proxyBusObject = ProxyBusObject.ProxyBusObject(
                g_bus, busName, path, sessionId)

            print "proxyBusObject", proxyBusObject
            try:
                proxyBusObject.IntrospectRemoteObject()
            except QStatusException, ex:
                print "Failed to introspect remote object."

            arg = MsgArg.MsgArg()
            arg.SetString("ECHO Echo echo...")

            replyMsg = Message.Message(self.bus_attachment)

            proxyBusObject.MethodCall(INTERFACE_NAME, "Echo", arg, 1, replyMsg,
                                      25000, 0)

            print "Echo method reply:", replyMsg.GetArg(0).GetString()
예제 #12
0
 def ToggleShuffleMode(self):
     proxyBusObject = ProxyBusObject.ProxyBusObject(self.bus, SERVICE_NAME, SERVICE_PATH, self.session_id)
     iface = self.bus.GetInterface("net.allplay.MCU")
     proxyBusObject.AddInterface(iface)
     proxyBusObject.MethodCallNoReply('net.allplay.MCU', "ToggleShuffleMode", None, 0, 0)