def get_messages_listing(self, name, max_list_count=1024, list_startoffset=0, filter_messageType=0, filter_readStatus=0, new_message=0): """Retrieves messages listing object from current folder""" logger.info("Requesting get_messages_listing with parameters %s", str(locals())) data = { "MaxListCount": headers.MaxListCount(max_list_count), "ListStartOffset": headers.ListStartOffset(list_startoffset), "FilterMessageType": headers.FilterMessageType(filter_messageType), "FilterReadStatus": headers.FilterReadStatus(filter_readStatus), "NewMessage": headers.NewMessage(new_message) } application_parameters = headers.App_Parameters(data, encoded=False) header_list = [headers.Type("x-bt/MAP-msg-listing")] if application_parameters.data: header_list.append(application_parameters) response = self.get(name, header_list) if not isinstance(response, tuple) and isinstance( response, responses.FailureResponse): logger.error( "get_messages_listing failed for bMessage '%s'. reason = %s", name, response) return return response
def push_message(self, name, file_name='0123', transparent=0, retry=1, charset=1): """Push a message to a folder of the MSE""" logger.info("Requesting push_message with parameters %s", str(locals())) data = { "Transparent": headers.Transparent(transparent), "Retry": headers.Retry(retry), "Charset": headers.Charset(charset) } file_path = sys.path[ 0] + os.sep + 'test' + os.sep + 'data' + os.sep + file_name application_parameters = headers.App_Parameters(data, encoded=False) header_list = [headers.Type("x-bt/message")] if application_parameters.data: header_list.append(application_parameters) with open(file_path, 'r') as f: file_data = f.readlines() response = self.put(name, ''.join(file_data), header_list) if not isinstance(response, tuple) and isinstance( response, responses.FailureResponse): logger.error("push bMessage to %s fail'. reason = %s", name, response) return return response logger.error(" Read bMessage data fail") return
def update_inbox(self, name=''): '''Initiate an update of the MSE's inbox''' logger.info("Requesting set_msg_status with parameters %s", str(locals())) header_list = [headers.Type("x-bt/MAP-messageUpdate")] response = self.put(name, '00', header_list=header_list) if not isinstance(response, tuple) and isinstance( response, responses.FailureResponse): logger.error( "Initiate an update of the MSE's inbox fail'. reason = %s", response) return return response
def get_folder_listing(self, max_list_count=1024, list_startoffset=0): """Retrieves folders list from current folder""" logger.info("Requesting get_folder_listing with appl parameters %s", str(locals())) data = { "MaxListCount": headers.MaxListCount(max_list_count), "ListStartOffset": headers.ListStartOffset(list_startoffset) } application_parameters = headers.App_Parameters(data, encoded=False) header_list = [headers.Type("x-obex/folder-listing")] if application_parameters.data: header_list.append(application_parameters) response = self.get(header_list=header_list) if not isinstance(response, tuple) and isinstance( response, responses.FailureResponse): logger.error("get_folder_listing failed. reason = %s", response) return return response
def set_msg_status(self, name='', status_indicator=1, status_value=''): '''Modify the status of a message on the MSE.''' logger.info("Requesting set_msg_status with parameters %s", str(locals())) data = { "StatusIndicator": headers.StatusIndicator(status_indicator), "StatusValue": headers.StatusValue(status_value) } application_parameters = headers.App_Parameters(data, encoded=False) header_list = [headers.Type("x-bt/messageStatus")] if application_parameters.data: header_list.append(application_parameters) response = self.put(name, '01', header_list=header_list) if not isinstance(response, tuple) and isinstance( response, responses.FailureResponse): logger.error( "Modify the status to %s of message %s fail'. reason = %s", name, status_value, response) return return response
def get_message(self, name, attachment=1, charset=1): """Retrieves a specific message from the MSE device""" logger.info("Requesting get_message with parameters %s", str(locals())) data = { "Attachment": headers.Attachment(attachment), "Charset": headers.Charset(charset) } application_parameters = headers.App_Parameters(data, encoded=False) header_list = [headers.Type("x-bt/message")] if application_parameters.data: header_list.append(application_parameters) response = self.get(name, header_list) if not isinstance(response, tuple) and isinstance( response, responses.FailureResponse): logger.error( "get_messages_listing failed for bMessage '%s'. reason = %s", name, response) return return response