Ejemplo n.º 1
0
	def httpGetInfo(self, filename, fileInfo):
		self.manager.log.debug('httpGetInfo: ' + filename)

		if not filename or not fileInfo:
			return -1

		# We need to remove the web handle part of the filename. So for example the
		# filename that was passed in could be '/web/cds.xml'. We need to make that
		# be just 'cds.xml'. If the file that was requested is '/web/movies/awesome.mp4'
		# this should be made into 'movies/awesome.mp4'.
		filename = filename.lstrip(self.manager.webRoot)

		if filename == CDSService.CDS_LOCATION:
			self.setInfoFile(fileInfo, len(CDSService.CDS_DESCRIPTION), 'text/xml')
			return 0

		if filename == CMSService.CMS_LOCATION:
			self.setInfoFile(fileInfo, len(CMSService.CMS_DESCRIPTION), 'text/xml')
			return 0

		if filename == MSRService.MSR_LOCATION:
			self.setInfoFile(fileInfo, len(MSRService.MSR_DESCRIPTION), 'text/xml')
			return 0

		upnpID = int(filename[filename.rfind('/') + 1:filename.rfind('.')])
		self.manager.log.debug('GetInfo for ' + str(upnpID))
		
		entry = self.manager.rootEntry.getChild(upnpID)
		if not entry:
			return -1

		if not entry.fullPath:
			return -1

		fileInfo.contents.is_readable = 1;
		fileInfo.contents.file_length = entry.size
		fileInfo.contents.last_modified = 1 #TODO: Modify entry to have a last_modified attribute
		fileInfo.contents.is_directory = 0 if entry.children is None else len(entry.children) + 1

		self.manager.log.debug("is_readable: {0}, file_length: {1}, last_modified {2}, is_directory {3}".format(fileInfo.contents.is_readable, fileInfo.contents.file_length, fileInfo.contents.last_modified, fileInfo.contents.is_directory))
		
		protocol = self.manager.idlna.dlna_write_protocol_info(
									 DLNAInterface.dlna_protocol_info_type_t['DLNA_PROTOCOL_INFO_TYPE_HTTP'],
									 DLNAInterface.dlna_org_play_speed_t['DLNA_ORG_PLAY_SPEED_NORMAL'],
									 DLNAInterface.dlna_org_conversion_t['DLNA_ORG_CONVERSION_NONE'],
									 DLNAInterface.dlna_org_operation_t['DLNA_ORG_OPERATION_RANGE'],
									 DLNAInterface.flags,
									 entry.dlnaProfile)


		content_type = protocol.split(':')[2]
		
		ct = ixmlCloneDOMString(content_type)
		self.manager.log.debug("Content Type :{0}".format(content_type))
		fileInfo.contents.content_type = ct
		return 0
Ejemplo n.º 2
0
    def httpGetInfo(self, filename, fileInfo):
        self.manager.log.debug('httpGetInfo: ' + filename)

        if not filename or not fileInfo:
            return -1

        # We need to remove the web handle part of the filename. So for example the
        # filename that was passed in could be '/web/cds.xml'. We need to make that
        # be just 'cds.xml'. If the file that was requested is '/web/movies/awesome.mp4'
        # this should be made into 'movies/awesome.mp4'.
        filename = filename.lstrip(self.manager.webRoot)

        if filename == CDSService.CDS_LOCATION:
            self.setInfoFile(fileInfo, len(CDSService.CDS_DESCRIPTION),
                             'text/xml')
            return 0

        if filename == CMSService.CMS_LOCATION:
            self.setInfoFile(fileInfo, len(CMSService.CMS_DESCRIPTION),
                             'text/xml')
            return 0

        if filename == MSRService.MSR_LOCATION:
            self.setInfoFile(fileInfo, len(MSRService.MSR_DESCRIPTION),
                             'text/xml')
            return 0

        upnpID = int(filename[filename.rfind('/') + 1:filename.rfind('.')])
        self.manager.log.debug('GetInfo for ' + str(upnpID))

        entry = self.manager.rootEntry.getChild(upnpID)
        if not entry:
            return -1

        if not entry.fullPath:
            return -1

        fileInfo.contents.is_readable = 1
        fileInfo.contents.file_length = entry.size
        fileInfo.contents.last_modified = 1  #TODO: Modify entry to have a last_modified attribute
        fileInfo.contents.is_directory = 0 if entry.children is None else len(
            entry.children) + 1

        self.manager.log.debug(
            "is_readable: {0}, file_length: {1}, last_modified {2}, is_directory {3}"
            .format(fileInfo.contents.is_readable,
                    fileInfo.contents.file_length,
                    fileInfo.contents.last_modified,
                    fileInfo.contents.is_directory))

        protocol = self.manager.idlna.dlna_write_protocol_info(
            DLNAInterface.
            dlna_protocol_info_type_t['DLNA_PROTOCOL_INFO_TYPE_HTTP'],
            DLNAInterface.dlna_org_play_speed_t['DLNA_ORG_PLAY_SPEED_NORMAL'],
            DLNAInterface.dlna_org_conversion_t['DLNA_ORG_CONVERSION_NONE'],
            DLNAInterface.dlna_org_operation_t['DLNA_ORG_OPERATION_RANGE'],
            DLNAInterface.flags, entry.dlnaProfile)

        content_type = protocol.split(':')[2]

        ct = ixmlCloneDOMString(content_type)
        self.manager.log.debug("Content Type :{0}".format(content_type))
        fileInfo.contents.content_type = ct
        return 0
Ejemplo n.º 3
0
 def setInfoFile(self, info, length, contentType):
     info.contents.file_length = length
     info.contents.last_modified = 0
     info.contents.is_directory = 0
     info.contents.is_readable = 1
     info.contents.content_type = ixmlCloneDOMString(contentType)
Ejemplo n.º 4
0
	def setInfoFile(self, info, length, contentType):
		info.contents.file_length = length
		info.contents.last_modified = 0
		info.contents.is_directory = 0
		info.contents.is_readable = 1
		info.contents.content_type = ixmlCloneDOMString(contentType)