| 1050 | } |
| 1051 | |
| 1052 | void Application::messageReceived(const QByteArray& message) |
| 1053 | { |
| 1054 | if(status() != Initialized) |
| 1055 | { |
| 1056 | qDebug() << "Received message" << message << "while still initializing. It will be ignored."; |
| 1057 | return; |
| 1058 | } |
| 1059 | |
| 1060 | ApplicationMessage received; |
| 1061 | received.parse(message); |
| 1062 | |
| 1063 | auto & command = received.command; |
| 1064 | |
| 1065 | if(command == "activate") |
| 1066 | { |
| 1067 | showMainWindow(); |
| 1068 | } |
| 1069 | else if(command == "import") |
| 1070 | { |
| 1071 | QString path = received.args["path"]; |
| 1072 | if(path.isEmpty()) |
| 1073 | { |
| 1074 | qWarning() << "Received" << command << "message without a zip path/URL."; |
| 1075 | return; |
| 1076 | } |
| 1077 | m_mainWindow->droppedURLs({ QUrl(path) }); |
| 1078 | } |
| 1079 | else if(command == "launch") |
| 1080 | { |
| 1081 | QString id = received.args["id"]; |
| 1082 | QString server = received.args["server"]; |
| 1083 | QString profile = received.args["profile"]; |
| 1084 | |
| 1085 | InstancePtr instance; |
| 1086 | if(!id.isEmpty()) { |
| 1087 | instance = instances()->getInstanceById(id); |
| 1088 | if(!instance) { |
| 1089 | qWarning() << "Launch command requires an valid instance ID. " << id << "resolves to nothing."; |
| 1090 | return; |
| 1091 | } |
| 1092 | } |
| 1093 | else { |
| 1094 | qWarning() << "Launch command called without an instance ID..."; |
| 1095 | return; |
| 1096 | } |
| 1097 | |
| 1098 | MinecraftServerTargetPtr serverObject = nullptr; |
| 1099 | if(!server.isEmpty()) { |
| 1100 | serverObject = std::make_shared<MinecraftServerTarget>(MinecraftServerTarget::parse(server)); |
| 1101 | } |
| 1102 | |
| 1103 | MinecraftAccountPtr accountObject; |
| 1104 | if(!profile.isEmpty()) { |
| 1105 | accountObject = accounts()->getAccountByProfileName(profile); |
| 1106 | if(!accountObject) { |
| 1107 | qWarning() << "Launch command requires the specified profile to be valid. " << profile << "does not resolve to any account."; |
| 1108 | return; |
| 1109 | } |
nothing calls this directly
no test coverage detected