Gajim now can send type=normal messages [TODO: handle incoming normal better]
This commit is contained in:
		
							parent
							
								
									287e860d10
								
							
						
					
					
						commit
						9b11b98af2
					
				
					 4 changed files with 52 additions and 25 deletions
				
			
		| 
						 | 
				
			
			@ -829,7 +829,7 @@ class Connection:
 | 
			
		|||
			self.connection.send(p)
 | 
			
		||||
			self.dispatch('STATUS', show)
 | 
			
		||||
 | 
			
		||||
	def send_message(self, jid, msg, keyID, type = 'chat'):
 | 
			
		||||
	def send_message(self, jid, msg, keyID, type = 'chat', subject=''):
 | 
			
		||||
		if not self.connection:
 | 
			
		||||
			return
 | 
			
		||||
		if not msg:
 | 
			
		||||
| 
						 | 
				
			
			@ -840,7 +840,15 @@ class Connection:
 | 
			
		|||
			#encrypt
 | 
			
		||||
			msgenc = self.gpg.encrypt(msg, [keyID])
 | 
			
		||||
			if msgenc: msgtxt = _('[this message is encrypted]')
 | 
			
		||||
		msg_iq = common.xmpp.Message(to = jid, body = msgtxt, typ = type)
 | 
			
		||||
		if type == 'chat':
 | 
			
		||||
			msg_iq = common.xmpp.Message(to = jid, body = msgtxt, typ = type)
 | 
			
		||||
		else:
 | 
			
		||||
			if subject:
 | 
			
		||||
				msg_iq = common.xmpp.Message(to = jid, body = msgtxt,
 | 
			
		||||
					typ = 'normal', subject = subject)
 | 
			
		||||
			else:
 | 
			
		||||
				msg_iq = common.xmpp.Message(to = jid, body = msgtxt,
 | 
			
		||||
					typ = 'normal')
 | 
			
		||||
		if msgenc:
 | 
			
		||||
			msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc)
 | 
			
		||||
		self.to_be_sent.insert(0, msg_iq)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -798,13 +798,21 @@ class PopupNotificationWindow:
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
class SendSingleMessageDialog:
 | 
			
		||||
	def __init__(self, plugin, account):
 | 
			
		||||
	def __init__(self, plugin, account, contact):
 | 
			
		||||
		self.plugin = plugin
 | 
			
		||||
		self.account = account
 | 
			
		||||
		
 | 
			
		||||
		xml = gtk.glade.XML(GTKGUI_GLADE, 'popup_notification_window', APP)
 | 
			
		||||
		self.window = xml.get_widget('popup_notification_window')
 | 
			
		||||
		xml.signal_autoconnect(self)
 | 
			
		||||
		self.xml = gtk.glade.XML(GTKGUI_GLADE, 'send_single_message_window', APP)
 | 
			
		||||
		self.window = self.xml.get_widget('send_single_message_window')
 | 
			
		||||
		self.count_chars_label = self.xml.get_widget('count_chars_label')
 | 
			
		||||
		self.to_entry = self.xml.get_widget('to_entry')
 | 
			
		||||
		self.subject_entry = self.xml.get_widget('subject_entry')
 | 
			
		||||
		self.message_tv_buffer = self.xml.get_widget('message_textview').\
 | 
			
		||||
			get_buffer()
 | 
			
		||||
 | 
			
		||||
		self.message_tv_buffer.connect('changed', self.update_char_counter)
 | 
			
		||||
		
 | 
			
		||||
		self.to_entry.set_text(contact.jid)
 | 
			
		||||
		
 | 
			
		||||
		our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
 | 
			
		||||
			gajim.config.get_per('accounts', self.account, 'hostname')
 | 
			
		||||
