summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/nowlistening
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/plugins/nowlistening
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/plugins/nowlistening')
-rw-r--r--kopete/plugins/nowlistening/DESIGN52
-rw-r--r--kopete/plugins/nowlistening/Makefile.am25
-rw-r--r--kopete/plugins/nowlistening/README41
-rw-r--r--kopete/plugins/nowlistening/configure.in.in59
-rw-r--r--kopete/plugins/nowlistening/kopete_nowlistening.desktop125
-rw-r--r--kopete/plugins/nowlistening/kopete_nowlistening_config.desktop121
-rw-r--r--kopete/plugins/nowlistening/nlamarok.cpp125
-rw-r--r--kopete/plugins/nowlistening/nlamarok.h40
-rw-r--r--kopete/plugins/nowlistening/nljuk.cpp112
-rw-r--r--kopete/plugins/nowlistening/nljuk.h41
-rw-r--r--kopete/plugins/nowlistening/nlkaffeine.cpp101
-rw-r--r--kopete/plugins/nowlistening/nlkaffeine.h40
-rw-r--r--kopete/plugins/nowlistening/nlkscd.cpp121
-rw-r--r--kopete/plugins/nowlistening/nlkscd.h41
-rw-r--r--kopete/plugins/nowlistening/nlmediaplayer.h58
-rw-r--r--kopete/plugins/nowlistening/nlnoatun.cpp147
-rw-r--r--kopete/plugins/nowlistening/nlnoatun.h41
-rw-r--r--kopete/plugins/nowlistening/nlxmms.cpp73
-rw-r--r--kopete/plugins/nowlistening/nlxmms.h41
-rw-r--r--kopete/plugins/nowlistening/nowlisteningchatui.rc9
-rw-r--r--kopete/plugins/nowlistening/nowlisteningconfig.kcfg54
-rw-r--r--kopete/plugins/nowlistening/nowlisteningconfig.kcfgc8
-rw-r--r--kopete/plugins/nowlistening/nowlisteningguiclient.cpp79
-rw-r--r--kopete/plugins/nowlistening/nowlisteningguiclient.h53
-rw-r--r--kopete/plugins/nowlistening/nowlisteningplugin.cpp554
-rw-r--r--kopete/plugins/nowlistening/nowlisteningplugin.h111
-rw-r--r--kopete/plugins/nowlistening/nowlisteningpreferences.cpp95
-rw-r--r--kopete/plugins/nowlistening/nowlisteningpreferences.h59
-rw-r--r--kopete/plugins/nowlistening/nowlisteningprefs.ui376
-rw-r--r--kopete/plugins/nowlistening/nowlisteningui.rc6
30 files changed, 2808 insertions, 0 deletions
diff --git a/kopete/plugins/nowlistening/DESIGN b/kopete/plugins/nowlistening/DESIGN
new file mode 100644
index 00000000..d2be5d5f
--- /dev/null
+++ b/kopete/plugins/nowlistening/DESIGN
@@ -0,0 +1,52 @@
+Now Listening Plugin
+
+What It Does
+
+This plugin tells your chat buddies what media (music, ...) you are currently enjoying. If you turn on "Now Listening" for a contact, when a new track begins, it automatically sends a user defined message.
+
+How It Does It
+Looks for running media applications (Noatun, Kscd, Xmms) using DCOP and asks them what track they are currently playing. The current track is discovered on a periodic basis, and if it has changed, it is advertised in live chatwindows to contacts that the user has indicated should be notified.
+
+Fair Points
+Do we want to tell ALL chat partners what we're listening to?
+- The operation of the plugin is configurable for each contact, using a context menu item.
+
+IRC chats probably DON'T want extraneous bumf.
+- Yes, by using KMM::protocol() we can discover which protocol a chat uses and squelch messages to it. Would need something like a view of QCheckListItems to change the user's per protocol preferences in the Config.
+
+Should we only advertise if the other party to the chat is online?
+- Yes
+
+Is it possible to tell whether media players are actually playing?
+- Not for KsCD, but we can and do for Noatun and xmms.
+
+Alternative methods
+Is there a way to be notified when tracks change?
+- Not yet, but xmms and noatun seem to provide an interface to find out how long a track will be playing for. Could try and predict when a track will change.
+Of course, if ppl change tracks before the track has ended then this prediction is no good. To do this we would need to add a per mediaplayer timer, or at least a pointer to a timer in the plugin (ugly!).
+
+Discovering all live chatwindows
+KopeteMessageManagerFactory::factory()->sessions(), or Kopete::sessionFactory() until that is implemented?
+- Done
+
+OOOH - HOW ABOUT SEEING IF XMMS-KDE HAS DCOP IN IT?
+NO IT DOESN'T
+
+How contact specific plugin data works
+Each metacontact has a method pluginData(KopetePlugin *). This takes a pointer to a plugin, and returns a QStringList containing the metacontact's data for that plugin. A corresponding setPluginData() method changes this. Who is responsible for making sure this data persists?
+
+What about custom actions?
+KopetePlugin::custom[Chat|ContextMenuActions] both return a set of KActions that the plugin wants to have added to the UI. Looking at contactnotes, it seems that this set is recreated every time thses methods are called and they change the state of the plugin (currentContact). Is this so that the context menu is generated individually for each MC, so that the method that is called when the men item is clicked know which MC it applies to?
+
+Choosing whether to advertise to all contacts
+We can either advertise periodically to (some) contacts, or we could just add an Action to advertise what we're currently listening to.
+DONE
+
+Maybe need a per-contact toggle, and a per-chat button to advertise.
+DONE
+
+Customising the advert message
+DONE
+Maybe provide substitution as in "Now listening to %track by %artist (on %album)". Here () indicates substitute whole clause only if enclosed variable is set.
+
+Change so action inserts text in current message?
diff --git a/kopete/plugins/nowlistening/Makefile.am b/kopete/plugins/nowlistening/Makefile.am
new file mode 100644
index 00000000..a9357d5f
--- /dev/null
+++ b/kopete/plugins/nowlistening/Makefile.am
@@ -0,0 +1,25 @@
+METASOURCES = AUTO
+
+AM_CPPFLAGS = $(KOPETE_INCLUDES) $(XMMS_INCLUDES) $(all_includes)
+
+kde_module_LTLIBRARIES = kopete_nowlistening.la kcm_kopete_nowlistening.la
+
+kopete_nowlistening_la_SOURCES = nowlisteningconfig.kcfgc nowlisteningplugin.cpp nlkscd.cpp nlnoatun.cpp nlxmms.cpp nowlisteningguiclient.cpp nljuk.cpp nlamarok.cpp nlkaffeine.cpp
+kopete_nowlistening_la_LDFLAGS = -module $(KDE_PLUGIN) $(XMMS_LDFLAGS) $(all_libraries)
+kopete_nowlistening_la_LIBADD = ../../libkopete/libkopete.la $(XMMS_LIBS)
+
+kcm_kopete_nowlistening_la_SOURCES = nowlisteningprefs.ui nowlisteningpreferences.cpp nowlisteningconfig.kcfgc
+kcm_kopete_nowlistening_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN) $(all_libraries)
+kcm_kopete_nowlistening_la_LIBADD = $(LIB_KOPETECOMPAT) $(LIB_KUTILS)
+
+service_DATA = kopete_nowlistening.desktop
+servicedir = $(kde_servicesdir)
+
+kcm_DATA = kopete_nowlistening_config.desktop
+kcmdir = $(kde_servicesdir)/kconfiguredialog
+
+kde_kcfg_DATA = nowlisteningconfig.kcfg
+
+mydatadir = $(kde_datadir)/kopete
+mydata_DATA = nowlisteningui.rc nowlisteningchatui.rc
+noinst_HEADERS = nlkaffeine.h
diff --git a/kopete/plugins/nowlistening/README b/kopete/plugins/nowlistening/README
new file mode 100644
index 00000000..83bdd6d1
--- /dev/null
+++ b/kopete/plugins/nowlistening/README
@@ -0,0 +1,41 @@
+README for Now Listening Plugin
+
+AUTHOR Will Stephenson <lists@stevello.free-online.co.uk>
+
+This plugin tells chat partners what you're currently listening to. On demand, it sends them a configurable message.
+
+Caveat: It currently only works with KsCD, Xmms, Noatun, JuK and amaroK. Other media players will be supported shortly.
+
+Caveat 2: It relies on DCOP - I doubt much will happen if you're not running the rest of KDE.
+
+Caveat 3: There's no escaping of the substituted strings, so you might get it stuck in a loop...
+
+REQUIREMENTS
+Requires XMMS remote control header xmmsctrl.h
+(can be found in:
+* SuSE's base xmms rpm
+* Mandrake's libxmms1-devel rpm
+* RedHat, TurboLinux, Conectiva: xmms-devel )
+Which in turn requires glib-devel and gtk-devel to build.
+
+IF CONFIGURE GIVES AN ERROR, OR IT DOESN'T WORK WITH XMMS, CHECK THESE ARE INSTALLED!
+
+Configure test doesn't tell us that this is why it bails.
+
+Rerun make -f Makefile.cvs && ./configure - or any subset of that which will
+reconfigure the new part of the tree.
+
+make
+
+USE
+
+Enable the plugin in Settings->Configure Plugins. You may wish to change the default message.
+
+You can force a notification by typing the string "/media" at the start of a new message, which will be substituted, or by using the Chat->Actions->Send Media Info menu item.
+
+BUGS
+
+Please report to bugs.kde.org. If you need help contact me at lists@stevello.free-online.co.uk.
+
+TODO
+More media players!
diff --git a/kopete/plugins/nowlistening/configure.in.in b/kopete/plugins/nowlistening/configure.in.in
new file mode 100644
index 00000000..08309761
--- /dev/null
+++ b/kopete/plugins/nowlistening/configure.in.in
@@ -0,0 +1,59 @@
+dnl AM_PATH_XMMS([1.0.0])
+dnl AM_INIT_AUTOMAKE(mediacontrol, 0.1)
+dnl AC_PATH_PROG(XMMS_CONFIG, xmms-config, no)
+dnl AM_PATH_XMMS(1.0.0,,AC_MSG_ERROR([*** XMMS >= 1.0.0 not installed - please install first ***]))
+
+AC_DEFUN([AC_CHECK_XMMS],
+[
+ AC_MSG_CHECKING([for libxmms])
+ AC_CACHE_VAL(ac_cv_have_xmms,
+ [
+ ac_save_libs="$LIBS"
+ LIBS="`xmms-config --libs`"
+ ac_CPPFLAGS_save="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $all_includes `xmms-config --cflags`"
+ ac_LDFLAGS_save="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $all_libraries"
+ AC_TRY_LINK(
+ [#include <xmms/xmmsctrl.h>],
+ [xmms_remote_stop(0);],
+ [ac_cv_have_xmms="yes"],
+ [ac_cv_have_xmms="no"]
+ )
+ LIBS="$ac_save_libs"
+ LDFLAGS="$ac_LDFLAGS_save"
+ CPPFLAGS="$ac_CPPFLAGS_save"
+ ])
+ AC_MSG_RESULT($ac_cv_have_xmms)
+ if test "$ac_cv_have_xmms" = "yes"; then
+ XMMS_INCLUDES="`xmms-config --cflags`"
+
+ for arg in `xmms-config --libs`; do
+ case $arg in
+ -[[lL]]*)
+ XMMS_LIBS="$XMMS_LIBS $arg"
+ ;;
+ *)
+ XMMS_LDFLAGS="$XMMS_LDFLAGS $arg"
+ esac
+ done
+ AC_DEFINE(HAVE_XMMS, 1, [Define if you have xmms libraries and header files.])
+ fi
+])
+
+AC_ARG_WITH(xmms,
+ [AC_HELP_STRING(--with-xmms,
+ [enable support for XMMS @<:@default=check@:>@])],
+ [], with_xmms=check)
+
+if test "x$with_xmms" != xno; then
+ AC_CHECK_XMMS
+
+ if test "x$with_xmms" != xcheck && test "x$ac_cv_have_xmms" = xno; then
+ AC_MSG_ERROR([--with-xmms was given, but test for XMMS failed])
+ fi
+fi
+
+AC_SUBST(XMMS_LIBS)
+AC_SUBST(XMMS_LDFLAGS)
+AC_SUBST(XMMS_INCLUDES)
diff --git a/kopete/plugins/nowlistening/kopete_nowlistening.desktop b/kopete/plugins/nowlistening/kopete_nowlistening.desktop
new file mode 100644
index 00000000..871e7574
--- /dev/null
+++ b/kopete/plugins/nowlistening/kopete_nowlistening.desktop
@@ -0,0 +1,125 @@
+[Desktop Entry]
+Type=Service
+X-Kopete-Version=1000900
+Icon=kaboodle
+ServiceTypes=Kopete/Plugin
+X-KDE-Library=kopete_nowlistening
+X-KDE-PluginInfo-Author=Will Stephenson
+X-KDE-PluginInfo-Email=will@stevello.free-online.co.uk
+X-KDE-PluginInfo-Name=kopete_nowlistening
+X-KDE-PluginInfo-Version=0.8.0
+X-KDE-PluginInfo-Website=http://kopete.kde.org
+X-KDE-PluginInfo-Category=Plugins
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=false
+Name=Now Listening
+Name[ar]=الاستماع جار
+Name[be]=Слухаю зараз
+Name[bg]=Инфо за песен
+Name[bn]=এখন শুনছেন
+Name[bs]=Sada slušam
+Name[ca]=Ara s'escolta
+Name[cs]=Nyní poslouchám
+Name[cy]=Rwan yn Gwrando ar
+Name[da]=Lytter nu
+Name[de]=Im Hintergrund läuft
+Name[el]=Τώρα ακούω
+Name[eo]=Nun aŭskultanta
+Name[es]=Escuchando
+Name[et]=Praegu kuulan
+Name[eu]=Orain entzuten
+Name[fa]=الان گوش می‌کند
+Name[fi]=Nyt soi
+Name[fr]=En écoute
+Name[ga]=Ag Éisteacht Anois
+Name[gl]=Escoitando
+Name[he]=מאזין עכשיו
+Name[hi]=नाऊ लिसनिंग
+Name[hr]=Sada slušam
+Name[hu]=Most figyelek
+Name[is]=Hlustandi á
+Name[it]=Adesso sto ascoltando
+Name[ja]=今聴いているもの
+Name[ka]=ახლა ისმინება
+Name[kk]=Тыңдауда
+Name[km]=កំពុង​ស្ដាប់
+Name[lt]=Dabar klausau
+Name[mk]=Сега слуша
+Name[nb]=Hører nå
+Name[nds]=In'n Achtergrund löppt
+Name[ne]=अहिले सुनिरहेको छ
+Name[nl]=Luistert naar
+Name[nn]=Høyrer på
+Name[pa]=ਹੁਣ ਸੁਣਦਾ
+Name[pl]=Czego słucham
+Name[pt]=Agora a Ouvir
+Name[pt_BR]=Ouvindo agora
+Name[ru]=Сейчас звучит
+Name[se]=Dál guldaleamen
+Name[sk]=Teraz počúvam
+Name[sl]=Zdaj poslušam
+Name[sr]=Сада слушам
+Name[sr@Latn]=Sada slušam
+Name[sv]=Lyssnar nu
+Name[ta]=தற்போது கேட்டுக்கொண்டுள்ளார்
+Name[tg]=Ҳоло гӯшкунӣ рафта истодааст
+Name[tr]=Şimdi Dinleniyor
+Name[uk]=Зараз слухаю
+Name[zh_CN]=现在收听
+Name[zh_HK]=現正聆聽
+Name[zh_TW]=正在收聽
+Comment=Tells your buddies what you're listening to
+Comment[ar]=تخبر أصدقائك بما تستمع إليه
+Comment[be]=Паведамляе сябрам, што вы зараз слухаеце
+Comment[bg]=Приставка за информиране на приятелите какво слушате
+Comment[bn]=আপনার বন্ধুদের বলে আপনি কি শুনছেন
+Comment[bs]=Obavještava vaše prijatelje o muzici koju slušate
+Comment[ca]=Li diu als vostres companys què esteu escoltant
+Comment[cs]=Sdělí vašim kamarádům, co právě posloucháte
+Comment[cy]=Dweud wrth eich cyfeillion be y gwrandwch arnodd
+Comment[da]=Fortæller dine venner hvad du lytter til
+Comment[de]=Teilt Ihren Freunden mit, welche Musik Sie gerade hören
+Comment[el]=Ενημερώνει τους φίλους σας σχετικά με το τι ακούτε
+Comment[es]=Le cuenta a sus contactos lo que está escuchando
+Comment[et]=Semudele teatamine, mida parajasti kuulad
+Comment[eu]=Zure lagunei zer entzuten ari zaren esaten die
+Comment[fa]=به دوستان شما می‌گوید که به چه چیز گوش می‌دهید
+Comment[fi]=Kertoo kavereillesi mitä kuuntelet tällä hetkellä
+Comment[fr]=Indique à vos contacts ce que vous êtes en train d'écouter
+Comment[gl]=Dílle ós teus amigos que estás a escoitar
+Comment[he]=מספר לחבריך לאיזו מוסיקה אתה מאזין כרגע
+Comment[hi]=आपके बड्डीस को बताता है कि आप क्या सुन रहे हैं
+Comment[hr]=Govori vašim prijateljima što trenutno slušate
+Comment[hu]=A partnerek értesítése arról, hogy Ön mit hallgat
+Comment[is]=Segir vinum þínum á hvað þú ert að hlusta
+Comment[it]=Di' ai tuoi amici cosa stai ascoltando
+Comment[ja]=何を聴いているかを仲間に伝える
+Comment[ka]=ატყობინებს თქვენს მეგობრებს, თუ რას უსმენთ
+Comment[kk]=Достарыңызға тыңдап тұрғаныңыз туралы хабарлайды
+Comment[km]=ប្រាប់​សម្លាញ់​អ្នក​ថា អ្នក​កំពុង​ស្ដាប់​អ្វី
+Comment[lt]=Praneškite bičiuliams ką dabar klausotės
+Comment[mk]=Им кажува на вашите пријатели што слушате
+Comment[nb]=Forteller venner hva du hører på
+Comment[nds]=Vertellt Dien Frünnen, welke Musik Du jüst höörst
+Comment[ne]=तपाईँले सुनिरहनुभएको तपाईँको साथीलाई भन्दछ
+Comment[nl]=Vertelt je vrienden naar welke muziek je luistert
+Comment[nn]=Fortel venner kva du høyrer på
+Comment[pl]=Przekazuje znajomym, czego obecnie słuchasz
+Comment[pt]=Indica aos seus amigos o que você está a ouvir
+Comment[pt_BR]=Diz a seus colegas o que você está escutando
+Comment[ru]=Сообщает вашим собеседникам что вы сейчас слушаете
+Comment[se]=Muitala olbmáide maid dál leat guldaleamen
+Comment[sk]=Oznámi vašim priateľom, koho práve počúvate
+Comment[sl]=Sporočí vašim prijateljem, kaj poslušate
+Comment[sr]=Говори вашим другарима шта тренутно слушате
+Comment[sr@Latn]=Govori vašim drugarima šta trenutno slušate
+Comment[sv]=Talar om för kompisar vad du lyssnar på
+Comment[ta]=நீங்கள் கேட்டுக் கொண்டிருப்பதை உங்கள் எதிராலிக்கு சொல்லும்
+Comment[tg]=Ба дӯстонатон чи гӯш карда истодаатонро мегӯяд
+Comment[tr]=Dinlediğiniz arkadaşların listesini söyler
+Comment[uk]=Сповіщає ваших друзів про, те що ви зараз слухаєте
+Comment[zh_CN]=告诉您的好友您正在收听的内容
+Comment[zh_HK]=告訴您的伙伴您正在聆聽甚麼
+Comment[zh_TW]=告訴您的好友您正在收聽什麼
+
diff --git a/kopete/plugins/nowlistening/kopete_nowlistening_config.desktop b/kopete/plugins/nowlistening/kopete_nowlistening_config.desktop
new file mode 100644
index 00000000..8b01b2bd
--- /dev/null
+++ b/kopete/plugins/nowlistening/kopete_nowlistening_config.desktop
@@ -0,0 +1,121 @@
+[Desktop Entry]
+Icon=kaboodle
+Type=Service
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kopete_nowlistening
+X-KDE-FactoryName=NowListeningConfigFactory
+X-KDE-ParentApp=kopete_nowlistening
+X-KDE-ParentComponents=kopete_nowlistening
+
+Name=Now Listening
+Name[ar]=الاستماع جار
+Name[be]=Слухаю зараз
+Name[bg]=Инфо за песен
+Name[bn]=এখন শুনছেন
+Name[bs]=Sada slušam
+Name[ca]=Ara s'escolta
+Name[cs]=Nyní poslouchám
+Name[cy]=Rwan yn Gwrando ar
+Name[da]=Lytter nu
+Name[de]=Im Hintergrund läuft
+Name[el]=Τώρα ακούω
+Name[eo]=Nun aŭskultanta
+Name[es]=Escuchando
+Name[et]=Praegu kuulan
+Name[eu]=Orain entzuten
+Name[fa]=الان گوش می‌کند
+Name[fi]=Nyt soi
+Name[fr]=En écoute
+Name[ga]=Ag Éisteacht Anois
+Name[gl]=Escoitando
+Name[he]=מאזין עכשיו
+Name[hi]=नाऊ लिसनिंग
+Name[hr]=Sada slušam
+Name[hu]=Most figyelek
+Name[is]=Hlustandi á
+Name[it]=Adesso sto ascoltando
+Name[ja]=今聴いているもの
+Name[ka]=ახლა ისმინება
+Name[kk]=Тыңдауда
+Name[km]=កំពុង​ស្ដាប់
+Name[lt]=Dabar klausau
+Name[mk]=Сега слуша
+Name[nb]=Hører nå
+Name[nds]=In'n Achtergrund löppt
+Name[ne]=अहिले सुनिरहेको छ
+Name[nl]=Luistert naar
+Name[nn]=Høyrer på
+Name[pa]=ਹੁਣ ਸੁਣਦਾ
+Name[pl]=Czego słucham
+Name[pt]=Agora a Ouvir
+Name[pt_BR]=Ouvindo agora
+Name[ru]=Сейчас звучит
+Name[se]=Dál guldaleamen
+Name[sk]=Teraz počúvam
+Name[sl]=Zdaj poslušam
+Name[sr]=Сада слушам
+Name[sr@Latn]=Sada slušam
+Name[sv]=Lyssnar nu
+Name[ta]=தற்போது கேட்டுக்கொண்டுள்ளார்
+Name[tg]=Ҳоло гӯшкунӣ рафта истодааст
+Name[tr]=Şimdi Dinleniyor
+Name[uk]=Зараз слухаю
+Name[zh_CN]=现在收听
+Name[zh_HK]=現正聆聽
+Name[zh_TW]=正在收聽
+Comment=Tells your buddies what you're listening to
+Comment[ar]=تخبر أصدقائك بما تستمع إليه
+Comment[be]=Паведамляе сябрам, што вы зараз слухаеце
+Comment[bg]=Приставка за информиране на приятелите какво слушате
+Comment[bn]=আপনার বন্ধুদের বলে আপনি কি শুনছেন
+Comment[bs]=Obavještava vaše prijatelje o muzici koju slušate
+Comment[ca]=Li diu als vostres companys què esteu escoltant
+Comment[cs]=Sdělí vašim kamarádům, co právě posloucháte
+Comment[cy]=Dweud wrth eich cyfeillion be y gwrandwch arnodd
+Comment[da]=Fortæller dine venner hvad du lytter til
+Comment[de]=Teilt Ihren Freunden mit, welche Musik Sie gerade hören
+Comment[el]=Ενημερώνει τους φίλους σας σχετικά με το τι ακούτε
+Comment[es]=Le cuenta a sus contactos lo que está escuchando
+Comment[et]=Semudele teatamine, mida parajasti kuulad
+Comment[eu]=Zure lagunei zer entzuten ari zaren esaten die
+Comment[fa]=به دوستان شما می‌گوید که به چه چیز گوش می‌دهید
+Comment[fi]=Kertoo kavereillesi mitä kuuntelet tällä hetkellä
+Comment[fr]=Indique à vos contacts ce que vous êtes en train d'écouter
+Comment[gl]=Dílle ós teus amigos que estás a escoitar
+Comment[he]=מספר לחבריך לאיזו מוסיקה אתה מאזין כרגע
+Comment[hi]=आपके बड्डीस को बताता है कि आप क्या सुन रहे हैं
+Comment[hr]=Govori vašim prijateljima što trenutno slušate
+Comment[hu]=A partnerek értesítése arról, hogy Ön mit hallgat
+Comment[is]=Segir vinum þínum á hvað þú ert að hlusta
+Comment[it]=Di' ai tuoi amici cosa stai ascoltando
+Comment[ja]=何を聴いているかを仲間に伝える
+Comment[ka]=ატყობინებს თქვენს მეგობრებს, თუ რას უსმენთ
+Comment[kk]=Достарыңызға тыңдап тұрғаныңыз туралы хабарлайды
+Comment[km]=ប្រាប់​សម្លាញ់​អ្នក​ថា អ្នក​កំពុង​ស្ដាប់​អ្វី
+Comment[lt]=Praneškite bičiuliams ką dabar klausotės
+Comment[mk]=Им кажува на вашите пријатели што слушате
+Comment[nb]=Forteller venner hva du hører på
+Comment[nds]=Vertellt Dien Frünnen, welke Musik Du jüst höörst
+Comment[ne]=तपाईँले सुनिरहनुभएको तपाईँको साथीलाई भन्दछ
+Comment[nl]=Vertelt je vrienden naar welke muziek je luistert
+Comment[nn]=Fortel venner kva du høyrer på
+Comment[pl]=Przekazuje znajomym, czego obecnie słuchasz
+Comment[pt]=Indica aos seus amigos o que você está a ouvir
+Comment[pt_BR]=Diz a seus colegas o que você está escutando
+Comment[ru]=Сообщает вашим собеседникам что вы сейчас слушаете
+Comment[se]=Muitala olbmáide maid dál leat guldaleamen
+Comment[sk]=Oznámi vašim priateľom, koho práve počúvate
+Comment[sl]=Sporočí vašim prijateljem, kaj poslušate
+Comment[sr]=Говори вашим другарима шта тренутно слушате
+Comment[sr@Latn]=Govori vašim drugarima šta trenutno slušate
+Comment[sv]=Talar om för kompisar vad du lyssnar på
+Comment[ta]=நீங்கள் கேட்டுக் கொண்டிருப்பதை உங்கள் எதிராலிக்கு சொல்லும்
+Comment[tg]=Ба дӯстонатон чи гӯш карда истодаатонро мегӯяд
+Comment[tr]=Dinlediğiniz arkadaşların listesini söyler
+Comment[uk]=Сповіщає ваших друзів про, те що ви зараз слухаєте
+Comment[zh_CN]=告诉您的好友您正在收听的内容
+Comment[zh_HK]=告訴您的伙伴您正在聆聽甚麼
+Comment[zh_TW]=告訴您的好友您正在收聽什麼
+
diff --git a/kopete/plugins/nowlistening/nlamarok.cpp b/kopete/plugins/nowlistening/nlamarok.cpp
new file mode 100644
index 00000000..15d19411
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlamarok.cpp
@@ -0,0 +1,125 @@
+/*
+ nlamarok.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+ Kopete
+ Copyright (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to amaroK by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+#include <qstring.h>
+
+#include "nlmediaplayer.h"
+#include "nlamarok.h"
+
+NLamaroK::NLamaroK( DCOPClient *client ) : NLMediaPlayer()
+{
+ m_client = client;
+ m_type = Audio;
+ m_name = "Amarok";
+}
+
+void NLamaroK::update()
+{
+ m_playing = false;
+ m_newTrack = false;
+ QString newTrack;
+ QByteArray data, replyData;
+ QCString replyType;
+ QString result;
+
+ // see if amaroK is registered with DCOP
+ if ( !m_client->isApplicationRegistered( "amarok" ) )
+ {
+ kdDebug ( 14307 ) << "AmaroK is not running!\n" << endl;
+ return;
+ }
+
+ // see if it's playing
+ // use status() call first, if not supported (amaroK 1.0 or earlier), use isPlaying
+
+ if ( !m_client->call( "amarok", "player", "status()", data,
+ replyType, replyData ) )
+ {
+ kdDebug( 14307 ) << k_funcinfo << " DCOP status() returned error, falling back to isPlaying()." << endl;
+ if ( !m_client->call( "amarok", "player", "isPlaying()", data,
+ replyType, replyData ) )
+ {
+ kdDebug( 14307 ) << k_funcinfo << " DCOP error on Amarok." << endl;
+ }
+ else
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "bool" ) {
+ reply >> m_playing;
+ }
+ }
+ }
+ else
+ {
+ int status = 0;
+
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "int" ) {
+ reply >> status;
+ kdDebug( 14307 ) << k_funcinfo << "Amarok status()=" << status << endl;
+ }
+
+ if ( status )
+ {
+ m_playing = true;
+ }
+ }
+
+ if ( m_client->call( "amarok", "player", "title()", data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+
+ if ( replyType == "QString" ) {
+ reply >> newTrack;
+ }
+ }
+
+ if ( newTrack != m_track )
+ {
+ m_newTrack = true;
+ m_track = newTrack;
+ }
+
+ if ( m_client->call( "amarok", "player", "album()", data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+
+ if ( replyType == "QString" ) {
+ reply >> m_album;
+ }
+ }
+
+ if ( m_client->call( "amarok", "player", "artist()", data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+
+ if ( replyType == "QString" ) {
+ reply >> m_artist;
+ }
+ }
+}
+
diff --git a/kopete/plugins/nowlistening/nlamarok.h b/kopete/plugins/nowlistening/nlamarok.h
new file mode 100644
index 00000000..b79900c2
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlamarok.h
@@ -0,0 +1,40 @@
+/*
+ nlamarok.h
+
+ Kopete Now Listening To plugin
+
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to amaroK by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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 NLAMAROK_H
+#define NLAMAROK_H
+
+#include <dcopclient.h>
+
+class NLamaroK : public NLMediaPlayer
+{
+ public:
+ NLamaroK( DCOPClient *client );
+ virtual void update();
+ protected:
+ DCOPClient *m_client;
+};
+
+#endif
+
diff --git a/kopete/plugins/nowlistening/nljuk.cpp b/kopete/plugins/nowlistening/nljuk.cpp
new file mode 100644
index 00000000..41de23bc
--- /dev/null
+++ b/kopete/plugins/nowlistening/nljuk.cpp
@@ -0,0 +1,112 @@
+/*
+ nljuk.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+ Copyright (c) 2003 by Ismail Donmez <ismail.donmez@boun.edu.tr>
+ Copyright (c) 2002,2003 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to JuK by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+#include <qstring.h>
+
+#include "nlmediaplayer.h"
+#include "nljuk.h"
+
+NLJuk::NLJuk( DCOPClient *client ) : NLMediaPlayer()
+{
+ m_client = client;
+ m_type = Audio;
+ m_name = "JuK";
+}
+
+void NLJuk::update()
+{
+ m_playing = false;
+ QString newTrack;
+
+ // see if JuK is registered with DCOP
+ if ( m_client->isApplicationRegistered( "juk" ) )
+ {
+ // see if it's playing
+ QByteArray data, replyData;
+ QCString replyType;
+ QString result;
+
+ if ( m_client->call( "juk", "Player", "playing()", data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "bool" ) {
+ reply >> m_playing;
+ }
+ }
+
+ {
+ QDataStream arg( data, IO_WriteOnly );
+ arg << QString::fromLatin1("Album");
+ if ( m_client->call( "juk", "Player", "trackProperty(QString)", data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+
+ if ( replyType == "QString" ) {
+ reply >> m_album;
+ }
+ }
+ }
+
+ {
+ QDataStream arg( data, IO_WriteOnly );
+ arg << QString::fromLatin1("Artist");
+ if ( m_client->call( "juk", "Player", "trackProperty(QString)", data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+
+ if ( replyType == "QString" ) {
+ reply >> m_artist;
+ }
+ }
+ }
+
+ {
+ QDataStream arg( data, IO_WriteOnly );
+ arg << QString::fromLatin1("Title");
+ if ( m_client->call( "juk", "Player", "trackProperty(QString)", data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+
+ if ( replyType == "QString" ) {
+ reply >> newTrack;
+ }
+ }
+ }
+
+ if ( newTrack != m_track )
+ {
+ m_newTrack = true;
+ m_track = newTrack;
+ }
+ else
+ m_newTrack = false;
+ }
+ else
+ kdDebug( 14307 ) << "Juk is not running!\n" << endl;
+}
+
diff --git a/kopete/plugins/nowlistening/nljuk.h b/kopete/plugins/nowlistening/nljuk.h
new file mode 100644
index 00000000..40794c59
--- /dev/null
+++ b/kopete/plugins/nowlistening/nljuk.h
@@ -0,0 +1,41 @@
+/*
+ nljuk.h
+
+ Kopete Now Listening To plugin
+
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+ Copyright (c) 2003 by Ismail Donmez <ismail.donmez@boun.edu.tr>
+
+ Kopete (c) 2002,2003 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to JuK by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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 NLJUK_H
+#define NLJUK_H
+
+#include <dcopclient.h>
+
+class NLJuk : public NLMediaPlayer
+{
+ public:
+ NLJuk( DCOPClient *client );
+ virtual void update();
+ protected:
+ DCOPClient *m_client;
+};
+
+#endif
+
diff --git a/kopete/plugins/nowlistening/nlkaffeine.cpp b/kopete/plugins/nowlistening/nlkaffeine.cpp
new file mode 100644
index 00000000..fe02077f
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlkaffeine.cpp
@@ -0,0 +1,101 @@
+/*
+ nlkaffeine.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2004 by Will Stephenson <will@stevello.free-online.co.uk>
+ Kopete
+ Copyright (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to Kaffeine by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+#include <qstring.h>
+
+#include "nlmediaplayer.h"
+#include "nlkaffeine.h"
+
+NLKaffeine::NLKaffeine( DCOPClient *client ) : NLMediaPlayer()
+{
+ m_client = client;
+ m_type = Video;
+ m_name = "Kaffeine";
+}
+
+void NLKaffeine::update()
+{
+ m_playing = false;
+ m_newTrack = false;
+ QString newTrack;
+ bool error = true; // Asume we have a error first.
+ QCString kaffeineIface("Kaffeine"), kaffeineGetTrack("getTitle()");
+
+ // see if kaffeine is registered with DCOP
+ if ( m_client->isApplicationRegistered( "kaffeine" ) )
+ {
+ // see if it's playing
+ QByteArray data, replyData;
+ QCString replyType;
+ QString result;
+ if ( !m_client->call( "kaffeine", kaffeineIface, "isPlaying()", data,
+ replyType, replyData ) )
+ {
+ kdDebug ( 14307 ) << k_funcinfo << " Trying DCOP interface of Kaffeine >= 0.5" << endl;
+ // Trying with the new Kaffeine DCOP interface (>=0.5)
+ kaffeineIface = "KaffeineIface";
+ kaffeineGetTrack = "title()";
+ if( !m_client->call( "kaffeine", kaffeineIface, "isPlaying()", data, replyType, replyData ) )
+ {
+ kdDebug( 14307 ) << k_funcinfo << " DCOP error on Kaffeine." << endl;
+ }
+ else
+ {
+ error = false;
+ }
+ }
+ else
+ {
+ error = false;
+ }
+
+ // If we didn't get any DCOP error, check if Kaffeine is playing.
+ if(!error)
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "bool" ) {
+ reply >> m_playing;
+ kdDebug( 14307 ) << "checked if Kaffeine is playing!" << endl;
+ }
+ }
+
+ if ( m_client->call( "kaffeine", kaffeineIface, kaffeineGetTrack, data,
+ replyType, replyData ) )
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+
+ if ( replyType == "QString" ) {
+ reply >> newTrack;
+ }
+ }
+ if( newTrack != m_track )
+ {
+ m_newTrack = true;
+ m_track = newTrack;
+ }
+ }
+ else
+ kdDebug ( 14307 ) << "Kaffeine is not running!\n" << endl;
+}
+
diff --git a/kopete/plugins/nowlistening/nlkaffeine.h b/kopete/plugins/nowlistening/nlkaffeine.h
new file mode 100644
index 00000000..7f868e79
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlkaffeine.h
@@ -0,0 +1,40 @@
+/*
+ nlkaffeine.h
+
+ Kopete Now Listening To plugin
+
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to Kaffeine by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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 NLKAFFEINE_H
+#define NLKAFFEINE_H
+
+#include <dcopclient.h>
+
+class NLKaffeine : public NLMediaPlayer
+{
+ public:
+ NLKaffeine( DCOPClient *client );
+ virtual void update();
+ protected:
+ DCOPClient *m_client;
+};
+
+#endif
+
diff --git a/kopete/plugins/nowlistening/nlkscd.cpp b/kopete/plugins/nowlistening/nlkscd.cpp
new file mode 100644
index 00000000..a20c809b
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlkscd.cpp
@@ -0,0 +1,121 @@
+/*
+ nlkscd.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to KsCD by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+#include <qstringlist.h>
+
+#include "nlmediaplayer.h"
+
+#include "nlkscd.h"
+
+NLKscd::NLKscd( DCOPClient *client ) : NLMediaPlayer()
+{
+ m_client = client;
+ m_type = Audio;
+ m_name = "KsCD";
+}
+
+void NLKscd::update()
+{
+ m_playing = false;
+ QString newTrack;
+ // see if it's registered with DCOP
+ if ( m_client->isApplicationRegistered( "kscd" ) )
+ {
+ // see if it's playing
+ QByteArray data, replyData;
+ QCString replyType;
+ if ( !m_client->call( "kscd", "CDPlayer", "playing()", data,
+ replyType, replyData ) )
+ {
+ // we're talking to a KsCD without the playing() method
+ m_playing = true;
+// kdDebug( 14307 ) << "NLKscd::update() - KsCD without playing()"
+// << endl;
+ }
+ else
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "bool" ) {
+ reply >> m_playing;
+// kdDebug( 14307 ) << "NLKscd::update() - KsCD is " <<
+// ( m_playing ? "" : "not " ) << "playing!" << endl;
+ }
+ }
+ // poll it for its current artist
+ if ( !m_client->call( "kscd", "CDPlayer",
+ "currentArtist()", data, replyType, replyData ) )
+ kdDebug( 14307 ) << "NLKscd::update() DCOP error"
+ << endl;
+ else {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "QString" )
+ reply >> m_artist;
+ else
+ kdDebug( 14307 ) << "NLKscd::update() trackList returned unexpected reply type!" << endl;
+ }
+
+ //album
+ if ( !m_client->call( "kscd", "CDPlayer",
+ "currentAlbum()", data, replyType, replyData ) )
+ kdDebug( 14307 ) << "NLKscd::update() DCOP error"
+ << endl;
+ else {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "QString" )
+ reply >> m_album;
+ else
+ kdDebug( 14307 ) << "NLKscd::update() trackList returned unexpected reply type!" << endl;
+ }
+
+ // Get the current track title
+ if ( !m_client->call( "kscd", "CDPlayer",
+ "currentTrackTitle()", data, replyType, replyData ) )
+ kdDebug( 14307 ) << "NLKscd::update() - there was some error using DCOP." << endl;
+ else {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "QString" ) {
+ reply >> newTrack;
+ //kdDebug( 14307 ) << "the result is: " << newTrack.latin1()
+ // << endl;
+ } else
+ kdDebug( 14307 ) << "NLKscd::update()- currentTrackTitle "
+ << "returned unexpected reply type!" << endl;
+ }
+ // if the current track title has changed
+ if ( newTrack != m_track )
+ {
+ m_newTrack = true;
+ m_track = newTrack;
+ }
+ else
+ m_newTrack = false;
+// kdDebug( 14307 ) << "NLKscd::update() - found kscd - "
+// << m_track << endl;
+
+ }
+// else
+// kdDebug( 14307 ) << "NLKscd::update() - kscd not found" << endl;
+}
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nlkscd.h b/kopete/plugins/nowlistening/nlkscd.h
new file mode 100644
index 00000000..e245ec76
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlkscd.h
@@ -0,0 +1,41 @@
+/*
+ nlkscd.h
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to Kscd by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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 NLKSCD_H
+#define NLKSCD_H
+
+#include <dcopclient.h>
+
+class NLKscd : public NLMediaPlayer
+{
+ public:
+ NLKscd( DCOPClient *client );
+ virtual void update();
+ protected:
+ DCOPClient *m_client;
+
+};
+
+#endif
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nlmediaplayer.h b/kopete/plugins/nowlistening/nlmediaplayer.h
new file mode 100644
index 00000000..5c619150
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlmediaplayer.h
@@ -0,0 +1,58 @@
+/*
+ nlmediaplayer.h
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ Represents a generic media player
+ and abstracts real media players' actual interfaces (DCOP for KDE apps,
+ otherwise anything goes!
+
+ *************************************************************************
+ * *
+ * 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 NLMEDIAPLAYER_H
+#define NLMEDIAPLAYER_H
+
+class NLMediaPlayer
+{
+ public:
+ enum NLMediaType { Audio, Video };
+ NLMediaPlayer() { m_playing = false; m_artist = ""; m_album = ""; m_track = ""; m_newTrack = false; }
+ virtual ~NLMediaPlayer() {}
+ /**
+ * This communicates with the actual mediaplayer and updates
+ * the model of its state in this class
+ */
+ virtual void update() = 0;
+ bool playing() const { return m_playing; }
+ bool newTrack() const { return m_newTrack; }
+ QString artist() const { return m_artist; }
+ QString album() const { return m_album; }
+ QString track() const { return m_track; }
+ QString name() const{ return m_name; }
+ NLMediaType mediaType() const { return m_type; }
+ protected:
+ // The name of the application
+ QString m_name;
+ bool m_playing;
+ bool m_newTrack;
+ QString m_artist;
+ QString m_album;
+ QString m_track;
+ NLMediaType m_type;
+};
+
+#endif
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nlnoatun.cpp b/kopete/plugins/nowlistening/nlnoatun.cpp
new file mode 100644
index 00000000..62bdc8ba
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlnoatun.cpp
@@ -0,0 +1,147 @@
+/*
+ nlnoatun.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to Noatun by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+#include "nlmediaplayer.h"
+#include "nlnoatun.h"
+
+NLNoatun::NLNoatun( DCOPClient *client ) : NLMediaPlayer()
+{
+ m_client = client;
+ m_name = "noatun";
+ // FIXME - detect current media type in update()
+ m_type = Audio;
+}
+
+void NLNoatun::update()
+{
+ // Thanks mETz for telling me about Noatun's currentProperty()
+ m_playing = false;
+ QString newTrack;
+ // see if it's registered with DCOP
+ QCString appname = find();
+ if ( !appname.isEmpty() )
+ {
+ // see if it's playing
+ QByteArray data, replyData;
+ QCString replyType;
+ if ( !m_client->call( appname, "Noatun", "state()", data,
+ replyType, replyData ) )
+ {
+ kdDebug( 14307 ) << "NLNoatun::update() DCOP error on " << appname << endl;
+ }
+ else
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "int" ) {
+ int state = 0;
+ reply >> state;
+ m_playing = ( state == 2 );
+ //kdDebug( 14307 ) << "checked if Noatun is playing!" << endl;
+ }
+ }
+ // poll it for its current songtitle, artist and album
+ // Using properties
+ m_artist = currentProperty( appname, "author" );
+ m_album = currentProperty( appname, "album" );
+ QString title = currentProperty( appname, "title" );
+ // if properties not set ( no id3 tags... ) fallback to filename
+ if ( !title.isEmpty() )
+ newTrack = title;
+ else
+ // Using the title() method
+ if ( !m_client->call( appname, "Noatun",
+ "title()", data, replyType, replyData ) )
+ kdDebug( 14307 ) << "NLNoatun::update() DCOP error on " << appname
+ << endl;
+ else {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "QString" ) {
+ reply >> newTrack;
+ } else
+ kdDebug( 14307 ) << "NLNoatun::update(), title() returned unexpected reply type!" << endl;
+ }
+ // if the current track title has changed
+ if ( newTrack != m_track )
+ {
+ m_newTrack = true;
+ m_track = newTrack;
+ }
+ else
+ m_newTrack = false;
+ kdDebug( 14307 ) << "NLNoatun::update() - found "<< appname << " - "
+ << m_track << endl;
+
+ }
+ else
+ kdDebug( 14307 ) << "NLNoatun::update() - noatun not found" << endl;
+}
+
+QCString NLNoatun::find() const
+{
+ QCString app = "noatun";
+ if ( !m_client->isApplicationRegistered( app ) )
+ {
+ // looking for a registered app prefixed with 'app'
+ QCStringList allApps = m_client->registeredApplications();
+ QCStringList::iterator it;
+ for ( it = allApps.begin(); it != allApps.end(); it++ )
+ {
+ //kdDebug( 14307 ) << ( *it ) << endl;
+ if ( ( *it ).left( 6 ) == app )
+ {
+ app = ( *it );
+ break;
+ }
+ }
+ // not found, set app to ""
+ if ( it == allApps.end() )
+ app = "";
+ }
+ return app;
+}
+
+QString NLNoatun::currentProperty( QCString appname, QString property ) const
+{
+ QByteArray data, replyData;
+ QCString replyType;
+ QDataStream arg( data, IO_WriteOnly );
+ QString result = "";
+ arg << property;
+ if ( !m_client->call( appname, "Noatun",
+ "currentProperty(QString)", data, replyType, replyData ) )
+ {
+ kdDebug( 14307 ) << "NLNoatun::currentProperty() DCOP error on "
+ << appname << endl;
+ }
+ else
+ {
+ QDataStream reply( replyData, IO_ReadOnly );
+ if ( replyType == "QString" )
+ {
+ reply >> result;
+ }
+ }
+ return result;
+}
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nlnoatun.h b/kopete/plugins/nowlistening/nlnoatun.h
new file mode 100644
index 00000000..88441754
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlnoatun.h
@@ -0,0 +1,41 @@
+/*
+ nlnoatun.h
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002,2003,2004 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to Noatun by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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 NLNOATUN_H
+#define NLNOATUN_H
+
+#include <dcopclient.h>
+
+class NLNoatun : public NLMediaPlayer
+{
+ public:
+ NLNoatun( DCOPClient *client );
+ virtual void update();
+ protected:
+ QCString find() const;
+ QString currentProperty( QCString appname, QString property ) const;
+ DCOPClient *m_client;
+};
+
+#endif
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nlxmms.cpp b/kopete/plugins/nowlistening/nlxmms.cpp
new file mode 100644
index 00000000..f0a9f47a
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlxmms.cpp
@@ -0,0 +1,73 @@
+/*
+ nlxmms.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to the X Multimedia System (xmms) by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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. *
+ * *
+ *************************************************************************
+*/
+#include "config.h"
+
+#ifdef HAVE_XMMS
+
+#include <kdebug.h>
+#include <xmmsctrl.h> // need to fix Makefile.am for this?
+#include "nlmediaplayer.h"
+#include "nlxmms.h"
+
+NLXmms::NLXmms() : NLMediaPlayer()
+{
+ m_name = "Xmms";
+}
+
+
+void NLXmms::update()
+{
+ //look for running xmms
+ if ( xmms_remote_get_version( 0 ) )
+ {
+ QString newTrack;
+ // see if it's playing
+ if ( xmms_remote_is_playing( 0 ) && !xmms_remote_is_paused( 0 ) )
+ {
+ m_playing = true;
+
+ // get the artist and album title
+ // get the song title
+ newTrack = xmms_remote_get_playlist_title( 0, xmms_remote_get_playlist_pos( 0 ) );
+ //kdDebug( 14307 ) << "NLXmms::update() - track is: " << m_track << endl;
+ m_artist = newTrack.section( " - ", 0, 0 );
+ newTrack = newTrack.section( " - ", -1, -1 );
+ }
+ else
+ m_playing = false;
+ // check if it's a new song
+ if ( newTrack != m_track )
+ {
+ m_newTrack = true;
+ m_track = newTrack;
+ }
+ else
+ m_newTrack = false;
+ kdDebug( 14307 ) << k_funcinfo << " - found xmms - " << m_track << endl;
+ }
+ else
+ kdDebug( 14307 ) << k_funcinfo << " - xmms not found" << endl;
+}
+
+#endif
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nlxmms.h b/kopete/plugins/nowlistening/nlxmms.h
new file mode 100644
index 00000000..14c74ea8
--- /dev/null
+++ b/kopete/plugins/nowlistening/nlxmms.h
@@ -0,0 +1,41 @@
+/*
+ nlxmms.h
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002 by the Kopete developers <kopete-devel@kde.org>
+
+ Purpose:
+ This class abstracts the interface to the X Multimedia System (xmms) by
+ implementing NLMediaPlayer
+
+ *************************************************************************
+ * *
+ * 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. *
+ * *
+ *************************************************************************
+*/
+#include "config.h"
+
+#ifndef NLXMMS_H
+#define NLXMMS_H
+
+#ifdef HAVE_XMMS
+
+class NLXmms : public NLMediaPlayer
+{
+ public:
+ NLXmms();
+ virtual void update();
+};
+
+#endif
+
+#endif
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nowlisteningchatui.rc b/kopete/plugins/nowlistening/nowlisteningchatui.rc
new file mode 100644
index 00000000..9ab501f7
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningchatui.rc
@@ -0,0 +1,9 @@
+<!DOCTYPE kpartgui>
+<kpartgui version="1" name="kopete_nowlisteningchat">
+ <MenuBar>
+ <Menu name="tools">
+ <text>&amp;Tools</text>
+ <Action name="actionSendAdvert"/>
+ </Menu>
+ </MenuBar>
+</kpartgui>
diff --git a/kopete/plugins/nowlistening/nowlisteningconfig.kcfg b/kopete/plugins/nowlistening/nowlisteningconfig.kcfg
new file mode 100644
index 00000000..8233b737
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningconfig.kcfg
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Author: Michaël Larouche-->
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="kopeterc"/>
+
+ <group name="Now Listening Plugin">
+ <entry name="Header" type="String">
+ <label>Header of the message advertised.</label>
+ <default code="true">i18n("Now listening to:")</default>
+ </entry>
+
+ <entry name="PerTrack" type="String">
+ <label>Core of the message advertised.</label>
+ <default code="true">i18n("%track( by %artist)( on %album)")</default>
+ </entry>
+
+ <entry name="Conjunction" type="String">
+ <label>Conjunction when multiple track are playing.</label>
+ <default code="true">i18n(", and ")</default>
+ </entry>
+
+ <entry name="ExplicitAdvertising" type="Bool">
+ <label>Show explicitly the current music listened via a menu or /media command.</label>
+ <default>true</default>
+ </entry>
+
+ <entry name="ChatAdvertising" type="Bool">
+ <label>Show the current music listened in chat window.</label>
+ <default>false</default>
+ </entry>
+
+ <entry name="StatusAdvertising" type="Bool">
+ <label>Show the current music listened in place of your status message.</label>
+ <default>false</default>
+ </entry>
+
+ <entry name="AppendStatusAdvertising" type="Bool">
+ <label>Show the current music listened appended to your status message.</label>
+ <default>false</default>
+ </entry>
+
+ <entry name="UseSpecifiedMediaPlayer" type="Bool">
+ <label>Use the specified media player.</label>
+ <default>false</default>
+ </entry>
+
+ <entry name="SelectedMediaPlayer" type="Int">
+ <label>Selected Media Player for source of listening advertising.</label>
+ </entry>
+ </group>
+</kcfg>
diff --git a/kopete/plugins/nowlistening/nowlisteningconfig.kcfgc b/kopete/plugins/nowlistening/nowlisteningconfig.kcfgc
new file mode 100644
index 00000000..87c53b77
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningconfig.kcfgc
@@ -0,0 +1,8 @@
+# Code generation options for kconfig_compiler
+File=nowlisteningconfig.kcfg
+ClassName=NowListeningConfig
+Singleton=true
+Mutators=true
+MemberVariables=private
+GlobalEnums=true
+IncludeFiles=klocale.h
diff --git a/kopete/plugins/nowlistening/nowlisteningguiclient.cpp b/kopete/plugins/nowlistening/nowlisteningguiclient.cpp
new file mode 100644
index 00000000..8e7b1908
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningguiclient.cpp
@@ -0,0 +1,79 @@
+/*
+ nowlisteningguiclient.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2005 by Tommi Rantala <tommi.rantala@cs.helsinki.fi>
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ 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. *
+ * *
+ *************************************************************************
+*/
+
+#include "nowlisteningguiclient.h"
+#include "nowlisteningplugin.h"
+
+#include "kopetechatsessionmanager.h"
+#include "kopeteview.h"
+
+#include <kdebug.h>
+#include <kaction.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+NowListeningGUIClient::NowListeningGUIClient( Kopete::ChatSession *parent, NowListeningPlugin *plugin )
+ : QObject(parent) , KXMLGUIClient(parent)
+{
+ connect(plugin, SIGNAL(readyForUnload()), SLOT(slotPluginUnloaded()));
+ m_msgManager = parent;
+ m_action = new KAction( i18n( "Send Media Info" ), 0, this,
+ SLOT( slotAdvertToCurrentChat() ), actionCollection(), "actionSendAdvert" );
+ setXMLFile("nowlisteningchatui.rc");
+}
+
+void NowListeningGUIClient::slotAdvertToCurrentChat()
+{
+ kdDebug( 14307 ) << k_funcinfo << endl;
+
+ // Sanity check - don't crash if the plugin is unloaded and we get called.
+ if (!NowListeningPlugin::plugin())
+ return;
+
+ QString message = NowListeningPlugin::plugin()->mediaPlayerAdvert();
+
+ // We warn in a mode appropriate to the mode the user invoked the
+ // plugin - GUI on menu action, in message if they typed '/media'
+ if ( message.isEmpty() )
+ {
+ QWidget * origin = 0L;
+ if ( m_msgManager && m_msgManager->view() )
+ origin = m_msgManager->view()->mainWidget();
+ KMessageBox::queuedMessageBox( origin, KMessageBox::Sorry,
+ i18n( "None of the supported media players (KsCD, JuK, amaroK, Noatun or Kaffeine) are playing anything." ),
+ i18n( "Nothing to Send" ) );
+ }
+ else
+ {
+ //advertise to a single chat
+ if ( m_msgManager )
+ NowListeningPlugin::plugin()->advertiseToChat( m_msgManager, message );
+ }
+}
+
+// The plugin itself is being unloaded - so remove the GUI entry.
+void NowListeningGUIClient::slotPluginUnloaded()
+{
+ m_action->unplugAll();
+}
+
+#include "nowlisteningguiclient.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nowlisteningguiclient.h b/kopete/plugins/nowlistening/nowlisteningguiclient.h
new file mode 100644
index 00000000..9f89d351
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningguiclient.h
@@ -0,0 +1,53 @@
+/*
+ nowlisteningguiclient.h
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2005 by Tommi Rantala <tommi.rantala@cs.helsinki.fi>
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ 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 NOWLISTENINGGUICLIENT_H
+#define NOWLISTENINGGUICLIENT_H
+
+#include <qobject.h>
+#include <kxmlguiclient.h>
+
+class KAction;
+class NowListeningPlugin;
+
+namespace Kopete {
+ class ChatSession;
+}
+
+class NowListeningGUIClient : public QObject, public KXMLGUIClient
+{
+ Q_OBJECT
+
+public:
+ NowListeningGUIClient( Kopete::ChatSession* parent, NowListeningPlugin* plugin );
+ virtual ~NowListeningGUIClient() {}
+
+protected slots:
+ void slotAdvertToCurrentChat();
+ void slotPluginUnloaded();
+
+private:
+ Kopete::ChatSession* m_msgManager;
+ KAction* m_action;
+};
+
+#endif
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nowlisteningplugin.cpp b/kopete/plugins/nowlistening/nowlisteningplugin.cpp
new file mode 100644
index 00000000..e28316be
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningplugin.cpp
@@ -0,0 +1,554 @@
+/*
+ nowlisteningplugin.cpp
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+ Copyright (c) 2005-2006 by Michaël Larouche <michael.larouche@kdemail.net>
+
+ Kopete (c) 2002-2006 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. *
+ * *
+ *************************************************************************
+*/
+
+#include <qtimer.h>
+#include <qstringlist.h>
+#include <qregexp.h>
+
+#include <kdebug.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+#include <dcopclient.h>
+#include <kaction.h>
+
+#include "config.h"
+#include "kopetechatsessionmanager.h"
+#include "kopetemetacontact.h"
+#include "kopetecontact.h"
+#include "kopetecommandhandler.h"
+#include "kopeteaccount.h"
+#include "kopeteprotocol.h"
+#include "kopeteaccountmanager.h"
+
+#include "nowlisteningconfig.h"
+#include "nowlisteningplugin.h"
+#include "nlmediaplayer.h"
+#include "nlkscd.h"
+#include "nlnoatun.h"
+#include "nljuk.h"
+#include "nlamarok.h"
+#include "nlkaffeine.h"
+#include "nowlisteningguiclient.h"
+
+#if defined Q_WS_X11 && !defined K_WS_QTONLY && defined HAVE_XMMS
+#include "nlxmms.h"
+#endif
+
+class NowListeningPlugin::Private
+{
+public:
+ Private() : m_currentMediaPlayer(0L), m_client(0L), m_currentChatSession(0L), m_currentMetaContact(0L),
+ advertTimer(0L)
+ {}
+
+ // abstracted media player interfaces
+ QPtrList<NLMediaPlayer> m_mediaPlayerList;
+ NLMediaPlayer *m_currentMediaPlayer;
+
+ // Needed for DCOP interprocess communication
+ DCOPClient *m_client;
+ Kopete::ChatSession *m_currentChatSession;
+ Kopete::MetaContact *m_currentMetaContact;
+
+ // Used when using automatic advertising to know who has already gotten
+ // the music information
+ QStringList m_musicSentTo;
+
+ // Used when advertising to status message.
+ QTimer *advertTimer;
+};
+
+typedef KGenericFactory<NowListeningPlugin> NowListeningPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( kopete_nowlistening, NowListeningPluginFactory( "kopete_nowlistening" ) )
+
+NowListeningPlugin::NowListeningPlugin( QObject *parent, const char* name, const QStringList& /*args*/ )
+: Kopete::Plugin( NowListeningPluginFactory::instance(), parent, name )
+{
+ if ( pluginStatic_ )
+ kdDebug( 14307 )<<"####"<<"Now Listening already initialized"<<endl;
+ else
+ pluginStatic_ = this;
+
+ d = new Private;
+
+ kdDebug(14307) << k_funcinfo << endl;
+
+ // Connection for the "/media" command (always needed)
+ connect( Kopete::ChatSessionManager::self(), SIGNAL(
+ chatSessionCreated( Kopete::ChatSession * )) , SLOT( slotNewKMM(
+ Kopete::ChatSession * ) ) );
+
+ // If autoadvertising is on...
+ connect(Kopete::ChatSessionManager::self(),
+ SIGNAL(aboutToSend(Kopete::Message&)),
+ this,
+ SLOT(slotOutgoingMessage(Kopete::Message&)));
+
+ QValueList<Kopete::ChatSession*> sessions = Kopete::ChatSessionManager::self()->sessions();
+ for (QValueListIterator<Kopete::ChatSession*> it= sessions.begin(); it!=sessions.end() ; ++it)
+ slotNewKMM( *it );
+
+ // get a pointer to the dcop client
+ d->m_client = kapp->dcopClient(); //new DCOPClient();
+
+ // set up known media players
+ d->m_mediaPlayerList.setAutoDelete( true );
+ d->m_mediaPlayerList.append( new NLKscd( d->m_client ) );
+ d->m_mediaPlayerList.append( new NLNoatun( d->m_client ) );
+ d->m_mediaPlayerList.append( new NLJuk( d->m_client ) );
+ d->m_mediaPlayerList.append( new NLamaroK( d->m_client ) );
+ d->m_mediaPlayerList.append( new NLKaffeine( d->m_client ) );
+
+#if defined Q_WS_X11 && !defined K_WS_QTONLY && HAVE_XMMS
+ d->m_mediaPlayerList.append( new NLXmms() );
+#endif
+
+ // User has selected a specific mediaPlayer so update the currentMediaPlayer pointer.
+ if( NowListeningConfig::self()->useSpecifiedMediaPlayer() )
+ {
+ updateCurrentMediaPlayer();
+ }
+
+ // watch for '/media' getting typed
+ Kopete::CommandHandler::commandHandler()->registerCommand(
+ this,
+ "media",
+ SLOT( slotMediaCommand( const QString &, Kopete::ChatSession * ) ),
+ i18n("USAGE: /media - Displays information on current song"),
+ 0
+ );
+
+ connect ( this , SIGNAL( settingsChanged() ) , this , SLOT( slotSettingsChanged() ) );
+
+ // Advert the accounts with the current listened track.
+ d->advertTimer = new QTimer(this);
+ connect(d->advertTimer, SIGNAL( timeout() ), this, SLOT( slotAdvertCurrentMusic() ) );
+ d->advertTimer->start(5000); // Update every 5 seconds
+}
+
+NowListeningPlugin::~NowListeningPlugin()
+{
+ //kdDebug( 14307 ) << k_funcinfo << endl;
+
+ delete d;
+
+ pluginStatic_ = 0L;
+}
+
+void NowListeningPlugin::slotNewKMM(Kopete::ChatSession *KMM)
+{
+ new NowListeningGUIClient( KMM, this );
+}
+
+NowListeningPlugin* NowListeningPlugin::plugin()
+{
+ return pluginStatic_ ;
+}
+
+void NowListeningPlugin::slotMediaCommand( const QString &args, Kopete::ChatSession *theChat )
+{
+ QString advert = mediaPlayerAdvert();
+ if ( advert.isEmpty() )
+ {
+ // Catch no players/no track playing message case:
+ // Since we can't stop a message send in a plugin, add some message text to
+ // prevent us sending an empty message
+ advert = i18n("Message from Kopete user to another user; used when sending media information even though there are no songs playing or no media players running", "Now Listening for Kopete - it would tell you what I am listening to, if I was listening to something on a supported media player.");
+ }
+
+ Kopete::Message msg( theChat->myself(),
+ theChat->members(),
+ advert + " " + args,
+ Kopete::Message::Outbound,
+ Kopete::Message::RichText
+ );
+
+ theChat->sendMessage( msg );
+}
+
+void NowListeningPlugin::slotOutgoingMessage(Kopete::Message& msg)
+{
+ // Only do stuff if autoadvertising is on
+ if(!NowListeningConfig::self()->chatAdvertising())
+ return;
+
+ QString originalBody = msg.plainBody();
+
+ // If it is a /media message, don't process it
+ if(originalBody.startsWith(NowListeningConfig::self()->header()))
+ return;
+
+ // What will be sent
+ QString newBody;
+
+ // Getting the list of contacts the message will be sent to to determine if at least
+ // one of them has never gotten the current music information.
+ Kopete::ContactPtrList dest = msg.to();
+ bool mustSendAnyway = false;
+ for( Kopete::Contact *c = dest.first() ; c ; c = dest.next() )
+ {
+ const QString& cId = c->contactId();
+ if( 0 == d->m_musicSentTo.contains( cId ) )
+ {
+ mustSendAnyway = true;
+
+ // The contact will get the music information so we put it in the list.
+ d->m_musicSentTo.push_back( cId );
+ }
+ }
+
+ bool newTrack = newTrackPlaying();
+
+ // We must send the music information if someone has never gotten it or the track(s)
+ // has changed since it was last sent.
+ if ( mustSendAnyway || newTrack )
+ {
+ QString advert = mediaPlayerAdvert(false); // false since newTrackPlaying() did the update
+ if( !advert.isEmpty() )
+ newBody = originalBody + "<br>" + advert;
+
+ // If we send because the information has changed since it was last sent, we must
+ // rebuild the list of contacts the latest information was sent to.
+ if( newTrack )
+ {
+ d->m_musicSentTo.clear();
+ for( Kopete::Contact *c = dest.first() ; c ; c = dest.next() )
+ {
+ d->m_musicSentTo.push_back( c->contactId() );
+ }
+ }
+ }
+
+ // If the body has been modified, change the message
+ if( !newBody.isEmpty() )
+ {
+ msg.setBody( newBody, Kopete::Message::RichText );
+ }
+}
+
+void NowListeningPlugin::slotAdvertCurrentMusic()
+{
+ // Do anything when statusAdvertising is off.
+ if( !NowListeningConfig::self()->statusAdvertising() && !NowListeningConfig::self()->appendStatusAdvertising() )
+ return;
+
+ // This slot is called every 5 seconds, so we check if we have a new track playing.
+ if( newTrackPlaying() )
+ {
+ QString advert;
+
+ QPtrList<Kopete::Account> accountsList = Kopete::AccountManager::self()->accounts();
+ for( Kopete::Account* a = accountsList.first(); a; a = accountsList.next() )
+ {
+ /*
+ NOTE:
+ MSN status message(personal message) use a special tag to advert the current music playing.
+ So, we don't send the all formatted string, send a special string seperated by ";".
+
+ Also, do not use MSN hack in appending mode.
+ */
+ if( a->protocol()->pluginId() == "MSNProtocol" && !NowListeningConfig::self()->appendStatusAdvertising() )
+ {
+ QString track, artist, album, mediaList;
+ bool isPlaying=false;
+
+ if( NowListeningConfig::self()->useSpecifiedMediaPlayer() && d->m_currentMediaPlayer )
+ {
+ if( d->m_currentMediaPlayer->playing() )
+ {
+ track = d->m_currentMediaPlayer->track();
+ artist = d->m_currentMediaPlayer->artist();
+ album = d->m_currentMediaPlayer->album();
+ mediaList = track + ";" + artist + ";" + album;
+ isPlaying = true;
+ }
+ }
+ else
+ {
+ for ( NLMediaPlayer* i = d->m_mediaPlayerList.first(); i; i = d->m_mediaPlayerList.next() )
+ {
+ if( i->playing() )
+ {
+ track = i->track();
+ artist = i->artist();
+ album = i->album();
+ mediaList = track + ";" + artist + ";" + album;
+ isPlaying = true;
+ }
+ }
+ }
+
+ // KDE4 TODO: Use the new status message framework, and remove this "hack".
+ if( isPlaying )
+ {
+ advert = QString("[Music]%1").arg(mediaList);
+ }
+
+ }
+ else
+ {
+ if( NowListeningConfig::self()->appendStatusAdvertising() )
+ {
+ // Check for the now listening message in parenthesis,
+ // include the header to not override other messages in parenthesis.
+ QRegExp statusSong( QString(" \\(%1.*\\)$").arg( NowListeningConfig::header()) );
+
+ // HACK: Don't keep appending the now listened song. Replace it in the status message.
+ advert = a->myself()->property( Kopete::Global::Properties::self()->awayMessage() ).value().toString();
+ // Remove the braces when they are no listened song.
+ QString mediaAdvert = mediaPlayerAdvert(false);
+ if(!mediaAdvert.isEmpty())
+ {
+ if(statusSong.search(advert) != -1)
+ {
+ advert = advert.replace(statusSong, QString(" (%1)").arg(mediaPlayerAdvert(false)) );
+ }
+ else
+ {
+ advert += QString(" (%1)").arg( mediaPlayerAdvert(false) );
+ }
+ }
+ else
+ {
+ advert = advert.replace(statusSong, "");
+ }
+ }
+ else
+ {
+ advert = mediaPlayerAdvert(false); // newTrackPlaying has done the update.
+ }
+ }
+
+ a->setOnlineStatus(a->myself()->onlineStatus(), advert);
+ }
+ }
+}
+
+QString NowListeningPlugin::mediaPlayerAdvert(bool update)
+{
+ // generate message for all players
+ QString message;
+
+ if( NowListeningConfig::self()->useSpecifiedMediaPlayer() && d->m_currentMediaPlayer != 0L )
+ {
+ buildTrackMessage(message, d->m_currentMediaPlayer, update);
+ }
+ else
+ {
+ for ( NLMediaPlayer* i = d->m_mediaPlayerList.first(); i; i = d->m_mediaPlayerList.next() )
+ {
+ buildTrackMessage(message, i, update);
+ }
+ }
+
+ kdDebug( 14307 ) << k_funcinfo << message << endl;
+
+ return message;
+}
+
+void NowListeningPlugin::buildTrackMessage(QString &message, NLMediaPlayer *player, bool update)
+{
+ QString perTrack = NowListeningConfig::self()->perTrack();
+
+ if(update)
+ player->update();
+ if ( player->playing() )
+ {
+ kdDebug( 14307 ) << k_funcinfo << player->name() << " is playing" << endl;
+ if ( message.isEmpty() )
+ message = NowListeningConfig::self()->header();
+
+ if ( message != NowListeningConfig::self()->header() ) // > 1 track playing!
+ message = message + NowListeningConfig::self()->conjunction();
+ message = message + substDepthFirst( player, perTrack, false );
+ }
+}
+
+bool NowListeningPlugin::newTrackPlaying(void) const
+{
+ if( NowListeningConfig::self()->useSpecifiedMediaPlayer() && d->m_currentMediaPlayer != 0L )
+ {
+ d->m_currentMediaPlayer->update();
+ if( d->m_currentMediaPlayer->newTrack() )
+ return true;
+ }
+ else
+ {
+ for ( NLMediaPlayer* i = d->m_mediaPlayerList.first(); i; i = d->m_mediaPlayerList.next() )
+ {
+ i->update();
+ if( i->newTrack() )
+ return true;
+ }
+ }
+ return false;
+}
+
+QString NowListeningPlugin::substDepthFirst( NLMediaPlayer *player,
+ QString in, bool inBrackets ) const
+{
+ QString track = player->track();
+ QString artist = player->artist();
+ QString album = player->album();
+ QString playerName = player->name();
+
+ for ( unsigned int i = 0; i < in.length(); i++ )
+ {
+ QChar c = in.at( i );
+ //kdDebug(14307) << "Now working on:" << in << " char is: " << c << endl;
+ if ( c == '(' )
+ {
+ // find matching bracket
+ int depth = 0;
+ //kdDebug(14307) << "Looking for ')'" << endl;
+ for ( unsigned int j = i + 1; j < in.length(); j++ )
+ {
+ QChar d = in.at( j );
+ //kdDebug(14307) << "Got " << d << endl;
+ if ( d == '(' )
+ depth++;
+ if ( d == ')' )
+ {
+ // have we found the match?
+ if ( depth == 0 )
+ {
+ // recursively replace contents of matching ()
+ QString substitution = substDepthFirst( player,
+ in.mid( i + 1, j - i - 1), true ) ;
+ in.replace ( i, j - i + 1, substitution );
+ // perform substitution and return the result
+ i = i + substitution.length() - 1;
+ break;
+ }
+ else
+ depth--;
+ }
+ }
+ }
+ }
+ // no () found, perform substitution!
+ // get each string (to) to substitute for (from)
+ bool done = false;
+ if ( in.contains ( "%track" ) )
+ {
+ if ( track.isEmpty() )
+ track = i18n("Unknown track");
+
+ in.replace( "%track", track );
+ done = true;
+ }
+
+ if ( in.contains ( "%artist" ) && !artist.isEmpty() )
+ {
+ if ( artist.isEmpty() )
+ artist = i18n("Unknown artist");
+ in.replace( "%artist", artist );
+ done = true;
+ }
+ if ( in.contains ( "%album" ) && !album.isEmpty() )
+ {
+ if ( album.isEmpty() )
+ album = i18n("Unknown album");
+ in.replace( "%album", album );
+ done = true;
+ }
+ if ( in.contains ( "%player" ) && !playerName.isEmpty() )
+ {
+ if ( playerName.isEmpty() )
+ playerName = i18n("Unknown player");
+ in.replace( "%player", playerName );
+ done = true;
+ }
+ // make whether we return anything dependent on whether we
+ // were in brackets and if we were, if a substitution was made.
+ if ( inBrackets && !done )
+ return "";
+
+ return in;
+}
+
+void NowListeningPlugin::advertiseToChat( Kopete::ChatSession *theChat, QString message )
+{
+ Kopete::ContactPtrList pl = theChat->members();
+
+ // get on with it
+ kdDebug(14307) << k_funcinfo <<
+ ( pl.isEmpty() ? "has no " : "has " ) << "interested recipients: " << endl;
+/* for ( pl.first(); pl.current(); pl.next() )
+ kdDebug(14307) << "NowListeningPlugin::advertiseNewTracks() " << pl.current()->displayName() << endl; */
+ // if no-one in this KMM wants to be advertised to, don't send
+ // any message
+ if ( pl.isEmpty() )
+ return;
+ Kopete::Message msg( theChat->myself(),
+ pl,
+ message,
+ Kopete::Message::Outbound,
+ Kopete::Message::RichText );
+ theChat->sendMessage( msg );
+}
+
+void NowListeningPlugin::updateCurrentMediaPlayer()
+{
+ kdDebug(14307) << k_funcinfo << "Update current media player (single mode)" << endl;
+
+ d->m_currentMediaPlayer = d->m_mediaPlayerList.at( NowListeningConfig::self()->selectedMediaPlayer() );
+}
+
+void NowListeningPlugin::slotSettingsChanged()
+{
+ // Force reading config
+ NowListeningConfig::self()->readConfig();
+
+ // Update the currentMediaPlayer, because config has changed.
+ if( NowListeningConfig::useSpecifiedMediaPlayer() )
+ updateCurrentMediaPlayer();
+
+ disconnect(Kopete::ChatSessionManager::self(),
+ SIGNAL(aboutToSend(Kopete::Message&)),
+ this,
+ SLOT(slotOutgoingMessage(Kopete::Message&)));
+
+ d->advertTimer->stop();
+ disconnect(d->advertTimer, SIGNAL(timeout()), this, SLOT(slotAdvertCurrentMusic()));
+
+ if( NowListeningConfig::self()->chatAdvertising() )
+ {
+ kdDebug(14307) << k_funcinfo << "Now using chat window advertising." << endl;
+
+ connect(Kopete::ChatSessionManager::self(),
+ SIGNAL(aboutToSend(Kopete::Message&)),
+ this,
+ SLOT(slotOutgoingMessage(Kopete::Message&)));
+ }
+ else if( NowListeningConfig::self()->statusAdvertising() || NowListeningConfig::self()->appendStatusAdvertising() )
+ {
+ kdDebug(14307) << k_funcinfo << "Now using status message advertising." << endl;
+
+ connect(d->advertTimer, SIGNAL(timeout()), this, SLOT(slotAdvertCurrentMusic()));
+ d->advertTimer->start(5000);
+ }
+}
+
+NowListeningPlugin* NowListeningPlugin::pluginStatic_ = 0L;
+
+#include "nowlisteningplugin.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/nowlistening/nowlisteningplugin.h b/kopete/plugins/nowlistening/nowlisteningplugin.h
new file mode 100644
index 00000000..7a608fd2
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningplugin.h
@@ -0,0 +1,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 <qptrlist.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( QObject *parent, const char *name, const QStringList &args );
+ virtual ~NowListeningPlugin();
+ static NowListeningPlugin* plugin();
+
+ public slots:
+ void slotMediaCommand( const QString &, 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().
+ */
+ QString mediaPlayerAdvert(bool update = true);
+ /**
+ * @internal Build the message for @ref mediaPlayerAdvert
+ * @param message Reference to the messsage, because return QString 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(QString &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?
+ */
+ QString substDepthFirst( NLMediaPlayer *player, QString in, bool inBrackets) const;
+ /**
+ * Sends a message to a single chat
+ */
+ void advertiseToChat( Kopete::ChatSession* theChat, QString 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:
diff --git a/kopete/plugins/nowlistening/nowlisteningpreferences.cpp b/kopete/plugins/nowlistening/nowlisteningpreferences.cpp
new file mode 100644
index 00000000..179ce3a5
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningpreferences.cpp
@@ -0,0 +1,95 @@
+/*
+ nowlisteningpreferences.cpp
+
+ 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. *
+ * *
+ *************************************************************************
+*/
+#include <qspinbox.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include <qradiobutton.h>
+
+#include <klistbox.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+
+#include "config.h" // for HAVE_XMMS
+#include "nowlisteningprefs.h"
+#include "nowlisteningconfig.h"
+#include "nowlisteningpreferences.h"
+#include "nowlisteningpreferences.moc"
+
+typedef KGenericFactory<NowListeningPreferences> NowListeningPreferencesFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_kopete_nowlistening, NowListeningPreferencesFactory( "kcm_kopete_nowlistening" ) )
+
+
+NowListeningPreferences::NowListeningPreferences(QWidget *parent, const char* /*name*/, const QStringList &args)
+ : KCModule( NowListeningPreferencesFactory::instance(), parent, args )
+{
+ ( new QVBoxLayout( this ) )->setAutoAdd( true );
+ preferencesDialog = new NowListeningPrefsUI( this );
+
+ addConfig( NowListeningConfig::self(), preferencesDialog );
+
+ // Fill the media player listbox.
+ preferencesDialog->kcfg_SelectedMediaPlayer->insertItem(QString::fromUtf8("Kscd"));
+ preferencesDialog->kcfg_SelectedMediaPlayer->insertItem(QString::fromUtf8("Noatun"));
+ preferencesDialog->kcfg_SelectedMediaPlayer->insertItem(QString::fromUtf8("Juk"));
+ preferencesDialog->kcfg_SelectedMediaPlayer->insertItem(QString::fromUtf8("amaroK"));
+ preferencesDialog->kcfg_SelectedMediaPlayer->insertItem(QString::fromUtf8("Kaffeine"));
+#if defined Q_WS_X11 && !defined K_WS_QTONLY && defined HAVE_XMMS
+ preferencesDialog->kcfg_SelectedMediaPlayer->insertItem(QString::fromUtf8("XMMS"));
+#endif
+ load();
+}
+
+NowListeningPreferences::~NowListeningPreferences( )
+{
+ delete preferencesDialog;
+}
+
+void NowListeningPreferences::save()
+{
+ KCModule::save();
+}
+
+void NowListeningPreferences::load()
+{
+ KCModule::load();
+}
+
+void NowListeningPreferences::slotSettingsChanged()
+{
+ emit changed( true );
+}
+
+void NowListeningPreferences::defaults()
+{
+ /*preferencesDialog->m_header->setText( i18n("Now Listening To: "));
+ preferencesDialog->m_perTrack->setText(i18n("%track( by %artist)( on %album)"));
+ preferencesDialog->m_conjunction->setText( i18n(", and "));
+ preferencesDialog->m_autoAdvertising->setChecked( false );*/
+}
+
+/*
+* Local variables:
+* c-indentation-style: k&r
+* c-basic-offset: 8
+* indent-tabs-mode: t
+* End:
+*/
+// vim: set noet ts=4 sts=4 sw=4:
+//
diff --git a/kopete/plugins/nowlistening/nowlisteningpreferences.h b/kopete/plugins/nowlistening/nowlisteningpreferences.h
new file mode 100644
index 00000000..14d9ceea
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningpreferences.h
@@ -0,0 +1,59 @@
+/*
+ nowlisteningpreferences.h
+
+ Kopete Now Listening To plugin
+
+ Copyright (c) 2002,2003,2004 by Will Stephenson <will@stevello.free-online.co.uk>
+
+ Kopete (c) 2002,2003,2004 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 NOWLISTENINGPREFERENCES_H
+#define NOWLISTENINGPREFERENCES_H
+
+#include <kcmodule.h>
+
+class NowListeningPrefsUI;
+class NowListeningConfig;
+
+/**
+ *@author Will Stephenson
+ */
+
+class NowListeningPreferences : public KCModule
+{
+Q_OBJECT
+public:
+ NowListeningPreferences(QWidget *parent = 0, const char *name = 0, const QStringList &args = QStringList());
+ virtual ~NowListeningPreferences();
+ virtual void save();
+ virtual void load();
+ virtual void defaults();
+
+private slots:
+ void slotSettingsChanged();
+
+private:
+ NowListeningPrefsUI *preferencesDialog;
+
+};
+
+#endif
+/*
+ * Local variables:
+ * c-indentation-style: k&r
+ * c-basic-offset: 8
+ * indent-tabs-mode: t
+ * End:
+ */
+// vim: set noet ts=4 sts=4 sw=4:
+
diff --git a/kopete/plugins/nowlistening/nowlisteningprefs.ui b/kopete/plugins/nowlistening/nowlisteningprefs.ui
new file mode 100644
index 00000000..08dd72b9
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningprefs.ui
@@ -0,0 +1,376 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>NowListeningPrefsUI</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>NowListeningPrefsUI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>391</width>
+ <height>370</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Now Listening</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>advertiseNewMediaToBuddiesLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Share Your Musical Taste&lt;/b&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QFrame" row="1" column="0">
+ <property name="name">
+ <cstring>advertiseNewMediaToBuddiesHLine</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ </widget>
+ <widget class="QTabWidget" row="2" column="0">
+ <property name="name">
+ <cstring>tabWidget2</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Messa&amp;ge</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>useThisMessageLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Use this message when advertising:</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>helperLabel</cstring>
+ </property>
+ <property name="text">
+ <string>%track, %artist, %album, %player will be substituted if known.
+Expressions in brackets depend on a substitution being made.</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_headerLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Start with:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignLeft</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_header</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>kcfg_Header</cstring>
+ </property>
+ <property name="text">
+ <string>Now Listening To: </string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_perTrackLabel</cstring>
+ </property>
+ <property name="text">
+ <string>For each track:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignLeft</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_perTrack</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>kcfg_PerTrack</cstring>
+ </property>
+ <property name="text">
+ <string>%track (by %artist)(on %album)</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_conjunctionLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Conjunction (if &gt;1 track):</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignLeft</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>m_conjunction</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>kcfg_Conjunction</cstring>
+ </property>
+ <property name="text">
+ <string>, and </string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>A&amp;dvertising Mode</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>buttonGroup2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>kcfg_ExplicitAdvertising</cstring>
+ </property>
+ <property name="text">
+ <string>Explicit &amp;via "Tools-&gt;Send Media Info",
+or by typing "/media" in the chat
+window edit area.</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>kcfg_ChatAdvertising</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Show in chat window (automatic)</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>kcfg_StatusAdvertising</cstring>
+ </property>
+ <property name="text">
+ <string>Show &amp;the music you are listening to
+in place of your status message.</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>kcfg_AppendStatusAdvertising</cstring>
+ </property>
+ <property name="text">
+ <string>Appe&amp;nd to your status message</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>80</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Media Pla&amp;yer</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2_2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>kcfg_UseSpecifiedMediaPlayer</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;specified media player</string>
+ </property>
+ </widget>
+ <widget class="KListBox">
+ <property name="name">
+ <cstring>kcfg_SelectedMediaPlayer</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="columnMode">
+ <enum>FixedNumber</enum>
+ </property>
+ <property name="rowMode">
+ <enum>Variable</enum>
+ </property>
+ <property name="variableHeight">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>kcfg_UseSpecifiedMediaPlayer</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kcfg_SelectedMediaPlayer</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistbox.h</includehint>
+</includehints>
+</UI>
diff --git a/kopete/plugins/nowlistening/nowlisteningui.rc b/kopete/plugins/nowlistening/nowlisteningui.rc
new file mode 100644
index 00000000..149b3a69
--- /dev/null
+++ b/kopete/plugins/nowlistening/nowlisteningui.rc
@@ -0,0 +1,6 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kopete_nowlistening" version="1">
+ <Menu name="contact_popup">
+ <Action name="m_actionWantsAdvert"/>
+ </Menu>
+</kpartgui>