| 1 | /* |
| 2 | * midisnoop - MIDI monitor and prober |
| 3 | * Copyright (C) 2012 Devin Anderson |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License as published by the Free |
| 7 | * Software Foundation; either version 2 of the License, or (at your option) |
| 8 | * any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program; if not, write to the Free Software Foundation, Inc., 675 Mass |
| 17 | * Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | #include <cstdio> |
| 21 | #include <cstdlib> |
| 22 | #include <exception> |
| 23 | |
| 24 | #include <QtCore/QDebug> |
| 25 | #include <QtCore/QLibraryInfo> |
| 26 | #include <QtCore/QLocale> |
| 27 | #include <QtCore/QTranslator> |
| 28 | #include <QtCore/QTextStream> |
| 29 | |
| 30 | #include "controller.h"cxx . . $ `<file>/src/controller.h`/ |
| 31 | #include "error.h"cxx . . $ `<file>/src/error.h`/ |
| 32 | |
| 33 | int |
| 34 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 35 | { |
| 36 | Applicationcxx . . $ Application# applicationcxx . . $ Application#Application(90b35a5c77e1789d).(argc, argv); |
| 37 | QStringcxx . . $ QString# errorMessagecxx . . $ QString#QString(ced63f7c635d850d).; |
| 38 | |
| 39 | application.setApplicationNamecxx . . $ QCoreApplication#setApplicationName(3520e46b33348bf6).("midisnoop"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 40 | application.setOrganizationDomaincxx . . $ QCoreApplication#setOrganizationDomain(3520e46b33348bf6).("midisnoop.googlecode.com"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 41 | application.setOrganizationNamecxx . . $ QCoreApplication#setOrganizationName(3520e46b33348bf6).("midisnoop.googlecode.com"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 42 | |
| 43 | // Translations |
| 44 | QStringcxx . . $ QString# directory = QLibraryInfocxx . . $ QLibraryInfo#::locationcxx . . $ QLibraryInfo#location(dd7ac78f10b8a525).(QLibraryInfocxx . . $ QLibraryInfo#::TranslationsPathcxx . . $ QLibraryInfo#TranslationsPath.); |
| 45 | QStringcxx . . $ QString# language = QLocalecxx . . $ QLocale#::systemcxx . . $ QLocale#system(7171962d3a2fd395).().namecxx . . $ QLocale#name(6ef7b6c27b00b43d).(); |
| 46 | QTranslatorcxx . . $ QTranslator# qtTranslatorcxx . . $ QTranslator#QTranslator(749de1b6ae65bddd).; |
| 47 | qtTranslator.loadcxx . . $ QTranslator#load(142924642d8b819d).("qt_" +cxx . . $ operator+(c75c3ae4eb9af1a8). language, directory); |
| 48 | application.installTranslatorcxx . . $ QCoreApplication#installTranslator(d376406de50edad7).(&qtTranslator); |
| 49 | QTranslatorcxx . . $ QTranslator# translatorcxx . . $ QTranslator#QTranslator(749de1b6ae65bddd).; |
| 50 | translator.loadcxx . . $ QTranslator#load(142924642d8b819d).("midisnoop_" +cxx . . $ operator+(c75c3ae4eb9af1a8). language); |
| 51 | application.installTranslatorcxx . . $ QCoreApplication#installTranslator(d376406de50edad7).(&translator); |
| 52 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). application.trcxx . . $ Application#tr(75d9f1c324b4579d).("Translations loaded."); |
| 53 | |
| 54 | try { |
| 55 | |
| 56 | // Controller |
| 57 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). application.trcxx . . $ Application#tr(75d9f1c324b4579d).("Creating core application objects ..."); |
| 58 | Controllercxx . . $ Controller# controllercxx . . $ Controller#Controller(35d70d227b7d2743).(application); |
| 59 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). application.trcxx . . $ Application#tr(75d9f1c324b4579d).("Core application objects created."); |
| 60 | |
| 61 | // Run the program |
| 62 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). application.trcxx . . $ Application#tr(75d9f1c324b4579d).("Running ..."); |
| 63 | controller.runcxx . . $ Controller#run(49f6e7a06ebc5aa8).(); |
| 64 | |
| 65 | } catch (Errorcxx . . $ Error# &e) { |
| 66 | errorMessage =cxx . . $ QString#`operator=`(4f35bf974e7f8568). e.getMessagecxx . . $ Error#getMessage(4365c3963150523e).(); |
| 67 | } catch (stdcxx . . $ std/::exception &e) { |
| 68 | errorMessage =cxx . . $ QString#`operator=`(d02845eef0c33901). e.what(); |
| 69 | } |
| 70 | |
| 71 | // Deal with errors. |
| 72 | int result; |
| 73 | if (errorMessage.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 74 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). application.trcxx . . $ Application#tr(75d9f1c324b4579d).("Exiting without errors ..."); |
| 75 | result = EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!; |
| 76 | } else { |
| 77 | QTextStreamcxx . . $ QTextStream#QTextStream(65339a794c789c54).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!) <<cxx . . $ QTextStream#`operator<<`(f61e69e0d177108f). application.trcxx . . $ Application#tr(75d9f1c324b4579d).("Error: %1\n").argcxx . . $ QString#arg(bc823072288cbbb5).(errorMessage); |
| 78 | result = EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!; |
| 79 | } |
| 80 | |
| 81 | // Cleanup |
| 82 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). application.trcxx . . $ Application#tr(75d9f1c324b4579d).("Unloading translations ..."); |
| 83 | application.removeTranslatorcxx . . $ QCoreApplication#removeTranslator(d376406de50edad7).(&translator); |
| 84 | application.removeTranslatorcxx . . $ QCoreApplication#removeTranslator(d376406de50edad7).(&qtTranslator); |
| 85 | |
| 86 | return result; |
| 87 | } |