# Make sure the requested contact exists if num_id >= len(self._contacts): raise InvalidContactIDError() return self._contacts[num_id].get_content() @dbus_method(_DIN_ENTRY, "s", "a{sv}", rel_path_keyword="rel_path") def GetMultipleFields(self, field_list, rel_path): num_id = int(rel_path[1:]) # Make sure the requested contact exists if num_id >= len(self._contacts): raise InvalidContactIDError() # Break the string up into a list fields = field_list.split(',') new_field_list = [] for field_name in fields: # Make sure the field list entries contain no spaces and aren't empty field_name = field_name.strip() if field_name: new_field_list.append(field_name) return self._contacts[num_id].get_fields(new_field_list) ### Initalization ### DomainManager.register_domain(ContactDomain())
#----------------------------------------------------------------------------# # Test domain manager #----------------------------------------------------------------------------# from domain_manager import DomainManager class DummyDomain(object): name = 'DummyDomain' def get_dbus_objects(self): yield self def register_backend(self, backend): pass dd = DummyDomain() # Try adding a dummy domain and make sure it gets listed DomainManager.init('') DomainManager.register_domain(dd) if DomainManager.get_domain_handler('DummyDomain') == dd: print "Domain registration OK" else: print "Domain registration FAILED" # Make sure the D-Bus object listing works, too obj_ok = False for obj in DomainManager.enumerate_dbus_objects(): if obj == dd: obj_ok = True if obj_ok: print "D-Bus domain object listing OK" else: print "D-Bus domain object listing FAILED"
@dbus_method(_DIN_ENTRY, "s", "", rel_path_keyword="rel_path") def MoveToFolder(self, new_folder_name, rel_path): """Moves a message into a specific folder, if it exists @param new_folder_name Name of new folder @param rel_path Relative part of D-Bus object path, e.g. '/4'""" num_id = int(rel_path[1:]) # Make sure the requested message exists if num_id >= len(self._messages): raise InvalidMessageIDError() message = self._messages[num_id] # Notify old folder of the move folder_name = message['Folder'] folder_id = self.get_folder_id_from_name(folder_name) folder = self._folders[folder_id] folder.notify_message_move(num_id, new_folder_name) # Register message with new folder message['Folder'] = new_folder_name folder_id = self.get_folder_id_from_name(new_folder_name) folder = self._folders[folder_id] folder.register_message(num_id) ### Initalization ### DomainManager.register_domain(MessageDomain())