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_MessageHandler.h"
29 #include <MUtils/IPCChannel.h>
32 #include <QSharedMemory>
33 #include <QSystemSemaphore>
34 #include <QMessageBox>
39 ////////////////////////////////////////////////////////////
41 ////////////////////////////////////////////////////////////
43 MessageHandlerThread::MessageHandlerThread(MUtils::IPCChannel *const ipcChannel)
45 m_ipcChannel(ipcChannel)
48 m_parameter = new char[4096];
51 MessageHandlerThread::~MessageHandlerThread(void)
53 delete [] m_parameter;
56 void MessageHandlerThread::run()
59 setTerminationEnabled(true);
63 unsigned int command = 0;
64 m_ipcChannel->read(command, m_parameter, 4096);
65 if(!command) continue;
70 emit fileReceived(QString::fromUtf8(m_parameter));
73 emit folderReceived(QString::fromUtf8(m_parameter), false);
76 emit folderReceived(QString::fromUtf8(m_parameter), true);
79 if(!_stricmp(m_parameter, "Force!"))
85 emit killSignalReceived();
89 emit otherInstanceDetected();
92 qWarning("Received an unknown IPC message! (command=%u)", command);
98 void MessageHandlerThread::stop(void)
103 m_ipcChannel->send(0, NULL);
107 ////////////////////////////////////////////////////////////
109 ////////////////////////////////////////////////////////////