'Operations processed while running a TUI session of `Hosts Setup
Utility`.
:return: A flag indicating whether to reload the current session or
all operations have been finished. The return value could only be
`0` or `1`. To be specific:
flag  operation
0     Finish
1     Reload
.. note:: Reload operation is called only when a new data file is
retrieved from server.
:rtype: int
.. note:: IF hosts data file does not exists in current working
directory, a warning message box would popup. And operations to
change the hosts file on current system could be done only until
a new data file has been downloaded.'

def session_daemon(self):

    screen = self._stdscr.subwin(0, 0, 0, 0)
    screen.keypad(1)
    self.banner()
    self.footer()
    key_in = None
    tab = 0
    pos = 0
    tab_entry = [self.configure_settings, self.select_func]
    while (key_in != 27):
        self.setup_menu()
        self.status()
        self.process_bar(0, 0, 0, 0)
        for (i, sec) in enumerate(tab_entry):
            tab_entry[i]((pos if (i == tab) else None))
        if (key_in is None):
            test = self.settings[0][2][0]['test_url']
            self.check_connection(test)
        key_in = screen.getch()
        if (key_in == 9):
            if (self.choice == [[], []]):
                tab = 0
            else:
                tab = (not tab)
            pos = 0
        elif (key_in in self._hot_keys):
            pos = tab_entry[tab](pos, key_in)
        elif (key_in in self._ops_keys):
            if (key_in == curses.KEY_F10):
                if (self._funcs == [[], []]):
                    self.messagebox('No    data    file    found!    Press    F6    to    get    data    file    first.', 1)
                else:
                    msg = 'Apply    Changes    to    hosts    file?'
                    confirm = self.messagebox(msg, 2)
                    if confirm:
                        self.set_config_bytes()
                        self.make_mode = 'system'
                        maker = MakeHosts(self)
                        maker.make()
                        self.move_hosts()
            elif (key_in == curses.KEY_F5):
                self._update = self.check_update()
            elif (key_in == curses.KEY_F6):
                if (self._update == {}):
                    self._update = self.check_update()
                if self.new_version():
                    self.fetch_update()
                    return 1
                else:
                    self.messagebox('Data    file    is    up-to-date!', 1)
            else:
                pass
    return 0
