[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete
From:       Lamarque Souza <lamarque () kde ! org>
Date:       2012-02-25 20:33:11
Message-ID: 20120225203311.E8A5AAC896 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1282234 by lvsouza:

Add notifications about contact's status message change in chat.
Thanks to Igor Poboiko for this patch.

REVIEW: 5282
BUG: 160510
BUG: 193402


 M  +50 -3     kopete/chatwindow/chatview.cpp  
 M  +6 -0      kopete/chatwindow/chatview.h  
 M  +4 -6      libkopete/kopetechatsession.cpp  
 M  +5 -0      libkopete/kopetechatsession.h  
 M  +2 -0      libkopete/kopetecontact.cpp  
 M  +5 -0      libkopete/kopetecontact.h  
 M  +1 -1      protocols/oscar/aim/aimuserinfo.cpp  
 M  +14 -3     protocols/oscar/icq/icqcontact.cpp  
 M  +3 -6      protocols/oscar/icqcontactbase.cpp  
 M  +1 -1      protocols/oscar/oscarcontact.cpp  
 M  +0 -3      protocols/oscar/oscarcontact.h  


--- trunk/KDE/kdenetwork/kopete/kopete/chatwindow/chatview.cpp #1282233:1282234
@@ -132,6 +132,8 @@
 	//Manager signals
 	connect( mgr, SIGNAL(displayNameChanged()),
 	         this, SLOT(slotChatDisplayNameChanged()) );
+	connect( mgr, SIGNAL(statusMessageChanged(Kopete::Contact*)),
+	         this, SLOT(slotStatusMessageChanged( Kopete::Contact*)));
 	connect( mgr, SIGNAL(contactAdded(const Kopete::Contact*,bool)),
 	         this, SLOT(slotContactAdded(const Kopete::Contact*,bool)) );
 	connect( mgr, SIGNAL(contactRemoved(const \
Kopete::Contact*,QString,Qt::TextFormat,bool)), @@ -530,6 +532,30 @@
 	}
 }
 
+void ChatView::slotStatusMessageChanged( Kopete::Contact* contact )
+{
+	if ( contact == m_manager->myself() )
+		return;
+	const QString contactName = m_messagePart->formatName(contact, Qt::PlainText);
+	const QString statusTitle = contact->statusMessage().title();
+	const QString statusMessage = contact->statusMessage().message();
+	QString msg;
+	if ( statusTitle.isEmpty() && statusMessage.isEmpty() )
+		msg = i18n( "%1 deleted status message", contactName );
+	else
+	{
+		if ( statusTitle.isEmpty() )
+			msg = statusMessage;
+		else if ( statusMessage.isEmpty() )
+			msg = statusTitle;
+		else
+			msg = statusTitle + " - " + statusMessage;
+		msg = i18n( "%1 changed status message: %2", contactName, msg );
+	}
+
+	sendInternalMessage( msg );
+}
+
 void ChatView::slotContactAdded(const Kopete::Contact *contact, bool suppress)
 {
 	if( contact->metaContact() && contact->metaContact() != \
Kopete::ContactList::self()->myself() ) @@ -543,10 +569,9 @@
 		this, SLOT(slotPropertyChanged(Kopete::PropertyContainer*,QString,QVariant,QVariant)) \
) ;  }
 
-	if( !suppress && Kopete::BehaviorSettings::self()->showEvents() && \
                m_manager->members().count() > 1 ) {
-		QString contactName = m_messagePart->formatName(contact, Qt::PlainText);
+	const QString contactName = m_messagePart->formatName(contact, Qt::PlainText);
+	if( !suppress && Kopete::BehaviorSettings::self()->showEvents() && \
m_manager->members().count() > 1 )  sendInternalMessage(  i18n("%1 has joined the \
                chat.", contactName) );
-	}
 
 	if ( m_manager->members().count() == 1 )
 	{
@@ -557,7 +582,21 @@
 	}
 	else
 		disconnect( m_manager->members().first(), SIGNAL(canAcceptFilesChanged()), this, \
SIGNAL(canAcceptFilesChanged()) ); +
+	const QString statusTitle = contact->statusMessage().title();
+	const QString statusMessage = contact->statusMessage().message();
+	if ( contact != m_manager->myself() && ( !statusTitle.isEmpty() || \
!statusMessage.isEmpty() ) ) +	{
+		QString msg;
+		if ( statusTitle.isEmpty() )
+			msg = statusMessage;
+		else if ( statusMessage.isEmpty() )
+			msg = statusTitle;
+		else
+			msg = statusTitle + " - " + statusMessage;
+		sendInternalMessage( i18n( "%1 status message is %2", contactName, msg ) );
 }