| 
						 | 
				
			
			@ -814,18 +822,31 @@ class SendSingleMessageDialog:
 | 
			
		|||
		else:
 | 
			
		||||
			title = _('Send Single Message')
 | 
			
		||||
		self.window.set_title(title)
 | 
			
		||||
		
 | 
			
		||||
		self.subject_entry.grab_focus()
 | 
			
		||||
		
 | 
			
		||||
		self.xml.signal_autoconnect(self)
 | 
			
		||||
		self.window.show_all()
 | 
			
		||||
 | 
			
		||||
		instance = InputDialog(title, prompt_text)
 | 
			
		||||
		response = instance.get_response()
 | 
			
		||||
		if response == gtk.RESPONSE_OK:  
 | 
			
		||||
			jid = instance.input_entry.get_text()
 | 
			
		||||
	def on_cancel_button_clicked(self, widget):
 | 
			
		||||
		self.window.destroy()
 | 
			
		||||
 | 
			
		||||
			if jid.find('@') == -1: # if no @ was given
 | 
			
		||||
				ErrorDialog(_('Invalid contact ID'),
 | 
			
		||||
		_('Contact ID must be of the form "username@servername".')).get_response()
 | 
			
		||||
				return
 | 
			
		||||
 | 
			
		||||
			self.plugin.roster.new_chat_from_jid(self.account, jid)
 | 
			
		||||
	def update_char_counter(self, widget):
 | 
			
		||||
		characters_no = self.message_tv_buffer.get_char_count()
 | 
			
		||||
		self.count_chars_label.set_text(str(characters_no))
 | 
			
		||||
	
 | 
			
		||||
	def on_send_button_clicked(self, widget):
 | 
			
		||||
		pass
 | 
			
		||||
		to_whom_jid = self.to_entry.get_text()
 | 
			
		||||
		if to_whom_jid.find('@') == -1: # if no @ was given
 | 
			
		||||
			ErrorDialog(_('Invalid contact ID'),
 | 
			
		||||
		_('Contact ID must be of the form "username@servername".')).get_response()
 | 
			
		||||
			return
 | 
			
		||||
		subject = self.subject_entry.get_text()
 | 
			
		||||
		begin, end = self.message_tv_buffer.get_bounds()
 | 
			
		||||
		message = self.message_tv_buffer.get_text(begin, end)
 | 
			
		||||
 | 
			
		||||
		# FIXME: allow GPG message some day
 | 
			
		||||
		gajim.connections[self.account].send_message(to_whom_jid, message,
 | 
			
		||||
			keyID = None, type = 'normal', subject=subject)
 | 
			
		||||
		
 | 
			
		||||
		self.message_tv_buffer.set_text('') # we sent ok, clear the textview
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15397,8 +15397,7 @@ the Jabber network.</property>
 | 
			
		|||
</widget>
 | 
			
		||||
 | 
			
		||||
<widget class="GtkWindow" id="send_single_message_window">
 | 
			
		||||
  <property name="border_width">12</property>
 | 
			
		||||
  <property name="visible">True</property>
 | 
			
		||||
  <property name="border_width">6</property>
 | 
			
		||||
  <property name="title" translatable="yes"></property>
 | 
			
		||||
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
 | 
			
		||||
  <property name="window_position">GTK_WIN_POS_NONE</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -15475,7 +15474,7 @@ the Jabber network.</property>
 | 
			
		|||
	  </child>
 | 
			
		||||
 | 
			
		||||
	  <child>
 | 
			
		||||
	    <widget class="GtkEntry" id="entry4">
 | 
			
		||||
	    <widget class="GtkEntry" id="subject_entry">
 | 
			
		||||
	      <property name="visible">True</property>
 | 
			
		||||
	      <property name="can_focus">True</property>
 | 
			
		||||
	      <property name="editable">True</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -15521,7 +15520,7 @@ the Jabber network.</property>
 | 
			
		|||
	  </child>
 | 
			
		||||
 | 
			
		||||
	  <child>
 | 
			
		||||
	    <widget class="GtkEntry" id="entry5">
 | 
			
		||||
	    <widget class="GtkEntry" id="to_entry">
 | 
			
		||||
	      <property name="visible">True</property>
 | 
			
		||||
	      <property name="can_focus">True</property>
 | 
			
		||||
	      <property name="editable">True</property>
 | 
			
		||||
| 
						 | 
				
			
			@ -15603,7 +15602,7 @@ the Jabber network.</property>
 | 
			
		|||
	      <property name="use_stock">True</property>
 | 
			
		||||
	      <property name="relief">GTK_RELIEF_NORMAL</property>
 | 
			
		||||
	      <property name="focus_on_click">True</property>
 | 
			
		||||
	      <signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Thu, 30 Jun 2005 23:51:17 GMT"/>
 | 
			
		||||
	      <signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Sat, 02 Jul 2005 15:27:45 GMT"/>
 | 
			
		||||
	    </widget>
 | 
			
		||||
	  </child>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15654,7 +15653,7 @@ the Jabber network.</property>
 | 
			
		|||
		      <child>
 | 
			
		||||
			<widget class="GtkLabel" id="label333">
 | 
			
		||||
			  <property name="visible">True</property>
 | 
			
		||||
			  <property name="label" translatable="yes">Send</property>
 | 
			
		||||
			  <property name="label" translatable="yes">_Send</property>
 | 
			
		||||
			  <property name="use_underline">True</property>
 | 
			
		||||
			  <property name="use_markup">False</property>
 | 
			
		||||
			  <property name="justify">GTK_JUSTIFY_LEFT</property>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -569,8 +569,7 @@ class RosterWindow:
 | 
			
		|||
				HistoryWindow(self.plugin, user.jid, account)
 | 
			
		||||
 | 
			
		||||
	def on_send_single_message_menuitem_activate(self, wiget, account, contact):
 | 
			
		||||
		pass
 | 
			
		||||
		#SendSingleMessageDialog
 | 
			
		||||
		dialogs.SendSingleMessageDialog(self, account, contact)
 | 
			
		||||
	
 | 
			
		||||
	def mk_menu_user(self, event, iter):
 | 
			
		||||
		'''Make user's popup menu'''
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue