00001 /* 00002 Copyright (C) 2008-2010 Lukas Sommer < SommerLuk at gmail dot com > 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License as 00006 published by the Free Software Foundation; either version 2 of 00007 the License or (at your option) version 3 or any later version 00008 accepted by the membership of KDE e.V. (or its successor approved 00009 by the membership of KDE e.V.), which shall act as a proxy 00010 defined in Section 14 of version 3 of the license. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #include "streamripper_base.h" 00022 #include "settings_general.h" 00023 00024 streamripper_base::streamripper_base(QObject *parent) : console_reader(parent) 00025 { 00026 internal_index = 0; 00027 } 00028 00029 streamripper_base::streamripper_base(QObject *parent, void *index) 00030 : console_reader(parent) 00031 { 00032 setIndex(index); // better than setting internal_index directly. 00033 // And we don't have to worry about signals 00034 // that are emitted because this is the constructur - so there 00035 // won't be any slot connected 00036 // to them. 00037 } 00038 00039 streamripper_base::~streamripper_base() 00040 { 00041 } 00042 00043 void *streamripper_base::index() const 00044 { 00045 return internal_index; 00046 } 00047 00048 void streamripper_base::setIndex(void *index) 00049 { 00050 if (internal_index != index) { 00051 internal_index=index; 00052 emit indexChanged(index); 00053 }; 00054 } 00055 00056 void streamripper_base::startStreamripper() 00057 { 00058 QStringList command_line; 00059 command_line.append(streamripperCommand()); 00060 command_line += parameterList(); 00061 m_process.setProgram(command_line); //prepare KProcess 00062 m_process.clearEnvironment(); // (almost) all environment variables are cleard. We 00063 // don't want that strange, undefined things will happen with streamripper... 00064 m_process.start(); //call streamripper 00065 } 00066 00067 void streamripper_base::abortStreamripper() 00068 { 00069 m_process.kill(); // sends the SIGKILL signal 00070 m_process.waitForFinished(-1); // we have to wait until the process really is finished 00071 }