+}
 
 void ChatView::slotContactRemoved( const Kopete::Contact *contact, const QString \
&reason, Qt::TextFormat format, bool suppressNotification )  {
@@ -705,11 +744,19 @@
 		}
 		else if ( !contact->account() || !contact->account()->suppressStatusNotification() \
)  {
+			// We shouldn't show an internal message if status have changed
+			// but status visible by user hadn't. It can be happened
+			// if contact changed Xtraz status (oscar/icq protocol)
+			// In this case only status' metadata changes, and no need
+			// to show this message (see bug #193402)
+			if ( newStatus.status() != oldStatus.status() )
+			{
 			QString contactName = m_messagePart->formatName(contact, Qt::PlainText);
 			sendInternalMessage( i18n( "%2 is now %1.",
 				newStatus.description(), contactName ) );
 		}
 	}
+	}
 
 	// update the windows caption
 	slotChatDisplayNameChanged();
--- trunk/KDE/kdenetwork/kopete/kopete/chatwindow/chatview.h #1282233:1282234
@@ -318,6 +318,12 @@
 	void slotContactStatusChanged( Kopete::Contact *contact, const Kopete::OnlineStatus \
&status, const Kopete::OnlineStatus &oldstatus );  
 	/**
+	 * Called when a contact changes status message.
+	 * @param contact The contact who changed status
+	 */
+	void slotStatusMessageChanged( Kopete::Contact *contact );
+
+	/**
 	 * Called when the chat's display name is changed
 	 */
 	void slotChatDisplayNameChanged();
--- trunk/KDE/kdenetwork/kopete/libkopete/kopetechatsession.cpp #1282233:1282234
@@ -439,7 +439,7 @@
 void Kopete::ChatSession::addContact( const Kopete::Contact *c, bool suppress )
 {
 	//kDebug( 14010 ) ;
-	if ( d->contacts.contains( \
(Kopete::Contact*)(Kopete::Contact*)(Kopete::Contact*)(Kopete::Contact*)(Kopete::Contact*)(Kopete::Contact*)(Kopete::Contact*)(Kopete::Contact*)(Kopete::Contact*)c \
) ) +	if ( d->contacts.contains( (Kopete::Contact*)c ) )
 	{
 		kDebug( 14010 ) << "Contact already exists";
 //		emit contactAdded( c, suppress );
@@ -455,8 +455,7 @@
 			d->contacts.removeAll( old );
 			d->contacts.append( (Kopete::Contact*)c );
 
-			disconnect( old, \
SIGNAL(onlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)),
                
-			this, SLOT(slotOnlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)) \
); +			disconnect( old, SIGNAL(statusMessageChanged(Kopete::Contact*)), this, \
SIGNAL(statusMessageChanged(Kopete::Contact*)) );  
 			if ( old->metaContact() )
 			{
@@ -477,9 +476,8 @@
 			emit contactAdded( c, suppress );
 		}
 
-		connect( c, SIGNAL(onlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)),
                
-			this, SLOT(slotOnlineStatusChanged(Kopete::Contact*,Kopete::OnlineStatus,Kopete::OnlineStatus)) \
                );
-;
+		connect( c, SIGNAL(statusMessageChanged(Kopete::Contact*)), this, \
SIGNAL(statusMessageChanged(Kopete::Contact*)) ); +
 		if ( c->metaContact() )
 		{
 			connect( c->metaContact(), SIGNAL(displayNameChanged(QString,QString)), this, \
                SLOT(slotUpdateDisplayName()) );
--- trunk/KDE/kdenetwork/kopete/libkopete/kopetechatsession.h #1282233:1282234
@@ -280,6 +280,11 @@
 	void onlineStatusChanged( Kopete::Contact *, const Kopete::OnlineStatus &, const \
Kopete::OnlineStatus & );  
 	/**
+	 * @brief a contact in this chat has changed his status message
+	 */
+	void statusMessageChanged( Kopete::Contact* );
+
+	/**
 	 * @brief a contact in this chat has changed his nickname
 	 */
 	void nickNameChanged( Kopete::Contact *, const QString & );
--- trunk/KDE/kdenetwork/kopete/libkopete/kopetecontact.cpp #1282233:1282234
@@ -194,6 +194,8 @@
 		setProperty( Kopete::Global::Properties::self()->statusMessage(), \
statusMessage.message() );  else
 		removeProperty( Kopete::Global::Properties::self()->statusMessage() );
+
+	emit statusMessageChanged( this );
 }
 
 void Contact::slotAccountIsConnectedChanged()
