| 92 | } |
| 93 | |
| 94 | int main(int argc, char *argv[]) |
| 95 | { |
| 96 | Q_INIT_RESOURCE(commonrc); |
| 97 | Q_INIT_RESOURCE(translations); |
| 98 | |
| 99 | if(SingleCoreApplication::sendMessage("Another instance of Qcma tried to start")) { |
| 100 | QTextStream(stdout) << "An instance of Qcma is already running" << Qt::endl; |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | SingleCoreApplication app(argc, argv); |
| 105 | |
| 106 | // FIXME: libmtp sends SIGPIPE if a socket write fails crashing the whole app |
| 107 | // the proper fix is to libmtp to handle the cancel properly or ignoring |
| 108 | // SIGPIPE on the socket |
| 109 | signal(SIGPIPE, SIG_IGN); |
| 110 | |
| 111 | if(!setup_handlers()) |
| 112 | return 1; |
| 113 | |
| 114 | if(app.arguments().contains("--with-debug")) { |
| 115 | VitaMTP_Set_Logging(VitaMTP_DEBUG); |
| 116 | } else if(app.arguments().contains("--verbose")) { |
| 117 | VitaMTP_Set_Logging(VitaMTP_VERBOSE); |
| 118 | } else { |
| 119 | VitaMTP_Set_Logging(VitaMTP_NONE); |
| 120 | qInstallMessageHandler(noDebugOutput); |
| 121 | } |
| 122 | |
| 123 | QTextStream(stdout) << "Starting Qcma " << QCMA_VER << Qt::endl; |
| 124 | |
| 125 | QTranslator translator; |
| 126 | QString locale = QLocale().system().name(); |
| 127 | qDebug() << "Current locale:" << locale; |
| 128 | |
| 129 | if(app.arguments().contains("--set-locale")) { |
| 130 | int index = app.arguments().indexOf("--set-locale"); |
| 131 | if(index + 1 < app.arguments().length()) { |
| 132 | qDebug("Enforcing locale: %s", app.arguments().at(index + 1).toUtf8().data()); |
| 133 | locale = app.arguments().at(index + 1); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | if(translator.load("qcma_" + locale, ":/resources/translations")) { |
| 138 | app.installTranslator(&translator); |
| 139 | } else { |
| 140 | qWarning() << "Cannot load translation for locale:" << locale; |
| 141 | } |
| 142 | |
| 143 | QTranslator system_translator; |
| 144 | if(!system_translator.load("qt_" + locale, QLibraryInfo::path(QLibraryInfo::TranslationsPath))) { |
| 145 | qWarning() << "Cannot load system translation for locale:" << locale; |
| 146 | } else { |
| 147 | app.installTranslator(&system_translator); |
| 148 | } |
| 149 | |
| 150 | qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId()); |
| 151 |
nothing calls this directly
no test coverage detected