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

List:       kopete-devel
Subject:    [kopete-devel] Native nowlistening support
From:       Tiago Salem Herrmann <salem () mandriva ! com>
Date:       2008-11-30 15:36:36
Message-ID: 4932CEC8.7030406 () mandriva ! com
[Download RAW message or body]

Hi all,

I've been playing with nowlistening to WLM last days.
WLM protocol supports "listening to" in a native way, so we dont need to 
append strings to the "personal message", which I consider very bad.

I'm sending a patch, and it is just an initial idea, as I know we should 
not add setCurrentSong() method in Account class, but as we have 
setStatusMessage() there, it was my only idea.

Unfortunately I don't know kopete internals and at least for the moment 
I have no idea how to do this in a better way.
Any ideas?

Thanks

Tiago Salem Herrmann

["nowlistening-native-song-support.patch" (text/plain)]

Index: kopete/plugins/nowlistening/nowlisteningplugin.cpp
===================================================================
--- kopete/plugins/nowlistening/nowlisteningplugin.cpp	(revision 889523)
+++ kopete/plugins/nowlistening/nowlisteningplugin.cpp	(working copy)
@@ -286,6 +286,9 @@
 		{
 			Kopete::StatusMessage currentStatusMessage = a->myself()->statusMessage();
 
+			a->setCurrentSong(artist, track);
+
+
 			if(isPlaying)
 			{
 				currentStatusMessage.addMetaData("title", track);
Index: kopete/protocols/yahoo/yahooaccount.h
===================================================================
--- kopete/protocols/yahoo/yahooaccount.h	(revision 889523)
+++ kopete/protocols/yahoo/yahooaccount.h	(working copy)
@@ -137,6 +137,10 @@
 	/** Reimplemented from Kopete::Account */
 	void setOnlineStatus( const Kopete::OnlineStatus&, const Kopete::StatusMessage \
&reason = Kopete::StatusMessage());  void setStatusMessage(const \
Kopete::StatusMessage&); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
+
 signals:
 	/**
 	 * Emitted when we receive notification that the person we're talking to is typing
Index: kopete/protocols/gadu/gaduaccount.h
===================================================================
--- kopete/protocols/gadu/gaduaccount.h	(revision 889523)
+++ kopete/protocols/gadu/gaduaccount.h	(working copy)
@@ -73,6 +73,9 @@
 	void setOnlineStatus( const Kopete::OnlineStatus& status , const \
Kopete::StatusMessage &reason = Kopete::StatusMessage() );  void setStatusMessage( \
const Kopete::StatusMessage& statusMessage );  //}
+	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 	void changeStatus( const Kopete::OnlineStatus& status, const QString& descr = \
QString() );  void slotLogin( int status = GG_STATUS_AVAIL, const QString& dscr = \
                QString() );
Index: kopete/protocols/winpopup/wpaccount.h
===================================================================
--- kopete/protocols/winpopup/wpaccount.h	(revision 889523)
+++ kopete/protocols/winpopup/wpaccount.h	(working copy)
@@ -93,6 +93,9 @@
 	/* Reimplemented from Kopete::Account */
 	void setOnlineStatus( const Kopete::OnlineStatus &status , const \
Kopete::StatusMessage &reason = Kopete::StatusMessage());  void \
setStatusMessage(const Kopete::StatusMessage& statusMessage); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 protected:
 	virtual bool createContact(const QString &contactId, Kopete::MetaContact \
                *parentContact);
Index: kopete/protocols/qq/qqaccount.h
===================================================================
--- kopete/protocols/qq/qqaccount.h	(revision 889523)
+++ kopete/protocols/qq/qqaccount.h	(working copy)
@@ -75,6 +75,9 @@
 	 */
 	virtual void setOnlineStatus(const Kopete::OnlineStatus& status , const \
Kopete::StatusMessage &reason = Kopete::StatusMessage() );  virtual void \
setStatusMessage(const Kopete::StatusMessage& statusMessage); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 	/**
 	 * Connect/Disconnect 
Index: kopete/protocols/groupwise/gwaccount.h
===================================================================
--- kopete/protocols/groupwise/gwaccount.h	(revision 889523)
+++ kopete/protocols/groupwise/gwaccount.h	(working copy)
@@ -163,6 +163,9 @@
 	 * Set the status message for the account. Reimplemented from Kopete::Account
 	 */
 	void setStatusMessage( const Kopete::StatusMessage &statusMessage );
+	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 signals:
 	void conferenceCreated( const int mmId, const GroupWise::ConferenceGuid & guid );
Index: kopete/protocols/jabber/jabberaccount.h
===================================================================
--- kopete/protocols/jabber/jabberaccount.h	(revision 889523)
+++ kopete/protocols/jabber/jabberaccount.h	(working copy)
@@ -148,6 +148,9 @@
 	/* Reimplemented from Kopete::Account */
 	void setOnlineStatus( const Kopete::OnlineStatus& status, const \
Kopete::StatusMessage &reason = Kopete::StatusMessage());  void setStatusMessage( \
const Kopete::StatusMessage &statusMessage ); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 	void addTransport( JabberTransport *tr ,  const QString &jid);
 	void removeTransport( const QString &jid );
Index: kopete/protocols/jabber/jabbertransport.h
===================================================================
--- kopete/protocols/jabber/jabbertransport.h	(revision 889523)
+++ kopete/protocols/jabber/jabbertransport.h	(working copy)
@@ -91,6 +91,10 @@
 	/* Reimplemented from Kopete::Account */
 	void setOnlineStatus( const Kopete::OnlineStatus& status , const \
Kopete::StatusMessage &reason = Kopete::StatusMessage());  void setStatusMessage( \
const Kopete::StatusMessage &statusMessage ); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
+
 	/**
 	 * the account has been unregistered.
 	 * loop over all contact and remove them
Index: kopete/protocols/testbed/testbedaccount.h
===================================================================
--- kopete/protocols/testbed/testbedaccount.h	(revision 889523)
+++ kopete/protocols/testbed/testbedaccount.h	(working copy)
@@ -60,6 +60,10 @@
 	 */
 	virtual void setOnlineStatus(const Kopete::OnlineStatus& status , const \
Kopete::StatusMessage &reason = Kopete::StatusMessage() );  virtual void \
setStatusMessage(const Kopete::StatusMessage& statusMessage); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
+
 	/**
 	 * 'Connect' to the testbed server.  Only sets myself() online.
 	 */
Index: kopete/protocols/msn/msnaccount.h
===================================================================
--- kopete/protocols/msn/msnaccount.h	(revision 889523)
+++ kopete/protocols/msn/msnaccount.h	(working copy)
@@ -118,6 +118,10 @@
 	virtual void disconnect() ;
 	virtual void setOnlineStatus( const Kopete::OnlineStatus &status , const \
Kopete::StatusMessage &reason = Kopete::StatusMessage());  virtual void \
setStatusMessage( const Kopete::StatusMessage &statusMessage ); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
+
 	/**
 	 * Ask to the account to create a new chat session
 	 */
Index: kopete/protocols/wlm/wlmaccount.cpp
===================================================================
--- kopete/protocols/wlm/wlmaccount.cpp	(revision 889523)
+++ kopete/protocols/wlm/wlmaccount.cpp	(working copy)
@@ -130,10 +130,18 @@
 	return newContact != 0L;
 }
 
+void WlmAccount::setCurrentSong (const QString & artist, const QString & track)
+{
+    m_currentSongTrack = track;
+    m_currentSongArtist = artist;
+    setPersonalMessage (m_personalMessage);
+}
+ 
 void WlmAccount::setPersonalMessage (const Kopete::StatusMessage & reason)
 {
     kDebug (14210) << k_funcinfo;
     myself()->setStatusMessage(reason);
+    m_personalMessage = reason.message();
     if (isConnected ())
     {
         MSN::personalInfo pInfo;
@@ -142,11 +150,19 @@
             pInfo.PSM = "";
         else
             pInfo.PSM = reason.message().toAscii ().data ();
-//      pInfo.mediaType="Music";
-        pInfo.mediaIsEnabled = 0;
-//      pInfo.mediaFormat="{0} - {1}";
-//      pInfo.mediaLines.push_back("Artist");
-//      pInfo.mediaLines.push_back("Song");
+
+        if(m_currentSongTrack.isEmpty())
+        {
+            pInfo.mediaIsEnabled = 0;
+            m_server->cb.mainConnection->setPersonalStatus (pInfo);
+            return;
+        }
+
+        pInfo.mediaType="Music";
+        pInfo.mediaIsEnabled = 1;
+        pInfo.mediaFormat="{0} - {1}";
+        pInfo.mediaLines.push_back(m_currentSongArtist.toAscii ().data ());
+        pInfo.mediaLines.push_back(m_currentSongTrack.toAscii ().data ());
         m_server->cb.mainConnection->setPersonalStatus (pInfo);
     }
 }
Index: kopete/protocols/wlm/wlmaccount.h
===================================================================
--- kopete/protocols/wlm/wlmaccount.h	(revision 889523)
+++ kopete/protocols/wlm/wlmaccount.h	(working copy)
@@ -76,6 +76,9 @@
                      Kopete::StatusMessage ());
     virtual void
     setStatusMessage (const Kopete::StatusMessage & statusMessage);
+    void
+    setCurrentSong (const QString & artist, const QString & track);
+ 
         /**
 	 * 'Connect' to the wlm server.  Only sets myself() online.
 	 */
@@ -285,6 +288,11 @@
     QString
         m_pictureFilename;
 
+    QString m_personalMessage;
+    QString m_currentSongTrack;
+    QString m_currentSongArtist;
+ 
+
     bool
         m_initialList;
 
Index: kopete/protocols/telepathy/telepathyaccount.h
===================================================================
--- kopete/protocols/telepathy/telepathyaccount.h	(revision 889523)
+++ kopete/protocols/telepathy/telepathyaccount.h	(working copy)
@@ -135,7 +135,10 @@
 	
 	virtual void setOnlineStatus(const Kopete::OnlineStatus& status, const \
Kopete::StatusMessage &reason = Kopete::StatusMessage());  virtual void \
                setStatusMessage(const Kopete::StatusMessage &statusMessage);
-	
+		void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
+
 	/**
 	 * @brief Called from the menu to change the myself contact alias
 	 */
Index: kopete/protocols/sms/smsaccount.h
===================================================================
--- kopete/protocols/sms/smsaccount.h	(revision 889523)
+++ kopete/protocols/sms/smsaccount.h	(working copy)
@@ -52,6 +52,9 @@
 	void loadConfig();
 	void setOnlineStatus( const Kopete::OnlineStatus& status , const \
Kopete::StatusMessage &reason);  void setStatusMessage( const Kopete::StatusMessage& \
msg ); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 public slots:
 	virtual void connect(const Kopete::OnlineStatus& initial= Kopete::OnlineStatus());
Index: kopete/protocols/oscar/aim/aimaccount.h
===================================================================
--- kopete/protocols/oscar/aim/aimaccount.h	(revision 889523)
+++ kopete/protocols/oscar/aim/aimaccount.h	(working copy)
@@ -99,6 +99,10 @@
 	/** Reimplementation from Kopete::Account */
 	void setOnlineStatus( const Kopete::OnlineStatus& status, const \
Kopete::StatusMessage &reason = Kopete::StatusMessage() );  void setStatusMessage( \
const Kopete::StatusMessage& statusMessage ); +	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
+
 	void slotEditInfo();
 
 	void slotToggleInvisible();
Index: kopete/protocols/oscar/icq/icqaccount.h
===================================================================
--- kopete/protocols/oscar/icq/icqaccount.h	(revision 889523)
+++ kopete/protocols/oscar/icq/icqaccount.h	(working copy)
@@ -64,6 +64,11 @@
 	void setOnlineStatus( const Kopete::OnlineStatus&, const Kopete::StatusMessage \
&reason = Kopete::StatusMessage() );  void setStatusMessage( const \
Kopete::StatusMessage& );  
+	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
+
+
 	void connectWithPassword( const QString &password );
 
 	void setUserProfile( const QString &profile );
Index: kopete/protocols/meanwhile/meanwhileaccount.h
===================================================================
--- kopete/protocols/meanwhile/meanwhileaccount.h	(revision 889523)
+++ kopete/protocols/meanwhile/meanwhileaccount.h	(working copy)
@@ -112,6 +112,9 @@
     void setOnlineStatus(const Kopete::OnlineStatus& status,
             const Kopete::StatusMessage &reason = Kopete::StatusMessage());
     void setAway(bool away, const QString &reason = QString());
+    void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 private:
     /** Current online status */
Index: kopete/protocols/irc/ircaccount.h
===================================================================
--- kopete/protocols/irc/ircaccount.h	(revision 889523)
+++ kopete/protocols/irc/ircaccount.h	(working copy)
@@ -144,6 +144,9 @@
 	virtual void setOnlineStatus(const Kopete::OnlineStatus &status, const \
Kopete::StatusMessage &statusMessage);  
 	virtual void setStatusMessage(const Kopete::StatusMessage &statusMessage);
+	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 
 	// Returns the Kopete::Contact of the user
 	IRCContact *mySelf() const;
Index: kopete/protocols/bonjour/bonjouraccount.h
===================================================================
--- kopete/protocols/bonjour/bonjouraccount.h	(revision 889523)
+++ kopete/protocols/bonjour/bonjouraccount.h	(working copy)
@@ -159,7 +159,9 @@
 	 */
 	virtual void setOnlineStatus(const Kopete::OnlineStatus& status , const \
Kopete::StatusMessage &reason = Kopete::StatusMessage() );  virtual void \
                setStatusMessage(const Kopete::StatusMessage& statusMessage);
-	
+	void
+    setCurrentSong (const QString & artist, const QString & track) {};
+ 
 	/**
 	 * @brief 'Connect' to the bonjour service.
 	 *
Index: kopete/libkopete/kopeteaccount.h
===================================================================
--- kopete/libkopete/kopeteaccount.h	(revision 889523)
+++ kopete/libkopete/kopeteaccount.h	(working copy)
@@ -516,6 +516,8 @@
 	 * @param statusMessage is the status message to set. (Use Kopete::StatusMessage).
 	 */
 	virtual void setStatusMessage( const Kopete::StatusMessage &statusMessage ) = 0;
+	
+    virtual void setCurrentSong( const QString &, const QString & ) {};
 
 	/**
 	 * Display the edit account widget for the account



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


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

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