--- trunk/KDE/kdenetwork/kopete/libkopete/kopetecontact.h #1282233:1282234
@@ -481,6 +481,11 @@
 		const Kopete::OnlineStatus &status, const Kopete::OnlineStatus &oldStatus );
 
 	/**
+	 * The contact's status message changed
+	 */
+	void statusMessageChanged( Kopete::Contact *contact );
+
+	/**
 	 * The contact is about to be destroyed.
 	 * Called when entering the destructor. Useful for cleanup, since
 	 * metaContact() is still accessible at this point.
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/aim/aimuserinfo.cpp #1282233:1282234
@@ -59,7 +59,7 @@
 	QObject::connect(this, SIGNAL(user1Clicked()), this, SLOT(slotUpdateClicked()));
 	QObject::connect(this, SIGNAL(cancelClicked()), this, SLOT(slotCloseClicked()));
 	QObject::connect(c, SIGNAL(updatedProfile()), this, SLOT(slotUpdateProfile()));
-	QObject::connect(c, SIGNAL(statusMessageChanged()), this, \
SLOT(slotUpdateProfile())); +	QObject::connect(c, SIGNAL(statusMessageChanged( \
Kopete::Contact* )), this, SLOT(slotUpdateProfile()));  
 	mMainWidget->txtScreenName->setText( c->contactId() );
 
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/icq/icqcontact.cpp #1282233:1282234
@@ -139,22 +139,33 @@
 	{
 		presence.setFlags( presence.flags() | Oscar::Presence::ExtStatus2 );
 		presence.setMood( details.statusMood() );
-		setProperty( mProtocol->statusTitle, details.personalMessage() );
+
+		Kopete::StatusMessage msg;
+		msg.setTitle( details.personalMessage() );
+		setStatusMessage( msg );
 	}
 	// XStatus don't support offline status so don't show it (xtrazStatusSpecified can \
be true if contact was online)  else if ( details.xtrazStatus() != -1 && \
presence.type() != Oscar::Presence::Offline )  {
 		presence.setFlags( presence.flags() | Oscar::Presence::XStatus );
 		presence.setXtrazStatus( details.xtrazStatus() );
+
+		Kopete::StatusMessage msg;
+		msg.setTitle( details.personalMessage() );
+		setStatusMessage( msg );
 	}
 	else if ( !details.personalMessage().isEmpty() )
 	{
 		presence.setFlags( presence.flags() | Oscar::Presence::ExtStatus );
-		setProperty( mProtocol->statusTitle, details.personalMessage() );
+
+		Kopete::StatusMessage msg;
+		msg.setTitle( details.personalMessage() );
+		setStatusMessage( msg );
 	}
 	else
 	{
-		removeProperty( mProtocol->statusTitle );
+		Kopete::StatusMessage msg;
+		setStatusMessage( msg ); // set an empty status message
 	}
 
 	setPresenceTarget( presence );
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/icqcontactbase.cpp #1282233:1282234
@@ -51,12 +51,9 @@
 	setPresenceTarget( presence );
 
 	Kopete::StatusMessage statusMessage;
-	if ( !description.isEmpty() )
-		setProperty( static_cast<OscarProtocol*>( protocol() )->statusTitle, description \
                );
-	else
-		removeProperty( static_cast<OscarProtocol*>( protocol() )->statusTitle );
-
-	setAwayMessage( message );
+	statusMessage.setTitle( description );
+	statusMessage.setMessage( message );
+	setStatusMessage( statusMessage );
 }
 
 #include "icqcontactbase.moc"
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/oscarcontact.cpp #1282233:1282234
@@ -398,7 +398,7 @@
 	else
 		removeProperty( static_cast<OscarProtocol*>( protocol() )->statusMessage );
 
-	emit statusMessageChanged();
+	emit statusMessageChanged( this );
 }
 
 void OscarContact::changeContactEncoding()
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/oscarcontact.h #1282233:1282234
@@ -141,9 +141,6 @@
 
 	void requestAuthorization();
 
-signals:
-	void statusMessageChanged();
-
 protected slots:
 	void slotTyping( bool typing );
 	void messageAck( const QString& contact, uint messageId );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic