/
main.py
executable file
·56 lines (43 loc) · 1.38 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
"""
TODO: Document me
"""
__date__ = "$16-Mar-2010 16:35:49$"
import sys
from PyQt4 import QtCore, QtGui
from tunnelconnection import TunnelConnection
from chatrosterwindow import ChatRosterWindow
from loginwindow import LoginWindow
class TunnelClient(object):
"""Holder object for the application"""
def __init__(self):
"""Initialise objects"""
self.connected = False
self.app = QtGui.QApplication(sys.argv)
self.chat = ChatRosterWindow(self)
self.login()
self.chat.show()
sys.exit(self.app.exec_())
def login(self):
"""Run login dialog and get the api_conn set up"""
login = LoginWindow(self)
login.exec_()
self.connected = True
def set_login_details(self, username, password, server):
self.username = username
self.password = password
self.server = server
return self.start_connection()
def start_connection(self):
# Initialise the XMPP connection
#try:
self.xmpp = TunnelConnection(str(self.username) + "/tunnel",
str(self.password), self.chat.session_start,
self.chat.incoming_message)
self.xmpp.connect((str(self.server), 5222))
self.xmpp.process(threaded=True)
#except:
# return False
#else:
return True
TunnelClient()