OSDN Git Service

More detailed error output when process failed to create + use UUID's to index jobs.
[lamexp/LameXP.git] / src / Thread_Process.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
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.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "Thread_Process.h"
23
24 #include "Global.h"
25 #include "Model_Progress.h"
26
27 #include <QUuid.h>
28 #include <limits.h>
29 #include <time.h>
30
31 ////////////////////////////////////////////////////////////
32 // Constructor
33 ////////////////////////////////////////////////////////////
34
35 ProcessThread::ProcessThread(void)
36         : m_jobId(QUuid::createUuid()), m_aborted(false)
37 {
38 }
39
40 ProcessThread::~ProcessThread(void)
41 {
42 }
43
44 void ProcessThread::run()
45 {
46         m_aborted = false;
47
48         qDebug("Process thread %s has started.", m_jobId.toString().toLatin1().constData());
49         emit processStateInitialized(m_jobId, "Slime - Der Tod Ist Ein Meister Aus Deutschland.mp3", "Starting...", ProgressModel::JobRunning);
50         
51         QUuid uuid = QUuid::createUuid();
52         qsrand(uuid.data1 * uuid.data2 * uuid.data3 * uuid.data4[0] * uuid.data4[1] * uuid.data4[2] * uuid.data4[3] * uuid.data4[4] * uuid.data4[5] * uuid.data4[6] * uuid.data4[7]);
53         unsigned long delay = 250 + (qrand() % 500);
54
55
56         for(int i = 1; i <= 100; i++)
57         {
58                 if(m_aborted)
59                 {
60                         emit processStateChanged(m_jobId, "Aborted.", ProgressModel::JobFailed);
61                         return;
62                 }
63
64                 QThread::msleep(delay);
65                 emit processStateChanged(m_jobId, QString("Encoding (%1%)").arg(i), ProgressModel::JobRunning);
66         }
67
68         emit processStateChanged(m_jobId, "Done (100%)", ProgressModel::JobComplete);
69         qDebug("Process thread is done.");
70 }
71
72 ////////////////////////////////////////////////////////////
73 // EVENTS
74 ////////////////////////////////////////////////////////////
75
76 /*NONE*/