Exemple #1
0
 def step_config_monitor_password_procede(self, curui):
     if curui.get_key() is not None and curui.get_key() == 'set_password':
         if self._change_pwd.get() == self._change_repwd.get():
             try:
                 self.change_pwd(self._change_pwd.get())
                 self._password = self._change_pwd.get()
                 msg = ui.Message(
                     self._get_message('configurePasswordUpdated'))
                 msg.next_step(self.step_menu_main)
                 return msg
             except:
                 return ui.ErrorDialog(
                     self._get_message('configureErrorConnection'))
         else:
             return ui.ErrorDialog(
                 self._get_message('configurePasswordErrNoMatch'))
     elif curui.get_key() is not None and curui.get_key(
     ) == 'remove_password':
         if curui.get_variable().get() == 'yes':
             try:
                 self.change_pwd("")
                 self._password = ""
                 msg = ui.Message(
                     self._get_message('configurePasswordUpdated'))
                 msg.next_step(self.step_menu_main)
                 return msg
             except:
                 return ui.ErrorDialog(
                     self._get_message('configureErrorConnection'))
Exemple #2
0
 def chat_with(self, id):
     self.CHAT_WITH = self.get_me() if id is 'me' else self.get_users(id)
     history = self.get_history(self.CHAT_WITH['username'])
     ui.msg_list.body = ui.ListWalker([])
     for message in history['messages'][::-1]:
         ui.msg_list.append_child(ui.Message(message))
     self.update_status_line()
Exemple #3
0
 def step_menu_main_selected(self, curui):
     if curui.get_variable().get() == "configureAgent":
         return self.step_menu_agent(curui)
     elif curui.get_variable().get() == "configureProxy":
         curui.set_key("menuProxy")
         return self.step_configure_proxy_type(curui)
     elif curui.get_variable().get() == "configureMonitor":
         return self.step_menu_monitor(curui)
     elif curui.get_variable().get() == "configureExit":
         return ui.Message(self._get_message('configureEnd'))
Exemple #4
0
 def step_menu_monitor_procede(self, curui):
     try:
         if curui.get_variable().get()=='yes':
             self.set_config("monitor_tray_icon", "True")
         else:
             self.set_config("monitor_tray_icon", "False")
         msg = ui.Message(self._get_message('configureTrayIconOK'))
         msg.next_step(self.step_menu_main)
         return msg
     except:
         return ui.ErrorDialog(self._get_message('configureErrorConnection'))
Exemple #5
0
 def step_menu_agent_disable_procede(self, curui):
     if curui.get_variable().get()=='yes':
         try:
             self.set_config("enabled", "False")
             msg = ui.Message(self._get_message('configureAgentDisabled'))
             msg.next_step(self.step_menu_main)
             return msg
         except:
                 return ui.ErrorDialog(self._get_message('configureErrorConnection'))
     else:
         return self.step_menu_agent(curui)
Exemple #6
0
 def step_menu_monitor_desktop_notification_procede(self, curui):
     try:
         self.set_config("monitor_desktop_notification",
                         curui.get_variable().get())
         msg = ui.Message(
             self._get_message('configureDesktopNotificationOK') + "\n\n" +
             self._get_message('warningLoginLogout'))
         msg.next_step(self.step_menu_main)
         return msg
     except:
         return ui.ErrorDialog(
             self._get_message('configureErrorConnection'))
Exemple #7
0
 def step_configure_proxy_set(self, curui):
     ar = curui.get_key().split('_')
     curui.set_key(ar[0])
     if len(ar) == 2 and ar[1] == 'tryAgain':
         if curui.get_variable() is not None and curui.get_variable().get(
         ) == 'configureLater':
             if curui.get_key() == "menuProxy":
                 return self.step_menu_main(curui)
             elif curui.get_key() == "installCode":
                 return self.step_menu_agent_install_key_selected(curui)
     try:
         if self._proxy_type.get() == 'HTTP' or self._proxy_type.get(
         ) == 'SOCKS4' or self._proxy_type.get(
         ) == 'SOCKS4A' or self._proxy_type.get() == 'SOCKS5':
             try:
                 int(self._proxy_port.get())
             except:
                 return ui.ErrorDialog(
                     self._get_message("validInteger").format(
                         self._get_message('proxyPort')))
         sret = self.send_req(
             "set_proxy", {
                 'type': self._proxy_type.get(),
                 'host': self._proxy_host.get(),
                 'port': self._proxy_port.get(),
                 'user': self._proxy_user.get(),
                 'password': self._proxy_password.get()
             })
         if sret != "OK":
             raise Exception(sret[6:])
     except:
         chs = ui.Chooser()
         chs.set_key(curui.get_key() + "_tryAgain")
         chs.set_message(self._get_message('errorConnectionConfig'))
         chs.add("noTryAgain", self._get_message('noTryAgain'))
         chs.add("configureLater", self._get_message('configureLater'))
         chs.set_variable(ui.VarString("noTryAgain"))
         if curui.get_key() == "menuProxy":
             chs.prev_step(self.step_menu_main)
         elif curui.get_key() == "installCode":
             chs.prev_step(self.step_menu_agent_install_key_selected)
         chs.next_step(self.step_configure_proxy_set)
         return chs
     if curui.get_key() == "menuProxy":
         msg = ui.Message(self._get_message('configureProxyEnd'))
         msg.next_step(self.step_menu_main)
         return msg
     elif curui.get_key() == "installCode":
         return self.step_check_install_code(curui)
Exemple #8
0
def updater():
    history.messages = []
    while True:
        messes = send(get_messages())["data"]
        for i in messes:
            recid = i[0]
            text = i[1]
            try:
                usr = users_dict[recid]
            except KeyError:
                usr = "******"
            msg = ui.Message(datetime.datetime.now(), usr, text)
            history.append(msg)

        history.redraw()
        sleep(1)
Exemple #9
0
 def step_check_install_code(self, curui):
     if curui.get_key() is not None and curui.get_key() == 'tryAgain':
         if curui.get_variable().get() == 'configureLater':
             return self.step_menu_main(curui)
         elif curui.get_variable().get() == 'configProxy':
             curui.set_key("installCode")
             return self.step_configure_proxy_type(curui)
         elif curui.get_variable().get() == 'reEnterCode':
             return self.step_menu_agent_install_key_selected(curui)
     msg = self._get_message('checkInstallCode')
     self._uinterface.wait_message(msg)
     key = self._install_code.get()
     try:
         self.install_key(key)
         msg = ui.Message(self._get_message('configureKeyInstalled'))
         msg.next_step(self.step_menu_main)
         return msg
     except Exception as e:
         s = str(e)
         if s == "INVALID_CODE":
             chs = ui.Chooser()
             chs.set_key("tryAgain")
             chs.set_message(self._get_message('errorInvalidCode'))
             chs.add("reEnterCode", self._get_message('reEnterCode'))
             chs.add("configureLater", self._get_message('configureLater'))
             chs.set_variable(ui.VarString("reEnterCode"))
             chs.prev_step(self.step_menu_agent_install_key_selected)
             chs.next_step(self.step_check_install_code)
             return chs
         elif s == "CONNECT_ERROR":
             chs = ui.Chooser()
             chs.set_key("tryAgain")
             chs.set_message(self._get_message('errorConnectionQuestion'))
             chs.add("configProxy", self._get_message('yes'))
             chs.add("noTryAgain", self._get_message('noTryAgain'))
             chs.add("configureLater", self._get_message('configureLater'))
             chs.set_variable(ui.VarString("noTryAgain"))
             chs.prev_step(self.step_menu_agent_install_key_selected)
             chs.next_step(self.step_check_install_code)
             return chs
         elif s == "REQUEST_TIMEOUT":
             return ui.ErrorDialog(
                 self._get_message('configureErrorConnection'))
         else:
             return ui.ErrorDialog(s)
Exemple #10
0
        history.redraw()
        sleep(1)


_start_curses()
layout = ui.Layout()
title = ui.Title(layout, screen)
history = ui.History(layout, screen)
prompt = ui.Prompt(layout, screen)

redraw()

if not (os.path.exists("config.cfg") and os.path.exists("op.Key")
        and os.path.exists("pr.Key")):
    history.append(ui.Message(datetime.datetime.now(), "Введи имя", ""))
    history.redraw()
    nam = prompt.getstr().decode('utf-8')
    history.messages = []
    history.redraw()
    config = configparser.ConfigParser()
    config.add_section("Chat")
    config.set("Chat", "username", nam)
    register(nam)
    config.set("Chat", "id", str(indent))
    with open("config.cfg", "w") as config_file:
        config.write(config_file)

if (os.path.exists("config.cfg") and os.path.exists("op.Key")
        and os.path.exists("pr.Key")):
    config = configparser.ConfigParser()
Exemple #11
0
def client_on_message(c, message):
    if message['chat']['type'] == client.PRIVATE:
        if message['chat']['username'] == client.CHAT_WITH['username']:
            ui.msg_list.append_child(ui.Message(message))
Exemple #12
0
def msg_line_on_enter(value):
    message = client.send_message(client.CHAT_WITH['username'], value)
    ui.msg_list.append_child(ui.Message(message, text=value))
    return 0