From 0ae60337a7a3dad9a6e79dc46fb8ac383ccbd227 Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Sat, 16 Jun 2007 21:14:16 +0200 Subject: [PATCH] Proxy work --- galtack_client.py | 31 ++++++++++++++++++++----------- galtack_proxy.py | 50 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/galtack_client.py b/galtack_client.py index 8df05e1..1f8246a 100755 --- a/galtack_client.py +++ b/galtack_client.py @@ -105,7 +105,7 @@ class WindowF12RawConsoleMixin(Window): """ def __init__(self, *a, **kw): - super(WindowF12RawConsoleMixin, self).__init__(*a, **kw) + super(WindowF12RawConsoleMixin, self).__init__() self.connect("key-press-event", self.__cb_key_press_event) def __cb_key_press_event(self, window, event): @@ -183,7 +183,9 @@ class GaltackChatWindow(WindowF12RawConsoleMixin): protocol. """ - def __init__(self, options, user_info, server_info): + def __init__(self, prev_window, options, user_info, server_info): + self.__class__._instance = self + self.__prev_window = prev_window self.__options = options self.__user_info = user_info self.__server_info = server_info @@ -249,8 +251,8 @@ class GaltackChatWindow(WindowF12RawConsoleMixin): deferred.addErrback(self.__eb_left) def __cb_left(self, ignored_arg): - # GaltackLoginWindow._instance.show() - GaltackServerListWindow._instance.show() + # GaltackServerListWindow._instance.show() + self.__prev_window.show() self.destroy() def __eb_left(self, ignored_arg): @@ -292,7 +294,11 @@ class GaltackServerListWindow(WindowF12RawConsoleMixin): Window displaying the list of Galcon servers. """ - def __init__(self, options, user_info): + NEXT_CLASS = GaltackChatWindow + + def __init__(self, prev_window, options, user_info): + self.__class__._instance = self + self.__prev_window = prev_window self.__options = options super(GaltackServerListWindow, self).__init__() self.__user_info = user_info @@ -419,7 +425,8 @@ class GaltackServerListWindow(WindowF12RawConsoleMixin): self.join_with_server_info(server_info) def __cb_back(self, button): - GaltackLoginWindow._instance.show() + # self.GaltackLoginWindow._instance.show() + self.__prev_window.show() self.destroy() def __run_server_password_prompt(self, server_info): @@ -434,8 +441,8 @@ class GaltackServerListWindow(WindowF12RawConsoleMixin): self.join_with_server_info(server_info) def join_with_server_info(self, server_info): - chat_window = GaltackChatWindow(self.__options, - self.__user_info, server_info) + chat_window = self.NEXT_CLASS(self, self.__options, + self.__user_info, server_info) gobject.idle_add(self.hide) @@ -443,8 +450,11 @@ class GaltackLoginWindow(WindowF12RawConsoleMixin): """ A Window asking the user for Galcon login details and log in. """ + + NEXT_CLASS = GaltackServerListWindow def __init__(self, options): + self.__class__._instance = self self.__options = options super(GaltackLoginWindow, self).__init__() self.set_title("GalTacK Login") @@ -516,8 +526,7 @@ class GaltackLoginWindow(WindowF12RawConsoleMixin): main_loop_quit() def __server_list_callback(self, (current_version, server_info_list)): - w = GaltackServerListWindow(self.__options, self.__get_user_info()) - GaltackServerListWindow._instance = w + w = self.NEXT_CLASS(self, self.__options, self.__get_user_info()) w.set_current_version(current_version) w.set_server_info_list(server_info_list) gobject.idle_add(self.hide) @@ -556,7 +565,7 @@ def main(argv): option_parser = GaltackLoginWindow._modify_option_parser(option_parser) option_parser = GaltackClient._modify_option_parser(option_parser) options, arguments = option_parser.parse_args(argv[1:]) - GaltackLoginWindow._instance = GaltackLoginWindow(options) + GaltackLoginWindow(options) main_loop_run() return 0 diff --git a/galtack_proxy.py b/galtack_proxy.py index 53ddee3..e5fe4e4 100755 --- a/galtack_proxy.py +++ b/galtack_proxy.py @@ -40,10 +40,10 @@ class GaltackProxyClient( # to the server class GaltackServerHousekeeperMixin( - GaltackClientAckExpectingMixin, - GaltackClientPingSenderMixin, - GaltackClientAckSenderMixin, - GaltackClientSendCmdBaseMixin, + galtack.net.GaltackClientAckExpectingMixin, + galtack.net.GaltackClientPingSenderMixin, + galtack.net.GaltackClientAckSenderMixin, + galtack.net.GaltackClientSendCmdBaseMixin, ): """ GaltackServer that interacts properly with a Galcon server. @@ -82,12 +82,6 @@ class GaltackServerHousekeeperMixin( class GaltackProxyServer( # to the client GaltackServerHousekeeperMixin, - galtack.net.GaltackClientPingSenderMixin, - galtack.net.GaltackClientAckExpectingMixin, - galtack.net.GaltackClientBackCallerMixin, - galtack.net.GaltackClientAckSenderMixin, - galtack.net.GaltackClientIgnoreResentCmdsMixin, - galtack.net.GaltackClientPrependSeqNrMixin, ): pass @@ -97,18 +91,28 @@ class GaltackProxyWindow(WindowF12RawConsoleMixin): """ def __init__(self, *a, **kw): - super(GaltackProxyWindow, self).__init__(*a, **kw) + super(GaltackProxyWindow, self).__init__() self.set_title("GalTacK Proxy") (outer, inner) = gnome_hig(self) - table = gnome_hig(inner(Table())) + table = gnome_hig(inner(Table(), False, False)) + + xo = {"xoptions": 0} + + table.add_rows() + table.attach_cell(LeftLabel("Listening Port:"), **xo) + self.__port_entry = table.attach_cell(Entry()) table.add_rows() - table.attach_cell(LeftLabel("Listening Port:", + self.__listen_button = table.attach_row(Button("Listen")) + self.__listen_button.connect("clicked", self.__cb_listen_clicked) C = GaltackClient self.galtack_client = C(self.__options, self.__user_info, self.__server_info) + + def __cb_listen_clicked(self, button): + print "listen" class GaltackServerListWindow(GaltackServerListWindow): @@ -126,6 +130,26 @@ class GaltackServerListWindow(GaltackServerListWindow): gobject.idle_add(self.hide) +class GaltackLoginWindow(GaltackLoginWindow): + + NEXT_CLASS = GaltackServerListWindow + + def __init__(self, *a, **kw): + super(GaltackLoginWindow, self).__init__(*a, **kw) + self.set_title("GalTacK Proxy Login") + + +def main(argv): + option_parser = optparse.OptionParser(prog = "GalTacK Proxy", + version = "%%prog %s" % + galtack_version_str) + option_parser = GaltackLoginWindow._modify_option_parser(option_parser) + option_parser = GaltackClient._modify_option_parser(option_parser) + options, arguments = option_parser.parse_args(argv[1:]) + GaltackLoginWindow._instance = GaltackLoginWindow(options) + main_loop_run() + return 0 + if __name__ == "__main__": import sys sys.exit(main(sys.argv)) -- 2.11.4.GIT