Exemplo n.º 1
0
 def test_message_and_command_to_empty_group(self, *_):
     self.window.type = WIN_TYPE_GROUP
     self.window.window_contacts = []
     self.window.group.members = []
     user_input = get_input(self.window, self.settings)
     self.assertEqual(user_input.plaintext, 'clear')
     self.assertEqual(user_input.type, COMMAND)
Exemplo n.º 2
0
def input_loop(queues: Dict[bytes, 'Queue[bytes]'], settings: 'Settings',
               gateway: 'Gateway', contact_list: 'ContactList',
               group_list: 'GroupList', master_key: 'MasterKey',
               onion_service: 'OnionService', stdin_fd: int) -> NoReturn:
    """Get input from user and process it accordingly.

    Running this loop as a process allows handling different functions
    including inputs, key exchanges, file loading and assembly packet
    generation, separate from assembly packet output.
    """
    sys.stdin = os.fdopen(stdin_fd)
    window = TxWindow(contact_list, group_list)

    while True:
        with ignored(EOFError, FunctionReturn, KeyboardInterrupt):
            readline.set_completer(
                get_tab_completer(contact_list, group_list, settings, gateway))
            readline.parse_and_bind('tab: complete')

            window.update_window(group_list)

            while not onion_service.is_delivered:
                export_onion_service_data(contact_list, settings,
                                          onion_service, gateway)

            while not contact_list.has_local_contact():
                new_local_key(contact_list, settings, queues)

            while not contact_list.has_contacts():
                add_new_contact(contact_list, group_list, settings, queues,
                                onion_service)

            while not window.is_selected():
                window.select_tx_window(settings, queues, onion_service,
                                        gateway)

            user_input = get_input(window, settings)

            if user_input.type == MESSAGE:
                queue_message(user_input, window, settings, queues)

            elif user_input.type == FILE:
                queue_file(window, settings, queues)

            elif user_input.type == COMMAND:
                process_command(user_input, window, contact_list, group_list,
                                settings, queues, master_key, onion_service,
                                gateway)
Exemplo n.º 3
0
 def test_command(self, *_):
     user_input = get_input(self.window, self.settings)
     self.assertEqual(user_input.plaintext, 'clear')
     self.assertEqual(user_input.type, COMMAND)
Exemplo n.º 4
0
 def test_file(self, *_):
     user_input = get_input(self.window, self.settings)
     self.assertEqual(user_input.plaintext, '/file')
     self.assertEqual(user_input.type, FILE)
Exemplo n.º 5
0
 def test_message(self, *_):
     user_input = get_input(self.window, self.settings)
     self.assertEqual(user_input.plaintext, 'test_message')
     self.assertEqual(user_input.type, MESSAGE)