[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/protocols/jabber
From: Tomáš Trnka <tomtrnka () seznam ! cz>
Date: 2009-01-31 23:28:41
Message-ID: 1233444521.170205.6923.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 919429 by ttrnka:
Do not send repeated typing notifications.
BUG: 139418
M +38 -32 jabberchatsession.cpp
M +6 -4 jabberchatsession.h
--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberchatsession.cpp #919428:919429
@@ -46,10 +46,11 @@
JabberChatSession::JabberChatSession ( JabberProtocol *protocol, const \
JabberBaseContact *user, Kopete::ContactPtrList others, const QString &resource )
- : Kopete::ChatSession ( user, others, protocol )
+ : Kopete::ChatSession ( user, others, protocol ),
+ mTypingNotificationSent ( false )
{
kDebug ( JABBER_DEBUG_GLOBAL ) << "New message manager for " << user->contactId ();
-
+
setComponentData(protocol->componentData());
// make sure Kopete knows about this instance
@@ -73,11 +74,11 @@
KAction *jingleSessionGui = new KAction(i18n("Show audio calls"), \
members().first()); connect(jingleSessionGui, SIGNAL(triggered(bool)), SLOT \
(slotJingleSessionGui() )); setComponentData(protocol->componentData());
-
+
KAction *jingleSession = new KAction(i18n("Start audio call"), members().first());
connect(jingleSession, SIGNAL(triggered(bool)), SLOT (slotJingleSession() ));
setComponentData(protocol->componentData());
-
+
Kopete::ContactPtrList chatMembers = members();
if (chatMembers.first())
{
@@ -93,8 +94,8 @@
jingleSession->setEnabled(false);
}
}
-
+
/*KAction *jingleaudiocall = new KAction(i18n("Jingle Audio call" ), \
members().first()); connect(jingleaudiocall, SIGNAL(triggered(bool)), SLOT \
(slotJingleAudioCall() )); setComponentData(protocol->componentData());
@@ -104,7 +105,7 @@
connect(jinglevideocall, SIGNAL(triggered(bool)), SLOT (slotJingleVideoCall() ));
setComponentData(protocol->componentData());
jinglevideocall->setEnabled( false );*/
-
+
//Kopete::ContactPtrList chatMembers = members ();
//if ( chatMembers.first () )
//{
@@ -113,7 +114,7 @@
//jingleaudiocall->setEnabled( bestResource->features().canJingleAudio() );
//jinglevideocall->setEnabled( bestResource->features().canJingleVideo() );
//}
-
+
//FIXME : Toolbar does not show any action (either for MSN or XMPP)
// It should be corrected in trunk.
//actionCollection()->addAction( "jabberJingleaudiocall", jingleaudiocall );
@@ -194,14 +195,14 @@
// We send the notifications for Delivered and Displayed events. More granular \
management // (ie.: send Displayed event when it is really displayed)
// of these events would require changes in the chatwindow API.
-
+
if ( account()->configGroup()->readEntry ("SendEvents", true) )
{
if ( account()->configGroup()->readEntry ("SendDeliveredEvent", true) )
{
sendNotification( Delivered );
}
-
+
if ( account()->configGroup()->readEntry ("SendDisplayedEvent", true) )
{
sendNotification( Displayed );
@@ -218,7 +219,7 @@
XMPP::ChatState new_state;
bool send_msg_event=false;
bool send_state=false;
-
+
switch(event)
{
case Delivered:
@@ -253,7 +254,7 @@
default:
break;
}
-
+
if(send_msg_event)
{
send_msg_event=false;
@@ -271,7 +272,7 @@
{
send_state=false;
foreach(JabberContact *contact , members())
- {
+ {
JabberContact *c;
if(contact->feature.canChatState() )
{
@@ -280,17 +281,17 @@
}
}
}*/
-
+
if( !members().isEmpty() && (send_state || send_msg_event) )
{
// create JID for us as sender
XMPP::Jid fromJid = static_cast<const \
JabberBaseContact*>(myself())->rosterItem().jid(); fromJid.setResource ( \
account()->resource () );
-
+
// create JID for the recipient
JabberContact *recipient = static_cast<JabberContact*>(members().first());
XMPP::Jid toJid = recipient->rosterItem().jid();
-
+
// set resource properly if it has been selected already
if ( !resource().isEmpty () )
toJid.setResource ( resource () );
@@ -309,13 +310,13 @@
{
message.setChatState( new_state );
}
-
+
if (view() && view()->plugin()->pluginId() == "kopete_emailwindow" )
- {
+ {
message.setType ( "normal" );
}
else
- {
+ {
message.setType ( "chat" );
}
@@ -328,13 +329,16 @@
void JabberChatSession::slotSendTypingNotification ( bool typing )
{
if ( !account()->configGroup()->readEntry ("SendEvents", true)
- || !account()->configGroup()->readEntry("SendComposingEvent", true) )
+ || !account()->configGroup()->readEntry("SendComposingEvent", true) )
return;
- // create JID for us as sender
- XMPP::Jid fromJid = static_cast<const \
JabberBaseContact*>(myself())->rosterItem().jid();
- fromJid.setResource ( account()->configGroup()->readEntry( "Resource", QString() ) \
); + if ( typing && mTypingNotificationSent ) {
+ return;
+ }
+ // send only one Composing notification; CancelComposing and slotMessageSent reset \
this + mTypingNotificationSent = typing;
+
kDebug ( JABBER_DEBUG_GLOBAL ) << "Sending out typing notification (" << typing << \
") to all chat members.";
typing ? sendNotification( Composing ) : sendNotification( CancelComposing );
@@ -389,26 +393,26 @@
{
// this message is not encrypted
jabberMessage.setBody ( message.plainBody ());
- if (message.format() == Qt::RichText)
+ if (message.format() == Qt::RichText)
{
JabberResource *bestResource = \
account()->resourcePool()->bestJabberResource(toJid); if( bestResource && \
bestResource->features().canXHTML() ) {
QString xhtmlBody = message.escapedBody();
-
+
// According to JEP-0071 8.9 it is only RECOMMENDED to replace \n with <br/>
- // which mean that some implementation (gaim 2 beta) may still think that \n \
are linebreak. + // which mean that some implementation (gaim 2 beta) may \
still think that \n are linebreak.
// and considered the fact that KTextEditor generate a well indented XHTML, we \
need to remove all \n from it // see Bug 121627
// Anyway, theses client that do like that are *WRONG* considreded the example \
of jep-71 where there are lot of // linebreak that are not interpreted. - Olivier \
2006-31-03 xhtmlBody.remove('\n');
-
+
// is not a valid XML entity
xhtmlBody.replace(" " , " ");
-
+
xhtmlBody="<p "+ message.getHtmlStyleAttribute() +'>'+ xhtmlBody +"</p>";
-
+
QDomDocument doc;
doc.setContent(xhtmlBody, true);
jabberMessage.setHTML( XMPP::HTMLElement( doc.documentElement() ) );
@@ -424,11 +428,11 @@
// FIXME: the view() is a speedy way to solve BUG:108389. A better solution is to \
be found // but I don't want to introduce a new bug during the bug hunt ;-).
if (view() && view()->plugin()->pluginId() == "kopete_emailwindow" )
- {
+ {
jabberMessage.setType ( "normal" );
}
else
- {
+ {
jabberMessage.setType ( "chat" );
}
@@ -438,9 +442,9 @@
jabberMessage.addEvent( DeliveredEvent );
jabberMessage.addEvent( DisplayedEvent );
jabberMessage.setChatState( XMPP::StateActive );
-
- // send the message
+
+ // send the message
account()->client()->sendMessage ( jabberMessage );
if ( recipient->sendsDeliveredEvent() )
@@ -451,6 +455,8 @@
// tell the manager that we sent successfully
messageSucceeded ();
+
+ mTypingNotificationSent = false;
}
else
{
--- trunk/KDE/kdenetwork/kopete/protocols/jabber/jabberchatsession.h #919428:919429
@@ -39,9 +39,9 @@
public:
JabberChatSession ( JabberProtocol *protocol, const JabberBaseContact *user,
Kopete::ContactPtrList others, const QString &resource = "" );
-
+
~JabberChatSession();
-
+
/**
* @brief Get the local user in the session
* @return the local user in the session, same as account()->myself()
@@ -100,11 +100,13 @@
* Send a notification (XMPP::MsgEvent) to the members of the chatsession.
* SlotSendTypingNotification uses it.
* and change the state acordingly.
- *
+ *
*/
void sendNotification( Event event );
-
+
QString mResource;
+
+ bool mTypingNotificationSent;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic