1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "Thread_MessageProducer.h"
29 #include <MUtils/Global.h>
30 #include <MUtils/IPCChannel.h>
31 #include <MUtils/OSSupport.h>
34 #include <QStringList>
35 #include <QApplication>
42 ////////////////////////////////////////////////////////////
44 ////////////////////////////////////////////////////////////
46 MessageProducerThread::MessageProducerThread(MUtils::IPCChannel *const ipcChannel)
48 m_ipcChannel(ipcChannel)
52 MessageProducerThread::~MessageProducerThread(void)
56 void MessageProducerThread::run()
58 setTerminationEnabled(true);
59 bool bSentFiles = false;
60 const QStringList &arguments = MUtils::OS::arguments();
62 for(int i = 0; i < arguments.count(); i++)
64 if(!arguments[i].compare("--kill", Qt::CaseInsensitive))
66 m_ipcChannel->send(666, NULL);
69 if(!arguments[i].compare("--force-kill", Qt::CaseInsensitive))
71 m_ipcChannel->send(666, "Force!");
76 for(int i = 0; i < arguments.count() - 1; i++)
78 if(!arguments[i].compare("--add", Qt::CaseInsensitive))
80 QFileInfo file = QFileInfo(arguments[++i]);
81 if(file.exists() && file.isFile())
83 m_ipcChannel->send(1, MUTILS_UTF8(file.canonicalFilePath()));
87 if(!arguments[i].compare("--add-folder", Qt::CaseInsensitive))
89 QDir dir = QDir(arguments[++i]);
92 m_ipcChannel->send(2, MUTILS_UTF8(dir.canonicalPath()));
96 if(!arguments[i].compare("--add-recursive", Qt::CaseInsensitive))
98 QDir dir = QDir(arguments[++i]);
101 m_ipcChannel->send(3, MUTILS_UTF8(dir.canonicalPath()));
109 m_ipcChannel->send(UINT_MAX, "Use running instance!");
113 ////////////////////////////////////////////////////////////
115 ////////////////////////////////////////////////////////////