DevConsole/Purk: Support for auto-join channels on connect, new button to connect to #olpc-help

This commit is contained in:
Eduardo Silva 2007-08-21 17:31:56 -04:00
parent 9eb9d79cee
commit 104b158a80
5 changed files with 40 additions and 16 deletions

View File

@ -54,7 +54,7 @@ class Console(object):
self._load_interface('memphis', 'Memphis')
self._load_interface('logviewer', 'Log Viewer')
self._load_interface('terminal', 'Terminal')
self._load_interface('irc_client', 'IRC')
self._load_interface('irc_client', 'IRC Client')
self._load_interface('ps_watcher', 'Presence')
main_hbox = gtk.HBox()

View File

@ -1,10 +1,28 @@
import gtk
import purk
class IRCGui(gtk.VBox):
_DEFAULT_SERVER = "irc.freenode.net"
_AUTO_JOIN_CHANNEL = "#olpc-help"
def __init__(self):
gtk.VBox.__init__(self, False)
connect_button = gtk.Button('Connect to OLPC Help Channel')
connect_button.connect('clicked', self._on_connect_clicked_cb)
self._client = purk.Client()
self._client.add_channel(self._AUTO_JOIN_CHANNEL)
client_widget = self._client.get_widget()
self.pack_start(connect_button, False, False, 1)
self.pack_start(client_widget)
self.show_all()
def _on_connect_clicked_cb(self, widget):
self._client.join_server(self._DEFAULT_SERVER)
class Interface(object):
def __init__(self):
client = purk.Client()
client.show()
client.join_server('irc.freenode.net')
self.widget = client.get_widget()
self.widget = IRCGui()

View File

@ -49,6 +49,7 @@ class Core(object):
self.trigger = Trigger()
self.events = self.trigger.events
self.manager = widgets.UrkUITabs(self)
self.channels = []
mods = self.trigger.get_modules()
for m in mods:
@ -79,6 +80,7 @@ class Client(object):
def __init__(self):
self.core = Core()
self.widget = self.core.manager.box
def run_command(self, command):
self.core.run_command(command)
@ -92,3 +94,8 @@ class Client(object):
def show(self):
self.widget.show_all()
def add_channel(self, channel):
self.core.channels.append(channel)
def clear_channels(self):
self.core.channels = []

View File

@ -192,17 +192,11 @@ def run(text, window, network):
c_data.args = split
event_name = "Command" + c_data.name.capitalize()
#print "searching: " + event_name
#for s in all_events:
# print "match: " + s
# if s == event_name:
# print "we got it!"
if event_name in all_events:
result = trigger(event_name, c_data)
if result:
print "* /%s: %s" % (c_data.name, result[0])
c_data.window.write("* /%s: %s" % (c_data.name, result[0]))
else:
trigger("Command", c_data)

View File

@ -54,6 +54,7 @@ class Network(object):
def __init__(self, core, server="irc.default.org", port=6667, nicks=[],
username="", fullname="", name=None, **kwargs):
self.core = core
self.manager = core.manager
self.server = server
self.port = port
@ -131,7 +132,7 @@ class Network(object):
self.disconnect(error=error[1])
#we should immediately retry if we failed to open the socket and there are hosts left
if self.status == DISCONNECTED and not self.failedlasthost:
windows.get_default(self).write("* Retrying with next available host")
windows.get_default(self, self.core.manager).write("* Retrying with next available host")
self.connect()
else:
self.source = source = ui.Source()
@ -143,6 +144,10 @@ class Network(object):
if source.enabled:
self.source = ui.fork(self.on_read, self.socket.recv, 8192)
# Auto join channels on connect
for channel in self.core.channels:
self.core.run_command("/join %s" % channel)
#called when we read data or failed to read data
def on_read(self, result, error):
if error: