summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-01-12 14:57:58 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-01-12 14:57:58 +0000
commit6298b4331a8c93beac31cb9b85b83892c254f97b (patch)
tree25fe8bf65d68abe02f1b526f3081fe04f3fa5f6c
parentc7e0fc1c25ce2a3b30557006d4ec607575923be8 (diff)
downloadpoezio-6298b4331a8c93beac31cb9b85b83892c254f97b.tar.gz
poezio-6298b4331a8c93beac31cb9b85b83892c254f97b.tar.bz2
poezio-6298b4331a8c93beac31cb9b85b83892c254f97b.tar.xz
poezio-6298b4331a8c93beac31cb9b85b83892c254f97b.zip
prout
-rw-r--r--src/connection.py12
-rw-r--r--src/gui.py15
2 files changed, 22 insertions, 5 deletions
diff --git a/src/connection.py b/src/connection.py
index 4e34384b..385dfe00 100644
--- a/src/connection.py
+++ b/src/connection.py
@@ -49,7 +49,7 @@ class Connection(Thread):
"""
connect to server
"""
- self.client = xmpp.Client(self.server)
+ self.client = xmpp.Client(self.server, debug=[])
if not self.connect_to_server(self.server, self.port):
log.error('Could not connect to server')
sys.exit(-1)
@@ -59,6 +59,9 @@ class Connection(Thread):
self.client.sendInitPresence()
self.online = 1 # 2 when confirmation of auth is received
self.register_handlers()
+ self.muc = MultiUserChat(self.client)
+ while 1:
+ self.process()
def connect_to_server(self, server, port):
# TODO proxy stuff
@@ -102,6 +105,9 @@ class Connection(Thread):
# print '[%s] in room {%s}. (%s - %s)'% (nick_from, room_from, affil, role)
self.handler.emit('xmpp-presence-handler', presence=presence)
+ def send_join_room(self, room, nick):
+ self.handler.emit('join-room', room=room, nick=nick)
+
def handler_iq(self, connection, iq):
pass
@@ -111,6 +117,7 @@ class Connection(Thread):
else:
log.warning('disconnecting...')
+
if __name__ == '__main__':
resource = config.get('resource')
server = config.get('server')
@@ -124,6 +131,3 @@ if __name__ == '__main__':
for room in rooms:
connection.send_join_room(room.split('/')[0], room.split('/')[1])
i = 17
- while i:
- connection.process()
- i -= 1
diff --git a/src/gui.py b/src/gui.py
index 10adb780..aa710caa 100644
--- a/src/gui.py
+++ b/src/gui.py
@@ -23,6 +23,8 @@ from curses import textpad
import sys
+from connection import *
+
class Win(object):
def __init__(self, height, width, y, x, parent_win):
self._resize(height, width, y, x, parent_win)
@@ -190,7 +192,7 @@ class Gui(object):
self.handler = Handler()
self.handler.connect('on-muc-message-received', self.on_message)
- self.handler.connect('join-room', self.on_join_room)
+ self.handler.connect('gui-join-room', self.on_join_room)
self.handler.connect('on-muc-presence-changed', self.on_presence)
self.init_curses(stdscr)
@@ -234,4 +236,15 @@ def main(stdscr):
gui.main_loop(stdscr)
if __name__ == '__main__':
+ resource = config.get('resource')
+ server = config.get('server')
+ connection = Connection(server, resource)
+ connection.start()
+ rooms = config.get('rooms').split(':')
+ from time import sleep
+ print connection.online
+ sleep(2)
+ print connection.online
+ for room in rooms:
+ connection.send_join_room(room.split('/')[0], room.split('/')[1])
curses.wrapper(main)