Changeset 9459
- Timestamp:
- 04/11/08 05:52:45 (8 months ago)
- Location:
- branches/session_centric
- Files:
-
- 1 added
- 5 modified
-
data/glade/roster_contact_context_menu.glade (modified) (1 diff)
-
src/common/connection_handlers.py (modified) (10 diffs)
-
src/common/stanza_session.py (modified) (3 diffs)
-
src/roster_window.py (modified) (2 diffs)
-
src/session.py (modified) (2 diffs)
-
src/tictactoe.py (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/session_centric/data/glade/roster_contact_context_menu.glade
r8706 r9459 90 90 </widget> 91 91 </child> 92 </widget> 93 </child> 94 <child> 95 <widget class="GtkImageMenuItem" id="tictactoe_menuitem"> 96 <property name="visible">True</property> 97 <property name="label" translatable="yes">Play Tic Tac Toe</property> 98 <property name="use_underline">True</property> 92 99 </widget> 93 100 </child> -
branches/session_centric/src/common/connection_handlers.py
r9447 r9459 51 51 52 52 # XXX interface leaking into the back end? 53 import session 53 from session import ChatControlSession 54 import tictactoe 54 55 55 56 STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', … … 769 770 q.addChild('feature', attrs = {'var': common.xmpp.NS_MOOD + '+notify'}) 770 771 q.addChild('feature', attrs = {'var': common.xmpp.NS_ESESSION_INIT}) 772 q.addChild('feature', attrs = {'var': 'http://jabber.org/protocol/games'}) 771 773 772 774 if (node is None or extension == 'cstates') and gajim.config.get('outgoing_chat_state_notifactions') != 'disabled': … … 779 781 q.addChild('feature', attrs = {'var': common.xmpp.NS_PING}) 780 782 q.addChild('feature', attrs = {'var': common.xmpp.NS_TIME_REVISED}) 783 784 if node == 'http://jabber.org/protocol/games': 785 q.addChild('feature', attrs = {'var': 'http://jabber.org/protocol/games/tictactoe'}) 781 786 782 787 if q.getChildren(): … … 1539 1544 mtype = 'normal' 1540 1545 1541 if not mtype == 'groupchat': 1546 game_invite = msg.getTag('invite', namespace='http://jabber.org/protocol/games') 1547 if game_invite: 1548 game = game_invite.getTag('game') 1549 1550 if game.getAttr('var') == 'http://jabber.org/protocol/games/tictactoe': 1551 klass = tictactoe.TicTacToeSession 1552 1553 # this assumes that the invitation came with a thread_id we haven't seen 1554 session = self.make_new_session(frm, thread_id, klass=klass) 1555 1556 session.invited(msg) 1557 1558 return 1559 elif mtype != 'groupchat': 1542 1560 session = self.get_session(frm, thread_id, mtype) 1543 1561 … … 1551 1569 1552 1570 # check if the message is a xep70-confirmation-request 1553 if msg.getTag('confirm') and msg.getTag('confirm').namespace == \ 1554 common.xmpp.NS_HTTP_AUTH: 1571 if msg.getTag('confirm', namespace=common.xmpp.NS_HTTP_AUTH): 1555 1572 self._HttpAuthCB(con, msg) 1556 1573 return 1557 1574 1558 1575 # check if the message is a XEP 0020 feature negotiation request 1559 if msg.getTag('feature') and msg.getTag('feature').namespace == \ 1560 common.xmpp.NS_FEATURE: 1576 if msg.getTag('feature', namespace=common.xmpp.NS_FEATURE): 1561 1577 if gajim.HAVE_PYCRYPTO: 1562 1578 self._FeatureNegCB(con, msg, session) … … 1564 1580 1565 1581 # check if the message is initiating an ESession negotiation 1566 if msg.getTag('init') and msg.getTag('init').namespace == \ 1567 common.xmpp.NS_ESESSION_INIT: 1582 if msg.getTag('init', namespace=common.xmpp.NS_ESESSION_INIT): 1568 1583 self._InitE2ECB(con, msg, session) 1569 1584 1570 1585 encrypted = False 1571 1586 1572 e2e_tag = msg.getTag('c', namespace = common.xmpp.NS_STANZA_CRYPTO) 1573 if e2e_tag: 1587 if msg.getTag('c', namespace = common.xmpp.NS_STANZA_CRYPTO): 1574 1588 encrypted = True 1575 1589 … … 1702 1716 mtype = treat_as 1703 1717 1704 session.received(frm, msgtxt, tim, encrypted, mtype, subject, chatstate, 1705 msg_id, composing_xep, user_nick, msghtml, form_node) 1718 # XXX horrible hack 1719 if isinstance(session, ChatControlSession): 1720 session.received(frm, msgtxt, tim, encrypted, mtype, subject, chatstate, 1721 msg_id, composing_xep, user_nick, msghtml, form_node) 1722 else: 1723 session.received(msg) 1706 1724 # END messageCB 1707 1725 1708 1726 # process and dispatch an error message 1709 def dispatch_error_message(self, msg, msgtxt, session, frm, tim, subject) 1727 def dispatch_error_message(self, msg, msgtxt, session, frm, tim, subject): 1710 1728 error_msg = msg.getError() 1711 1729 … … 1762 1780 self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 1763 1781 1764 def dispatch_invite_message(self, invite, frm) 1782 def dispatch_invite_message(self, invite, frm): 1765 1783 item = invite.getTag('invite') 1766 1784 … … 1834 1852 1835 1853 returns the session that we last sent a message to.''' 1836 1854 1837 1855 sessions_with_jid = self.sessions[jid].values() 1838 1856 no_threadid_sessions = filter(lambda s: not s.received_thread_id, sessions_with_jid) … … 1844 1862 return None 1845 1863 1846 def make_new_session(self, jid, thread_id = None, type = 'chat'): 1847 sess = session.ChatControlSession(self, common.xmpp.JID(jid), thread_id, type) 1864 def make_new_session(self, jid, thread_id=None, type='chat', klass=None): 1865 if not klass: 1866 klass = ChatControlSession 1867 1868 sess = klass(self, common.xmpp.JID(jid), thread_id, type) 1848 1869 1849 1870 if not jid in self.sessions: -
branches/session_centric/src/common/stanza_session.py
r9299 r9459 33 33 self.thread_id = self.generate_thread_id() 34 34 35 self.loggable = True 36 35 37 self.last_send = 0 36 38 self.status = None 37 39 self.negotiated = {} 40 41 def is_loggable(self): 42 account = self.conn.name 43 no_log_for = gajim.config.get_per('accounts', account, 'no_log_for') 44 45 if not no_log_for: 46 no_log_for = '' 47 48 no_log_for = no_log_for.split() 49 50 return self.loggable and account not in no_log_for and self.jid not in no_log_for 38 51 39 52 def generate_thread_id(self): … … 132 145 def __init__(self, conn, jid, thread_id, type = 'chat'): 133 146 StanzaSession.__init__(self, conn, jid, thread_id, type = 'chat') 134 135 self.loggable = True136 147 137 148 self.xes = {} … … 892 903 self.km_o = '' 893 904 894 def is_loggable(self):895 account = self.conn.name896 no_log_for = gajim.config.get_per('accounts', account, 'no_log_for')897 898 if not no_log_for:899 no_log_for = ''900 901 no_log_for = no_log_for.split()902 903 return self.loggable and account not in no_log_for and self.jid not in no_log_for904 905 905 def cancelled_negotiation(self): 906 906 StanzaSession.cancelled_negotiation(self) -
branches/session_centric/src/roster_window.py
r9326 r9459 2346 2346 2347 2347 else: # one resource 2348 tictactoe_menuitem = xml.get_widget( 'tictactoe_menuitem') 2349 tictactoe_menuitem.connect('activate', self.play_tictactoe, contact, account, contact.resource) 2350 2348 2351 start_chat_menuitem.connect('activate', 2349 2352 self.on_open_chat_window, contact, account) … … 4278 4281 return True 4279 4282 return False 4283 4284 def play_tictactoe(self, widget, contact, account, resource=None): 4285 jid = contact.jid 4286 4287 if resource is not None: 4288 jid = jid + u'/' + resource 4289 4290 import tictactoe 4291 4292 sess = gajim.connections[account].make_new_session(jid, klass=tictactoe.TicTacToeSession) 4293 sess.begin() 4280 4294 4281 4295 def on_execute_command(self, widget, contact, account, resource=None): -
branches/session_centric/src/session.py
r9308 r9459 17 17 self.control = None 18 18 19 # dispatch a received <message> stanza 19 20 def received(self, full_jid_with_resource, message, tim, encrypted, msg_type, subject, chatstate, msg_id, composing_xep, user_nick, xhtml, form_node): 20 21 … … 115 116 composing_xep, user_nick, xhtml, form_node])) 116 117 118 # display the message or show notification in the roster 117 119 def roster_message(self, jid, msg, tim, encrypted=False, msg_type='', 118 120 subject=None, resource='', msg_id=None, user_nick='',
