Initial commit
This commit is contained in:
commit
45115830c0
30 changed files with 2923 additions and 0 deletions
122
src/main.cpp
Executable file
122
src/main.cpp
Executable file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
Libre Media Server - A media server for audio playback in stage arts
|
||||
controlled by lingting protocols (DMX, ArtNet, ACN,...)
|
||||
|
||||
Copyright (C) 2015 Santiago Noreña libremediaserver@gmail.com
|
||||
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include "libremediaserver-audio.h"
|
||||
|
||||
// Handler for pipe the stderr to a log file
|
||||
|
||||
bool initMessageHandler = false;
|
||||
QFile outFile;
|
||||
|
||||
void MessageHandler(QtMsgType type, const char *msg)
|
||||
{
|
||||
QString txt;
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
txt = QString("Debug: %1").arg(msg);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
txt = QString("Warning: %1").arg(msg);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
txt = QString("Critical: %1").arg(msg);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
txt = QString("Fatal: %1").arg(msg);
|
||||
abort();
|
||||
}
|
||||
// Create the log dir and log file
|
||||
if (!initMessageHandler)
|
||||
{
|
||||
QDir dir;
|
||||
if (!dir.exists("log"))
|
||||
{
|
||||
if (!dir.mkdir("log"))
|
||||
{
|
||||
qDebug()<<"MessageHandler: Can not create log folder";
|
||||
return;
|
||||
}
|
||||
}
|
||||
QString filename;
|
||||
QDate date = QDate::currentDate();
|
||||
QTime time = QTime::currentTime();
|
||||
filename.append("./log/log_");
|
||||
filename.append(date.toString("ddMMyy-"));
|
||||
filename.append(time.toString("hhmmss.txt"));
|
||||
outFile.setFileName(filename);
|
||||
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Append))
|
||||
{
|
||||
qDebug()<<"main/MessageHandler/Qfile::open: can not open log file";
|
||||
return;
|
||||
}
|
||||
initMessageHandler = true;
|
||||
}
|
||||
QTextStream ts(&outFile);
|
||||
ts << txt << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QStringList args = app.arguments();
|
||||
// parse the command line
|
||||
if (args.size() > 1)
|
||||
{
|
||||
if (args.contains("-v") > 0)
|
||||
{
|
||||
qDebug() << VERSION;
|
||||
qDebug() << COPYRIGHT;
|
||||
qDebug() << LICENSE;
|
||||
return 0;
|
||||
}
|
||||
if (args.contains("-h") > 0)
|
||||
{
|
||||
qDebug() << VERSION;
|
||||
qDebug() << COPYRIGHT;
|
||||
qDebug() << LICENSE;
|
||||
qDebug() << "Help for command line options:";
|
||||
qDebug() << "-v show the version and exits";
|
||||
qDebug() << "-gui show the Pure Data GUI's";
|
||||
qDebug() << "-log write the debug information to a log file instead stderr";
|
||||
qDebug() << "-h this help";
|
||||
return 0;
|
||||
}
|
||||
if (args.contains("-log"))
|
||||
{
|
||||
qInstallMsgHandler(MessageHandler);
|
||||
}
|
||||
if (!args.contains("-gui"))
|
||||
{
|
||||
for (int i=1; i<args.size();i++)
|
||||
{
|
||||
qDebug() << "Option not known: " << args.at(i);
|
||||
}
|
||||
qDebug() <<"Write ./libremediaserver-audio -h for help in command line arguments";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
libreMediaServerAudio libreMediaServerAudio(args);
|
||||
libreMediaServerAudio.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue