annotate frontends/primitivus/primitivus @ 125:8d611eb9ae48

primitivus: contact list enhancement - primitivus: contact list now display groups and sexy name (instead of bare jid) - primitivus: contact list now show an alert when somebody want to contact you, and its chat window is not on the screen - primitivus: cursor is now visible when going to chat window (useful to go back in logs)
author Goffi <goffi@goffi.org>
date Mon, 12 Jul 2010 17:50:00 +0800
parents 961e0898271f
children 55d3ef84f01f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Primitivus: a SAT frontend
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
7
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
12
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU General Public License for more details.
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
17
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from quick_frontend.quick_app import QuickApp
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from quick_frontend.quick_chat_list import QuickChatList
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from quick_frontend.quick_contact_list import QuickContactList
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from quick_frontend.quick_contact_management import QuickContactManagement
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 import urwid
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from profile_manager import ProfileManager
116
7c482ecac0ff primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents: 113
diff changeset
29 from contact_list import ContactList
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
30 from chat import Chat
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
31 from custom_widgets import AdvancedEdit,FocusFrame,InputDialog,Alert
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32 import pdb
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33 """from window import Window
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from editbox import EditBox
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from statusbar import StatusBar
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from chat import Chat
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from tools.jid import JID"""
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38 import logging
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39 from logging import debug, info, error
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 #import locale
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41 import sys, os
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
42 from tools.jid import JID
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 #from curses import ascii
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
44 #import locale
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 #from signal import signal, SIGWINCH
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46 #import fcntl
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 #import struct
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 #import termios
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49 #from boxsizer import BoxSizer
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
50
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
51
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
52 ### logging configuration FIXME: put this elsewhere ###
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
53 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
54 format='%(message)s')
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55 ###
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
56
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 const_APP_NAME = "Primitivus"
113
e5ca22113280 Primitivus: profile manager
Goffi <goffi@goffi.org>
parents: 112
diff changeset
58 const_PALETTE = [('title', 'black', 'light gray', 'standout,underline'),
e5ca22113280 Primitivus: profile manager
Goffi <goffi@goffi.org>
parents: 112
diff changeset
59 ('selected', 'default', 'dark red'),
e5ca22113280 Primitivus: profile manager
Goffi <goffi@goffi.org>
parents: 112
diff changeset
60 ('selected_focus', 'default,bold', 'dark red'),
e5ca22113280 Primitivus: profile manager
Goffi <goffi@goffi.org>
parents: 112
diff changeset
61 ('default', 'default', 'default'),
e5ca22113280 Primitivus: profile manager
Goffi <goffi@goffi.org>
parents: 112
diff changeset
62 ('default_focus', 'default,bold', 'default'),
125
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
63 ('alert', 'default,underline', 'default'),
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
64 ('alert_focus', 'default,bold,underline', 'default'),
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
65 ('date', 'light gray', 'default'),
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
66 ('my_nick', 'dark red,bold', 'default'),
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
67 ('other_nick', 'dark cyan,bold', 'default'),
113
e5ca22113280 Primitivus: profile manager
Goffi <goffi@goffi.org>
parents: 112
diff changeset
68 ]
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
69
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
70 class ChatList(QuickChatList):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
71 """This class manage the list of chat windows"""
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
72
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
73 def __init__(self, host):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
74 QuickChatList.__init__(self, host)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
75
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
76 def createChat(self, target):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
77 return Chat(target, self.host)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
78
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
79 class PrimitivusApp(QuickApp):
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
80
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
81 def __init__(self):
116
7c482ecac0ff primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents: 113
diff changeset
82 self.CM = QuickContactManagement() #FIXME: not the best place
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
83 QuickApp.__init__(self) #XXX: yes it's an unusual place for the constructor of a parent class, but the init order is important
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
84
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
85 ## main loop setup ##
117
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
86 self.main_widget = ProfileManager(self)
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
87 self.loop = urwid.MainLoop(self.main_widget, const_PALETTE, event_loop=urwid.GLibEventLoop(), unhandled_input=self.key_handler)
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
88
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
89 ##misc setup##
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
90 self.chat_wins=ChatList(self)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
91
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
92 def debug(self):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
93 """convenience method to reset screen and launch pdb"""
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
94 import os
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
95 os.system('reset')
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
96 print 'Entered debug mode'
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
97 pdb.set_trace()
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
98
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
99 def redraw(self):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
100 """redraw the screen"""
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
101 self.loop.draw_screen()
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
102
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
103 def start(self):
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
104 self.i = 0
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
105 self.loop.set_alarm_in(0,lambda a,b: self.postInit())
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106 self.loop.run()
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
107
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
108 def key_handler(self, input):
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
109 if input in ('q', 'Q') or input == 'ctrl x':
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
110 raise urwid.ExitMainLoop()
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
111 elif input == 'ctrl d' and 'D' in self.bridge.getVersion(): #Debug only for dev versions
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
112 self.debug()
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
113 elif input == 'meta j': #user wants to join a room
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
114 pop_up_widget = InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'test@conference.necton2.int', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
115 self.showPopUp(pop_up_widget)
124
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
116 elif input == 'f2': #user wants to (un)hide the contact_list
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
117 try:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
118 center_widgets = self.center_part.widget_list
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
119 if self.contactList in center_widgets:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
120 self.center_part.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.center_part
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
121 center_widgets.remove(self.contactList)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
122 del self.center_part.column_types[0]
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
123 else:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
124 center_widgets.insert(0, self.contactList)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
125 self.center_part.column_types.insert(0, ('weight', 2))
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
126 except AttributeError:
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
127 #The main widget is not built (probably in Profile Manager)
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
128 pass
961e0898271f primitivus chat window
Goffi <goffi@goffi.org>
parents: 120
diff changeset
129
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
130 def __buildMainWidget(self):
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
131 self.contactList = ContactList(self, self.CM, on_click = self.contactSelected, on_change=lambda w: self.redraw())
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
132 #self.center_part = urwid.Columns([('weight',2,self.contactList),('weight',8,Chat('',self))])
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
133 self.center_part = urwid.Columns([('weight',2,self.contactList), ('weight',8,urwid.Filler(urwid.Text('')))])
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
134 editBar = AdvancedEdit('> ')
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
135 urwid.connect_signal(editBar,'click',self.onTextEntered)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
136 self.main_widget = FocusFrame(self.center_part, footer=editBar, focus_part='footer')
118
76055a209ed9 primitivus: added edition zone at the bottom
Goffi <goffi@goffi.org>
parents: 117
diff changeset
137 return self.main_widget
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
138
116
7c482ecac0ff primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents: 113
diff changeset
139 def plug_profile(self, profile_key='@DEFAULT@'):
118
76055a209ed9 primitivus: added edition zone at the bottom
Goffi <goffi@goffi.org>
parents: 117
diff changeset
140 self.loop.widget = self.__buildMainWidget()
116
7c482ecac0ff primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents: 113
diff changeset
141 QuickApp.plug_profile(self, profile_key)
117
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
142
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
143 def removePopUp(self, widget=None):
117
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
144 self.loop.widget = self.main_widget
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
145
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
146 def showPopUp(self, pop_up_widget):
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
147 display_widget = urwid.Overlay(pop_up_widget, self.main_widget, 'center', ('relative', 40), 'middle', ('relative', 40))
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
148 self.loop.widget = display_widget
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
149
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
150 def contactSelected(self, contact_list):
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
151 contact = contact_list.get_contact()
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
152 if contact:
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
153 assert(len(self.center_part.widget_list)==2)
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
154 #self.center_part.widget_list.append(self.chat_wins[contact])
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
155 #self.center_part.column_types.append(('weight',8))
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
156 self.center_part.widget_list[1] = self.chat_wins[contact]
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
157
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
158 def onTextEntered(self, editBar):
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
159 """Called when text is entered in the main edit bar"""
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
160 contact = self.contactList.get_contact() ###Based on the fact that there is currently only one contact selectableat once
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
161 if contact:
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
162 chat = self.chat_wins[contact]
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
163 self.bridge.sendMessage(contact,
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
164 editBar.get_edit_text(),
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
165 type = "groupchat" if chat.type == 'group' else "chat",
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
166 profile_key=self.profile)
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
167 editBar.set_edit_text('')
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 118
diff changeset
168
125
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
169 def newMessage(self, from_jid, msg, type, to_jid, profile):
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
170 if not self.check_profile(profile):
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
171 return
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
172 QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile)
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
173 sender = JID(from_jid)
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
174 if JID(self.contactList.selected).short != sender.short:
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
175 self.contactList.putAlert(sender)
8d611eb9ae48 primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents: 124
diff changeset
176
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
177 def onJoinRoom(self, button, edit):
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
178 self.removePopUp()
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
179 room_jid = JID(edit.get_edit_text())
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
180 if room_jid.is_valid():
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
181 self.bridge.joinMUC(room_jid.domain, room_jid.node, self.profiles[self.profile]['whoami'].node, self.profile)
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
182 else:
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
183 message = _("'%s' is an invalid JID !") % room_jid
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
184 error (message)
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
185 Alert(_("Error"), message, ok_cb=self.removePopUp)
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 119
diff changeset
186
112
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
187 sat = PrimitivusApp()
f551e44adb25 Primitivus first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
188 sat.start()
117
1f0fd6f03e2b misc fixes
Goffi <goffi@goffi.org>
parents: 116
diff changeset
189