void __cdecl wmain(int argc, WCHAR* argv[]) { if (argc>=2 && _wcsnicmp(argv[1], L"SERVER:", wcslen(L"SERVER:"))==0) { targetHost = argv[1]+wcslen(L"SERVER:"); } if (targetHost) { wprintf(L"\nCurrently connected to : %s\n",targetHost); }else { wprintf(L"Currently connected to <local host>\nUse 08cli.exe server:<server address> \nto connect to an alternate server\n\n"); } OPTIONS options[]={ {L'0',L"To connect to a COM server from a MTA apartment",MTAClientCall}, {L'1',L"To connect to a COM server from a STA apartment",STAClientCall}, {L'x',L"To exit",NULL}, }; AppInfo appInfo=AppInfo(options); appInfo.Loop(); }
AppInfo AppInfo::fromPath(const QString &path) { AppInfo info(Bundle::fromPath(path)); if (!static_cast<Bundle>(info).isValid()) { qCWarning(l) << "bundle" << path << "is not valid"; return AppInfo(); } QScopedPointer<QIODevice> appInfoJSON(info.openFile(AppInfo::INFO, QIODevice::Text)); if (!appInfoJSON) { qCWarning(l) << "cannot find app" << path << "info json"; return AppInfo(); } QJsonParseError parseError; QJsonDocument doc = QJsonDocument::fromJson(appInfoJSON->readAll(), &parseError); if (parseError.error != QJsonParseError::NoError) { qCWarning(l) << "cannot parse app" << path << "info json" << parseError.errorString(); return AppInfo(); } appInfoJSON->close(); const QJsonObject root = doc.object(); info.d->uuid = QUuid(root["uuid"].toString()); info.d->shortName = root["shortName"].toString(); info.d->longName = root["longName"].toString(); info.d->companyName = root["companyName"].toString(); info.d->versionCode = root["versionCode"].toInt(); info.d->versionLabel = root["versionLabel"].toString(); const QJsonObject watchapp = root["watchapp"].toObject(); info.d->watchface = watchapp["watchface"].toBool(); info.d->jskit = info.fileExists(AppInfo::APPJS); if (root.contains("capabilities")) { const QJsonArray capabilities = root["capabilities"].toArray(); AppInfo::Capabilities caps = 0; for (auto it = capabilities.constBegin(); it != capabilities.constEnd(); ++it) { QString cap = (*it).toString(); if (cap == "location") caps |= AppInfo::Location; if (cap == "configurable") caps |= AppInfo::Configurable; } info.d->capabilities = caps; } if (root.contains("appKeys")) { const QJsonObject appkeys = root["appKeys"].toObject(); for (auto it = appkeys.constBegin(); it != appkeys.constEnd(); ++it) { info.addAppKey(it.key(), it.value().toInt()); } } if (root.contains("resources")) { const QJsonObject resources = root["resources"].toObject(); const QJsonArray media = resources["media"].toArray(); int index = 0; for (auto it = media.constBegin(); it != media.constEnd(); ++it) { const QJsonObject res = (*it).toObject(); const QJsonValue menuIcon = res["menuIcon"]; switch (menuIcon.type()) { case QJsonValue::Bool: info.d->menuIcon = menuIcon.toBool(); info.d->menuIconResource = index; break; case QJsonValue::String: info.d->menuIcon = !menuIcon.toString().isEmpty(); info.d->menuIconResource = index; break; default: break; } index++; } } if (info.uuid().isNull() || info.shortName().isEmpty()) { qCWarning(l) << "invalid or empty uuid/name in json of" << path; return AppInfo(); } return info; }