summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/nowlistening/nowlisteningplugin.h
blob: 848b8aef726d5044d8a9dceca48e50ef14c4ca8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
    nowlisteningplugin.h

    Kopete Now Listening To plugin

    Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
    Copyright (c) 2005           by Michaël Larouche <michael.larouche@kdemail.net>

    Kopete    (c) 2002-2005      by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#ifndef NOWLISTENINGPLUGIN_H
#define NOWLISTENINGPLUGIN_H


#include "kopeteplugin.h"
#include <tqptrlist.h>

namespace Kopete { class ChatSession; class Message; }

class NLMediaPlayer;
class QStringList;

/**
 * @author Will Stephenson
 * @author Michaël Larouche
 */
class NowListeningPlugin : public Kopete::Plugin
{
	Q_OBJECT

friend class NowListeningGUIClient;

	public:
		NowListeningPlugin(  TQObject *parent, const char *name, const TQStringList &args );
		virtual ~NowListeningPlugin();
		static NowListeningPlugin* plugin();

	public slots:
		void slotMediaCommand( const TQString &, Kopete::ChatSession *theChat );
		void slotOutgoingMessage(Kopete::Message&);
		void slotAdvertCurrentMusic();

	protected:
		/**
		 * Constructs a string containing the track information.
		 * @param update Whether the players must update their data. It can be
		 *               useful to set it to false if one already has called
		 *               update somewhere else, for instance in newTrackPlaying().
		 */
		TQString mediaPlayerAdvert(bool update = true);
		/**
		 * @internal Build the message for @ref mediaPlayerAdvert
		 * @param message Reference to the messsage, because return TQString cause data loss.
		 * @param player Pointer to the current Media Player. 
		 *               Used to get the information about the current track playing.
		 * @param update Whether the players must update their data. It can be
		 *               useful to set it to false if one already has called
		 *               update somewhere else, for instance in newTrackPlaying().
		 */
		void buildTrackMessage(TQString &message, NLMediaPlayer *player, bool update);
		/**
		 * @return true if one of the players has changed track since the last message.
		 */
		bool newTrackPlaying(void) const;
		/**
		 * Creates the string for a single player
		 * @p player - the media player we're using
		 * @p in - the source format string
		 * @p bool - is this call within a set of brackets for conditional expansion?
		 */
		TQString substDepthFirst( NLMediaPlayer *player, TQString in, bool inBrackets) const;
		/**
		 * Sends a message to a single chat
		 */
		void advertiseToChat( Kopete::ChatSession* theChat, TQString message );
		/**
		 * Update the currentMedia pointer on config change.
		 */
		void updateCurrentMediaPlayer();

	protected slots:
		/**
		 * Reacts to a new chat starting and adds actions to its GUI
		 */
		void slotNewKMM( Kopete::ChatSession* );
		
		/**
		 * Reacts to the plugin's settings changed signal, originating from the KCModule dispatcher
		 */ 
		void slotSettingsChanged();

	private:
		class Private;
		Private *d;

		static NowListeningPlugin* pluginStatic_;
};

#endif

// vim: set noet ts=4 sts=4 sw=4: