From 2e77c0b4ce1781d87a532022d8ebaccff0fb2b17 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 5 Jul 2011 19:32:49 +0000 Subject: Added kstreamripper git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kstreamripper@1239912 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/SConscript | 69 ++++++++ src/addnewstream.ui | 108 ++++++++++++ src/addnewstreamimpl.cpp | 66 +++++++ src/addnewstreamimpl.h | 48 +++++ src/hi16-app-kstreamripper.png | Bin 0 -> 1033 bytes src/hi32-app-kstreamripper.png | Bin 0 -> 2749 bytes src/kstreamripper.cpp | 309 +++++++++++++++++++++++++++++++++ src/kstreamripper.desktop | 16 ++ src/kstreamripper.h | 79 +++++++++ src/kstreamripper.lsm | 16 ++ src/kstreamripperbase.ui | 337 ++++++++++++++++++++++++++++++++++++ src/kstreamripperui.rc | 8 + src/main.cpp | 66 +++++++ src/processcontroller.cpp | 148 ++++++++++++++++ src/processcontroller.h | 71 ++++++++ src/processlistviewitem.cpp | 108 ++++++++++++ src/processlistviewitem.h | 71 ++++++++ src/processlistviewitem_interface.h | 38 ++++ 18 files changed, 1558 insertions(+) create mode 100644 src/SConscript create mode 100644 src/addnewstream.ui create mode 100644 src/addnewstreamimpl.cpp create mode 100644 src/addnewstreamimpl.h create mode 100644 src/hi16-app-kstreamripper.png create mode 100644 src/hi32-app-kstreamripper.png create mode 100644 src/kstreamripper.cpp create mode 100644 src/kstreamripper.desktop create mode 100644 src/kstreamripper.h create mode 100644 src/kstreamripper.lsm create mode 100644 src/kstreamripperbase.ui create mode 100644 src/kstreamripperui.rc create mode 100644 src/main.cpp create mode 100644 src/processcontroller.cpp create mode 100644 src/processcontroller.h create mode 100644 src/processlistviewitem.cpp create mode 100644 src/processlistviewitem.h create mode 100644 src/processlistviewitem_interface.h (limited to 'src') diff --git a/src/SConscript b/src/SConscript new file mode 100644 index 0000000..5d40432 --- /dev/null +++ b/src/SConscript @@ -0,0 +1,69 @@ +#! /usr/bin/env python +## This script demonstrates how to build and install +## a simple kde program having KconfigXT settings +## with scons +## +## Thomas Nagy, 2004, 2005 + +## This file can be reused freely for any project (see COPYING) + +############################ +## load the config + +## Use the environment and the tools set in the top-level +## SConstruct file (set with 'Export') - this is very important + +Import( 'env' ) +myenv=env.Copy() + +############################# +## the programs to build + +# The sources for our program - only .ui, .skel and .cpp are accepted +kstreamripper_sources = """ +addnewstreamimpl.cpp +addnewstream.ui +kstreamripperbase.ui +kstreamripper.cpp +main.cpp +processcontroller.cpp +processlistviewitem.cpp +""".split() + +# Our main program +# KDEprogram add the file to the install targets automatically, +# so you do not need to write KDEinstall('KDEBIN', '', test1, myenv) +myenv.KDEprogram( "kstreamripper", kstreamripper_sources ) + +############################ +## Customization + +## Additional include paths for compiling the source files +## Always add '../' (top-level directory) because moc makes code that needs it +myenv.KDEaddpaths_includes( ['./', '../'] ) + +## Necessary libraries to link against +myenv.KDEaddlibs( ['qt-mt', 'kio', 'kdeui'] ) +if env['KDEm2']>3: myenv.KDEaddlibs( ['kdnssd']) +############################# +## Data to install + +## The ui.rc file and the tips go into datadir/appname/ +myenv.KDEinstall( 'KDEDATA', 'kstreamripper', 'kstreamripperui.rc' ) + +## The kcfg file is installed in a global kcfg directory +#myenv.KDEinstall( 'KDEKCFG', '', 'test1.kcfg' ) + +## Warning : there is a difference between the normal destop file used for the menu +## and the servicetype desktop file, so they go in different directories +## you will find more information in 'test3' +myenv.KDEinstall( 'KDEMENU', 'Utilities', 'kstreamripper.desktop') + +## Use this when you need to install a mimetype file +#myenv.KDEinstall( 'KDEMIME', 'application', 'x-test1.desktop' ) + +## Installing icons is easy (hi-16-app-test1.png, hi-22-app-test1.png) +## do not forget that this is a python script so loops are allowed here :) +myenv.KDEicon( 'hi16-app-kstreameripper.png') +myenv.KDEicon( 'hi32-app-kstreameripper.png') + diff --git a/src/addnewstream.ui b/src/addnewstream.ui new file mode 100644 index 0000000..5b46733 --- /dev/null +++ b/src/addnewstream.ui @@ -0,0 +1,108 @@ + +AddNewStream + + + AddNewStream + + + + 0 + 0 + 383 + 287 + + + + Add Stream.... + + + TabFocus + + + + unnamed + + + + frame3 + + + StyledPanel + + + Raised + + + + unnamed + + + + d_nameLabel + + + Name: + + + + + d_descriptionLabel + + + Description: + + + + + d_nameEdit + + + + + d_urlEdit + + + + + d_descEdit + + + + + d_urlLabel + + + Url of Stream: + + + + + + + d_okButton + + + TabFocus + + + &Ok + + + Alt+O + + + + + d_cancelButton + + + &Cancel + + + Alt+C + + + + + + diff --git a/src/addnewstreamimpl.cpp b/src/addnewstreamimpl.cpp new file mode 100644 index 0000000..033e44e --- /dev/null +++ b/src/addnewstreamimpl.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2003-2005 by Michael Goettsche * + * mail@tuxipuxi.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include + +#include +#include + +#include "addnewstreamimpl.h" + + +AddNewStreamImpl::AddNewStreamImpl( QWidget* parent, const char* name ) + : AddNewStream( parent,name, true ) +{ + connect( d_okButton, SIGNAL( clicked()), this, SLOT( okButtonClicked()) ); + connect( d_cancelButton, SIGNAL( clicked()), this, SLOT( cancelButtonClicked()) ); +} + + +AddNewStreamImpl::~AddNewStreamImpl() +{ +} + + +//SLOTS + + +void AddNewStreamImpl::okButtonClicked() +{ + if( d_nameEdit->text() != "" && d_urlEdit->text() != "") + { + emit finished( this ); + this->close(); + } + else + { + KMessageBox::error( this, "You forgot to fill out one or more fields, please do it now.", + "Missing Information" ); + } +} + + +void AddNewStreamImpl::cancelButtonClicked() +{ + this->close(); +} + + + diff --git a/src/addnewstreamimpl.h b/src/addnewstreamimpl.h new file mode 100644 index 0000000..30bcb49 --- /dev/null +++ b/src/addnewstreamimpl.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2003-2005 by Michael Goettsche * + * mail@tuxipuxi.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef ADDNEWSTREAMIMPL_H +#define ADDNEWSTREAMIMPL_H + +#include "addnewstream.h" + +class AddNewStreamImpl : public AddNewStream +{ + Q_OBJECT + +public: + + AddNewStreamImpl( QWidget* parent = 0, const char* name = 0 ); + ~AddNewStreamImpl(); + +protected: + +protected slots: + + void okButtonClicked(); + void cancelButtonClicked(); + +signals: + + void finished( AddNewStreamImpl* ); +}; + +#endif + diff --git a/src/hi16-app-kstreamripper.png b/src/hi16-app-kstreamripper.png new file mode 100644 index 0000000..4ed606c Binary files /dev/null and b/src/hi16-app-kstreamripper.png differ diff --git a/src/hi32-app-kstreamripper.png b/src/hi32-app-kstreamripper.png new file mode 100644 index 0000000..45ae1a1 Binary files /dev/null and b/src/hi32-app-kstreamripper.png differ diff --git a/src/kstreamripper.cpp b/src/kstreamripper.cpp new file mode 100644 index 0000000..9641df2 --- /dev/null +++ b/src/kstreamripper.cpp @@ -0,0 +1,309 @@ +/*************************************************************************** + * Copyright (C) 2003-2005 by Michael Goettsche * + * mail@tuxipuxi.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kstreamripper.h" +#include "addnewstreamimpl.h" +#include "processlistviewitem.h" +#include "processcontroller.h" + + + +KStreamRipper::KStreamRipper( QWidget* parent, const char* name ) + : KStreamRipperBase( parent,name ) +#if KDE_IS_VERSION(3,3,90) + , m_browser("_shoutcast._tcp",0,true) +#endif +{ + m_destEdit->setText( QDir::homeDirPath() ); + + m_streamsListView->addColumn( "Name" ); + m_streamsListView->addColumn( "Status" ); + m_streamsListView->addColumn( "Size" ); + + //app config + KConfig *appConfig = KGlobal::config(); + + m_destEdit->setText( appConfig->readEntry( "Destination" , "" ) ); + m_timeEdit->setText( appConfig->readEntry( "Riptime", "0" )); + m_tuneInEdit->setText( appConfig->readEntry( "Command", "xmms " )); + m_id3Checkbox->setChecked( appConfig->readBoolEntry( "Id3Tag", 1 )); + + //listview entrys + QStringList nameList,urlList,descList; + + nameList = appConfig->readListEntry( "names" ); + urlList = appConfig->readListEntry( "urls" ); + descList = appConfig->readListEntry( "descs" ); + QStringList::iterator iter1, iter2, iter3; + iter1 = nameList.begin(); + iter2 = urlList.begin(); + iter3 = descList.begin(); + + for( ; iter1 != nameList.end() && iter2 != urlList.end() && iter3 != descList.end(); ++iter1, ++iter2, ++iter3 ) + { + ProcessListViewItem * proc = new ProcessListViewItem( m_streamsListView, *iter1, "", ""); + proc->setRenameEnabled(0, true); + proc->getProcessController()->setUrl( *iter2 ); + proc->getProcessController()->setDescription( *iter3 ); + } + + //CONNECTS + + //clicks + connect(m_addStreamButton, SIGNAL(clicked()), this, SLOT(addStreamButtonClicked())); + connect(m_deleteStreamButton, SIGNAL(clicked()), this, SLOT(deleteStreamButtonClicked())); + connect(m_tuneInButton, SIGNAL(clicked()), this, SLOT(tuneInButtonClicked())); + connect(m_ripButton, SIGNAL(clicked()), this, SLOT(ripButtonClicked())); + connect(m_stopRipButton, SIGNAL(clicked()), this, SLOT(stopRipButtonClicked())); + connect(m_browseButton, SIGNAL(clicked()), this, SLOT(browseButtonClicked())); + connect(m_aboutButton, SIGNAL(clicked()), this, SLOT(aboutButtonClicked())); + connect(m_quitButton, SIGNAL(clicked()), this, SLOT(quitButtonClicked())); + + //other + connect( m_streamsListView, SIGNAL(selectionChanged()), this, SLOT( selectedNewListItem()) ); + connect( m_DescriptionEdit, SIGNAL(textChanged(const QString&)), this, SLOT( descriptionChanged()) ); + connect( m_UrlEdit, SIGNAL(textChanged(const QString&)), this, SLOT( urlChanged()) ); + + // zeroconf +#if KDE_IS_VERSION(3,3,90) + connect(&m_browser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)), this, + SLOT(serviceAdded(DNSSD::RemoteService::Ptr))); + connect(&m_browser, SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)), this, + SLOT(serviceRemoved(DNSSD::RemoteService::Ptr))); + m_browser.startBrowse(); +#endif +} + + +KStreamRipper::~KStreamRipper() +{ +} + + +void KStreamRipper::closeEvent( QCloseEvent *e ) +{ + KConfig *appConfig = KGlobal::config(); + + appConfig->writeEntry( "Destination", m_destEdit->text()); + appConfig->writeEntry( "Riptime", m_timeEdit->text()); + appConfig->writeEntry( "Command", m_tuneInEdit->text()); + appConfig->writeEntry( "Id3Tag", m_id3Checkbox->isChecked()); + + //save the listview entrys + + QStringList nameList,urlList,descList; + QListViewItemIterator iter( m_streamsListView ); + + while( iter.current() ) + { + ProcessListViewItem * ProcItem = (ProcessListViewItem*)iter.current(); + if(ProcItem->getProcessController()->getAutomatic()) continue; + + nameList.append( iter.current()->text( 0 )); + urlList.append( ProcItem->getProcessController()->getUrl() ); + descList.append( ProcItem->getProcessController()->getDescription() ); + ++iter; + } + + appConfig->writeEntry( "names", nameList ); + appConfig->writeEntry( "urls" , urlList ); + appConfig->writeEntry( "descs", descList ); + + appConfig->sync(); + + e->accept(); +} + + +//SLOTS +void KStreamRipper::addStreamButtonClicked() +{ + AddNewStreamImpl *test = new AddNewStreamImpl( this ); + connect( test, SIGNAL( finished( AddNewStreamImpl* )), this, SLOT( addStreamFinished( AddNewStreamImpl* )) ); + + test->show(); +} + +void KStreamRipper::deleteStreamButtonClicked() +{ + ProcessListViewItem * ProcItem = (ProcessListViewItem*)m_streamsListView->currentItem(); + stopRipButtonClicked(); + delete ProcItem; +} + +void KStreamRipper::tuneInButtonClicked() +{ + if( m_streamsListView->currentItem() ) + { + QString command = m_tuneInEdit->text().replace( "", m_UrlEdit->text() ); + + QStringList commands = QStringList::split( " ", command ); + + QProcess *process = new QProcess( this ); + process->setArguments( commands ); + + process->start(); + } + else ; +} + +#if KDE_IS_VERSION(3,3,90) +void KStreamRipper::serviceAdded(DNSSD::RemoteService::Ptr srv) +{ + ProcessListViewItem * proc = new ProcessListViewItem( m_streamsListView, srv->serviceName(), "", ""); + proc->getProcessController()->setUrl( QString("http://%1:%2%3").arg(srv->hostName()).arg(srv->port()).arg(srv->textData()["path"]) ); + proc->getProcessController()->setDescription( i18n("found by Zeroconf") ); + proc->getProcessController()->setAutomatic(true); + proc->getProcessController()->setService(srv); + +} +void KStreamRipper::serviceRemoved(DNSSD::RemoteService::Ptr srv) +{ + QListViewItemIterator iter( m_streamsListView ); + + while( iter.current() ) { + ProcessListViewItem * ProcItem = (ProcessListViewItem*)iter.current(); + if (ProcItem->getProcessController()->getAutomatic() && + srv==ProcItem->getProcessController()->getService()) { + delete ProcItem; + return; + } + ++iter; + } + +} +#endif + +void KStreamRipper::ripButtonClicked() +{ + if (KStandardDirs::findExe("streamripper")) { + ProcessListViewItem * ProcItem = (ProcessListViewItem*)m_streamsListView->currentItem(); + ProcItem->getProcessController()->startRip(m_destEdit->text(), m_timeEdit->text()); + m_ripButton->setEnabled( false ); + m_stopRipButton->setEnabled( true ); + } else { + KMessageBox::error(this, "The streamripper executable wasn't found. Make sure " + "it's in your path.", "streamripper not found"); + } +} + +void KStreamRipper::stopRipButtonClicked() +{ + ProcessListViewItem * ProcItem = (ProcessListViewItem*)m_streamsListView->currentItem(); + ProcItem->getProcessController()->stopRip(); + m_ripButton->setEnabled( true ); + m_stopRipButton->setEnabled( false ); +} + +void KStreamRipper::browseButtonClicked() +{ + QString openDest = KFileDialog::getExistingDirectory( QDir::homeDirPath(), + this, + "Select Destination..." ); + m_destEdit->setText( openDest ); +} + +void KStreamRipper::aboutButtonClicked() +{ + KAboutApplication *aboutApp = new KAboutApplication(); + aboutApp->show(); +} + +void KStreamRipper::quitButtonClicked() +{ + this->close(); +} + +void KStreamRipper::selectedNewListItem() +{ + if ( !m_streamsListView->selectedItem() ) { + m_deleteStreamButton->setEnabled( false ); + m_tuneInButton->setEnabled( false ); + m_ripButton->setEnabled( false ); + m_DescriptionEdit->setText( QString::null ); + m_DescriptionEdit->setEnabled(false); + m_UrlEdit->setEnabled(false); + m_UrlEdit->setText( QString::null ); + return; + } + ProcessController * ProcCtl = ((ProcessListViewItem*)m_streamsListView->currentItem())->getProcessController(); + + // reconfigure what the user is allowed to do based on if this process is ripping + m_ripButton->setEnabled( !ProcCtl->getStatus() ); + m_stopRipButton->setEnabled( ProcCtl->getStatus() ); + m_tuneInButton->setEnabled( true ); + m_deleteStreamButton->setEnabled( !ProcCtl->getAutomatic() ); + + m_DescriptionEdit->setText(ProcCtl->getDescription()); + m_DescriptionEdit->setEnabled(true); + m_UrlEdit->setText(ProcCtl->getUrl()); + m_UrlEdit->setEnabled( !ProcCtl->getAutomatic() ); + + + // maybe these are more elegant than the next two functions, assuming the slots are implemented in ProcessController + //connect(m_DescriptionEdit, SIGNAL(textChanged(const QString&)), (ProcessListViewItem*)m_streamsListView->currentItem()->getProcessController(), SIGNAL(descriptionChanged(const QString&)) + //connect(m_UrlEdit, SIGNAL(textChanged(const QString&)), (ProcessListViewItem*)m_streamsListView->currentItem()->getProcessController(), SIGNAL(urlChanged(const QString&)) +} + +void KStreamRipper::descriptionChanged() +{ + // maybe this should be deleted and the communication would be through a slot + ProcessListViewItem * ProcItem = (ProcessListViewItem*)m_streamsListView->currentItem(); + ProcItem->getProcessController()->setDescription(m_DescriptionEdit->text()); +} + +void KStreamRipper::urlChanged() +{ + // maybe this should be deleted and the communication would be through a slot + ProcessListViewItem * ProcItem = (ProcessListViewItem*)m_streamsListView->currentItem(); + ProcItem->getProcessController()->setUrl(m_UrlEdit->text()); +} + + +void KStreamRipper::addStreamFinished( AddNewStreamImpl *e ) +{ + ProcessListViewItem * proc = new ProcessListViewItem( m_streamsListView, e->d_nameEdit->text(), "", ""); + proc->getProcessController()->setUrl( e->d_urlEdit->text() ); + proc->getProcessController()->setDescription( e->d_descEdit->text() ); +} + diff --git a/src/kstreamripper.desktop b/src/kstreamripper.desktop new file mode 100644 index 0000000..3810f9f --- /dev/null +++ b/src/kstreamripper.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=KStreamRipper +Name[xx]=xxKStreamRipperxx +Exec=kstreamripper +Icon=kstreamripper +Type=Application +Comment=A simple KDE Application +Comment[da]=Et simpelt KDE program +Comment[es]=Una aplicación de KDE sencilla +Comment[hu]=Egyszerű KDE-alkalmazás +Comment[pt]=Uma aplicação KDE simples +Comment[pt_BR]=Um simples Aplicativo do KDE +Comment[sl]=Preprost program za KDE +Comment[sv]=Ett enkelt KDE-program +Comment[xx]=xxA simple KDE Applicationxx diff --git a/src/kstreamripper.h b/src/kstreamripper.h new file mode 100644 index 0000000..f1a5192 --- /dev/null +++ b/src/kstreamripper.h @@ -0,0 +1,79 @@ +/*************************************************************************** + * Copyright (C) 2003-2005 by Michael Goettsche * + * mail@tuxipuxi.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef KSTREAMRIPPER_H +#define KSTREAMRIPPER_H + +#include +#include "kstreamripperbase.h" +#if KDE_IS_VERSION(3,3,90) +#include +#include +#else +// damned moc will create slots regardless of #if macro +// this is hack to avoid undefined type +namespace DNSSD { namespace RemoteService { typedef int Ptr; } } +#endif + + +class AddNewStreamImpl; +class QString; + +class KStreamRipper : public KStreamRipperBase +{ + Q_OBJECT + +public: + + KStreamRipper( QWidget* parent = 0, const char* name = 0 ); + ~KStreamRipper(); + + virtual void closeEvent( QCloseEvent* ); +#if KDE_IS_VERSION(3,3,90) + DNSSD::ServiceBrowser m_browser; +#endif + +protected slots: + + void addStreamButtonClicked(); + void deleteStreamButtonClicked(); + void tuneInButtonClicked(); + void ripButtonClicked(); + void stopRipButtonClicked(); + void browseButtonClicked(); + void aboutButtonClicked(); + void quitButtonClicked(); + + void selectedNewListItem(); + void descriptionChanged(); + void urlChanged(); + + void addStreamFinished( AddNewStreamImpl* ); +#if KDE_IS_VERSION(3,3,90) + void serviceAdded(DNSSD::RemoteService::Ptr srv); + void serviceRemoved(DNSSD::RemoteService::Ptr srv); +#else + void serviceAdded(DNSSD::RemoteService::Ptr) {}; + void serviceRemoved(DNSSD::RemoteService::Ptr) {}; +#endif +}; + +#endif + diff --git a/src/kstreamripper.lsm b/src/kstreamripper.lsm new file mode 100644 index 0000000..0dbae01 --- /dev/null +++ b/src/kstreamripper.lsm @@ -0,0 +1,16 @@ +Begin3 +Title: KStreamRipper -- Some description +Version: 0.1 +Entered-date: +Description: +Keywords: KDE Qt +Author: Michael Goettsche +Maintained-by: Michael Goettsche +Home-page: +Alternate-site: +Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils + xxxxxx kstreamripper-0.1.tar.gz + xxx kstreamripper-0.1.lsm +Platform: Linux. Needs KDE +Copying-policy: GPL +End diff --git a/src/kstreamripperbase.ui b/src/kstreamripperbase.ui new file mode 100644 index 0000000..fc87901 --- /dev/null +++ b/src/kstreamripperbase.ui @@ -0,0 +1,337 @@ + +KStreamRipperBase + + + KStreamRipperBase + + + + 0 + 0 + 749 + 782 + + + + KStreamRipper V. 0.3.4 + + + + unnamed + + + + spacer1 + + + Horizontal + + + Expanding + + + + 31 + 20 + + + + + + m_favoriteLabel + + + Your Radio Streams: + + + + + layout10 + + + + unnamed + + + + m_aboutButton + + + About + + + + + m_quitButton + + + &Quit + + + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 421 + 21 + + + + + + m_streamsGroup + + + Stream Options + + + + unnamed + + + + m_addStreamButton + + + &Add Stream + + + Alt+A + + + + + m_deleteStreamButton + + + false + + + &Delete Stream + + + Alt+D + + + + + m_stopRipButton + + + false + + + &Stop Rip + + + Alt+S + + + false + + + + + m_tuneInButton + + + false + + + &Tune in + + + Alt+T + + + + + m_ripButton + + + false + + + &Rip Stream + + + Alt+R + + + + + + + m_streamsListView + + + true + + + AllColumns + + + Reject + + + + + m_settingsGroup + + + false + + + Settings + + + + unnamed + + + + m_pathLabel + + + Destination: + + + + + m_timeToRip + + + Time to Rip: + + + + + m_id3Label + + + Add ID3 Tag: + + + + + m_id3Checkbox + + + + + + true + + + + + m_tuneInLabel + + + Tune in Command: + + + + + m_secondsLabel + + + seconds + + + + + m_browseButton + + + .... + + + + + m_tuneInEdit + + + xmms <url> + + + + + m_timeEdit + + + 0 + + + + + m_destEdit + + + Choose a directory + + + + + + + m_Details + + + Details + + + + unnamed + + + + m_StreamDesc + + + Description: + + + + + m_StreamURL + + + URL: + + + + + m_UrlEdit + + + false + + + true + + + + + m_DescriptionEdit + + + false + + + + + + + + diff --git a/src/kstreamripperui.rc b/src/kstreamripperui.rc new file mode 100644 index 0000000..850885b --- /dev/null +++ b/src/kstreamripperui.rc @@ -0,0 +1,8 @@ + + + + C&ustom + + + + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..81d8846 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2003-2005 by Michael Goettsche * + * mail@tuxipuxi.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include + +#include "kstreamripper.h" + + +int main( int argc, char *argv[] ) +{ + KAboutData aboutApp( "KStreamRipper", I18N_NOOP( "KStreamRipper" ), "0.3.4", + "KStreamRipper is a Frontend to Streamripper. Visit Homepage for more Info.", + KAboutData::License_GPL, "(C) 2003-2005 Michael Goettsche", 0, + "http://kstreamripper.tuxipuxi.org", "mail@tuxipuxi.org" ); + + aboutApp.addAuthor( "Michael Goettsche", "Maintainer, Initial version", "mail@tuxipuxi.org" ); + aboutApp.addAuthor( "William Entriken", "Concurrent Ripping, Major UI improvements", "william.entriken@villanova.edu" ); + aboutApp.addCredit( "Kevin Krammer", "Assistance"); + aboutApp.addCredit( "Jakub Stachowski", "bksys migration, crash fix" ); + KCmdLineArgs::init( argc, argv, &aboutApp ); + + KApplication app; + + KStreamRipper *mainWidget = new KStreamRipper(); + + app.setMainWidget( mainWidget ); + mainWidget->show(); + + mainWidget->resize( 700, 600 ); + + return app.exec(); +} + + + + + + + + + + + + + + + diff --git a/src/processcontroller.cpp b/src/processcontroller.cpp new file mode 100644 index 0000000..f0dfb6c --- /dev/null +++ b/src/processcontroller.cpp @@ -0,0 +1,148 @@ +/*************************************************************************** + * Copyright (C) 2005 by Will Entriken * + * william.entriken@villanova.edu * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#include "processcontroller.h" +#include "processlistviewitem.h" + +ProcessController::ProcessController(ProcessListViewItem * parent) + : QObject((QObject *)parent), myParent(parent), myStatus(false), myAutomatic(false), myProcess(new QProcess(this)) +{ + connect (myProcess, SIGNAL( readyReadStdout() ), (ProcessController *) this, SLOT( readStdout()) ); + // connect (myProcess, SIGNAL( destroyed() ), myProcess, SLOT( kill()) ); + // this should work, according to http://doc.trolltech.com/3.2/qobject.html#~QObject but it doesn't +} + +ProcessController::~ProcessController() +{ + myProcess->kill(); +} + +void ProcessController::readStdout() +{ + QString tempOutput = myProcess->readStdout(); + + if( tempOutput.contains( "ripping..." )) + { + QString songname = tempOutput.mid( tempOutput.find( "]" )+1, tempOutput.findRev( "[" ) - tempOutput.find( "]" ) - 1); + myParent->setText( 1, songname.stripWhiteSpace() ); + + QString bytesR = tempOutput.mid( tempOutput.findRev( "[" )+1, tempOutput.findRev( "]" ) - tempOutput.findRev( "[" ) - 1); + myParent->setText( 2, bytesR.stripWhiteSpace() ); + } + + if( tempOutput.contains( "Connecting..." )) + { + myParent->setText( 1, "Connecting..." ); + myParent->setText( 2, "" ); + } + + if( tempOutput.contains( "buffering" )) + { + myParent->setText( 1, "Buffering..." ); + myParent->setText( 2, "" ); + } + + if( tempOutput.contains( "Time to stop is here" )) + { + myParent->setText( 1, "Complete" ); + myParent->setText( 2, "" ); + //QTimer::singleShot( 1500, myParent, SLOT( setEmptyText(3) )); + } +} + + +void ProcessController::startRip(QString destination, QString time) +{ + myStatus = true; + myParent->setText( 1, "Ripping" ); + + myProcess->clearArguments(); + myProcess->addArgument( "streamripper" ); + myProcess->addArgument( myUrl ); + myProcess->addArgument( "-d " ); + myProcess->addArgument( destination ); + if( time.toInt() ) + { + myProcess->addArgument( "-l " ); + myProcess->addArgument( time ); + } + + myProcess->setCommunication( QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr ); + myProcess->start(); +} + + +void ProcessController::stopRip() +{ + myStatus = false; + myParent->setText( 1, "" ); + myParent->setText( 2, "" ); + + myProcess->tryTerminate(); + QTimer::singleShot( 2000, myProcess, SLOT( kill() ) ); +} + + +bool ProcessController::getStatus() +{ + return myStatus; +} + +QString ProcessController::getUrl() +{ + return myUrl; +} + +void ProcessController::setAutomatic(bool a) +{ + myAutomatic = a; +} + +bool ProcessController::getAutomatic() +{ + return myAutomatic; +} +#if KDE_IS_VERSION(3,3,90) +void ProcessController::setService(DNSSD::RemoteService::Ptr service) +{ + myService = service; +} + +DNSSD::RemoteService::Ptr ProcessController::getService() +{ + return myService; +} +#endif + +QString ProcessController::getDescription() +{ + return myDescription; +} + +void ProcessController::setUrl(QString Url) +{ + myUrl = Url; +} + +void ProcessController::setDescription(QString Description) +{ + myDescription = Description; +} diff --git a/src/processcontroller.h b/src/processcontroller.h new file mode 100644 index 0000000..22183df --- /dev/null +++ b/src/processcontroller.h @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (C) 2005 by Will Entriken * + * william.entriken@villanova.edu * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef PROCESSCONTROLLER_H +#define PROCESSCONTROLLER_H + +#include +#include +#include +#include +#include +#if KDE_IS_VERSION(3,3,90) +#include +#endif + +class ProcessListViewItem; + +class ProcessController : public QObject +{ + Q_OBJECT +public: + ProcessController(ProcessListViewItem * parent); + ~ProcessController(); + + bool getStatus(); + bool getAutomatic(); + void setAutomatic(bool a); +#if KDE_IS_VERSION(3,3,90) + DNSSD::RemoteService::Ptr getService(); + void setService(DNSSD::RemoteService::Ptr service); +#endif + void setUrl(QString Url); + void setDescription(QString Description); + QString getUrl(); + QString getDescription(); + void startRip(QString destination, QString time); + void stopRip(); + +protected slots: + void readStdout(); + +private: + ProcessListViewItem * myParent; + bool myStatus; + bool myAutomatic; +#if KDE_IS_VERSION(3,3,90) + DNSSD::RemoteService::Ptr myService; +#endif + QProcess * myProcess; + QString myUrl; + QString myDescription; +}; + +#endif diff --git a/src/processlistviewitem.cpp b/src/processlistviewitem.cpp new file mode 100644 index 0000000..d2c88cc --- /dev/null +++ b/src/processlistviewitem.cpp @@ -0,0 +1,108 @@ +/*************************************************************************** + * Copyright (C) 2005 by Will Entriken * + * william.entriken@villanova.edu * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#include "processlistviewitem.h" + +#include "processlistviewitem.h" +#include "processcontroller.h" + +ProcessListViewItem::ProcessListViewItem( QListView * parent ) + : QListViewItem(parent), myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::ProcessListViewItem( QListViewItem * parent ) + : QListViewItem(parent), myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::ProcessListViewItem( QListView * parent, QListViewItem * after ) + : QListViewItem(parent, after), myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::ProcessListViewItem( QListViewItem * parent, QListViewItem * after ) + : QListViewItem(parent, after), myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::ProcessListViewItem( QListView * parent, + QString label1, + QString label2, + QString label3, + QString label4, + QString label5, + QString label6, + QString label7, + QString label8 ) + : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8), myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::ProcessListViewItem( QListViewItem * parent, + QString label1, + QString label2, + QString label3, + QString label4, + QString label5, + QString label6, + QString label7, + QString label8 ) + : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8), myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::ProcessListViewItem( QListView * parent, QListViewItem * after, + QString label1, + QString label2, + QString label3, + QString label4, + QString label5, + QString label6, + QString label7, + QString label8 ) + : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8), + myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::ProcessListViewItem( QListViewItem * parent, QListViewItem * after, + QString label1, + QString label2, + QString label3, + QString label4, + QString label5, + QString label6, + QString label7, + QString label8 ) + : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8), + myProcessController(new ProcessController(this)) +{ +} + +ProcessListViewItem::~ProcessListViewItem() +{ +} + +ProcessController * ProcessListViewItem::getProcessController() +{ + return myProcessController; +} diff --git a/src/processlistviewitem.h b/src/processlistviewitem.h new file mode 100644 index 0000000..aaa3e74 --- /dev/null +++ b/src/processlistviewitem.h @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (C) 2005 by Will Entriken * + * william.entriken@villanova.edu * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#ifndef PROCESSLISTVIEWITEM_H +#define PROCESSLISTVIEWITEM_H + +#include +#include +#include + +class ProcessController; + +class ProcessListViewItem : public QObject, public QListViewItem +{ + Q_OBJECT +public: + + ProcessListViewItem( QListView * parent ); + ProcessListViewItem( QListViewItem * parent ); + ProcessListViewItem( QListView * parent, QListViewItem * after ); + ProcessListViewItem( QListViewItem * parent, QListViewItem * after ); + + ProcessListViewItem( QListView * parent, + QString, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null ); + ProcessListViewItem( QListViewItem * parent, + QString, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null ); + + ProcessListViewItem( QListView * parent, QListViewItem * after, + QString, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null ); + ProcessListViewItem( QListViewItem * parent, QListViewItem * after, + QString, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null, + QString = QString::null, QString = QString::null ); + + ~ProcessListViewItem(); + + ProcessController * getProcessController(); + +private: + ProcessController * myProcessController; +}; + +#endif diff --git a/src/processlistviewitem_interface.h b/src/processlistviewitem_interface.h new file mode 100644 index 0000000..49385fa --- /dev/null +++ b/src/processlistviewitem_interface.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2005 by Will Entriken * + * william.entriken@villanova.edu * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#ifndef __PROCESSLISTVIEWITEM_INTERFACE_H +#define __PROCESSLISTVIEWITEM_INTERFACE_H + +class ProcessListViewItemInterface +{ +public: + ProcessListViewItemInterface() {} + virtual ~ProcessListViewItemInterface() {} + + +private: + ProcessListViewItemInterface( const ProcessListViewItemInterface& source ); + void operator = ( const ProcessListViewItemInterface& source ); +}; + + +#endif // __PROCESSLISTVIEWITEM_INTERFACE_H -- cgit v1.2.3