MCPcopy Create free account
hub / github.com/MultiMC/Launcher / messageReceived

Method messageReceived

launcher/Application.cpp:1135–1210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1133}
1134
1135void Application::messageReceived(const QByteArray& message)
1136{
1137 if(status() != Initialized)
1138 {
1139 qDebug() << "Received message" << message << "while still initializing. It will be ignored.";
1140 return;
1141 }
1142
1143 ApplicationMessage received;
1144 received.parse(message);
1145
1146 auto & command = received.command;
1147
1148 if(command == "activate")
1149 {
1150 showMainWindow();
1151 }
1152 else if(command == "import")
1153 {
1154 QString path = received.args["path"];
1155 if(path.isEmpty())
1156 {
1157 qWarning() << "Received" << command << "message without a zip path/URL.";
1158 return;
1159 }
1160 m_mainWindow->droppedURLs({ QUrl(path) });
1161 }
1162 else if(command == "launch")
1163 {
1164 QString id = received.args["id"];
1165 QString server = received.args["server"];
1166 QString profile = received.args["profile"];
1167 bool offline = received.args["offline_enabled"] == "true";
1168 QString offlineName = received.args["offline_name"];
1169
1170 InstancePtr instance;
1171 if(!id.isEmpty()) {
1172 instance = instances()->getInstanceById(id);
1173 if(!instance) {
1174 qWarning() << "Launch command requires an valid instance ID. " << id << "resolves to nothing.";
1175 return;
1176 }
1177 }
1178 else {
1179 qWarning() << "Launch command called without an instance ID...";
1180 return;
1181 }
1182
1183 MinecraftServerTargetPtr serverObject = nullptr;
1184 if(!server.isEmpty()) {
1185 serverObject = std::make_shared<MinecraftServerTarget>(MinecraftServerTarget::parse(server));
1186 }
1187
1188 MinecraftAccountPtr accountObject;
1189 if(!profile.isEmpty()) {
1190 accountObject = accounts()->getAccountByProfileName(profile);
1191 if(!accountObject) {
1192 qWarning() << "Launch command requires the specified profile to be valid. " << profile << "does not resolve to any account.";

Callers

nothing calls this directly

Calls 6

QUrlClass · 0.85
isEmptyMethod · 0.80
droppedURLsMethod · 0.80
getInstanceByIdMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected