200 lines
5.4 KiB
JavaScript
200 lines
5.4 KiB
JavaScript
import LS2Request from "./LS2Request";
|
|
|
|
export const getConnectionStatus = ({ onSuccess, onFailure, onComplete }) => {
|
|
if (process.env.REACT_APP_MODE === "DEBUG") {
|
|
console.log("LUNA SEND getConnectionStatus");
|
|
return "Some Hard Coded Mock Data";
|
|
} else {
|
|
return new LS2Request().send({
|
|
service: "luna://com.webos.service.connectionmanager",
|
|
method: "getStatus",
|
|
subscribe: true,
|
|
parameters: {},
|
|
onSuccess,
|
|
onFailure,
|
|
onComplete,
|
|
});
|
|
}
|
|
};
|
|
|
|
export const createToast = (message) => {
|
|
if (typeof window === "object" && !window.PalmSystem) {
|
|
console.log("LUNA SEND createToast message", message);
|
|
return;
|
|
}
|
|
return new LS2Request().send({
|
|
service: "luna://com.webos.notification",
|
|
method: "createToast",
|
|
parameters: {
|
|
message: message,
|
|
iconUrl: "",
|
|
noaction: true,
|
|
},
|
|
onSuccess: (res) => {
|
|
console.log("LUNA SEND createToast success", message);
|
|
},
|
|
onFailure: (err) => {
|
|
console.log("LUNA SEND createToast failed", err);
|
|
},
|
|
});
|
|
};
|
|
|
|
let httpHeaderHandler = null;
|
|
export const getHttpHeaderForServiceRequest = ({
|
|
onSuccess,
|
|
onFailure,
|
|
onComplete,
|
|
}) => {
|
|
if (
|
|
typeof window === "object" &&
|
|
window.PalmSystem &&
|
|
process.env.REACT_APP_MODE !== "DEBUG"
|
|
) {
|
|
if (httpHeaderHandler) {
|
|
httpHeaderHandler.cancel();
|
|
}
|
|
httpHeaderHandler = new LS2Request().send({
|
|
service: "luna://com.webos.service.sdx",
|
|
method: "getHttpHeaderForServiceRequest",
|
|
subscribe: true,
|
|
parameters: {},
|
|
onSuccess,
|
|
onFailure,
|
|
onComplete,
|
|
});
|
|
return httpHeaderHandler;
|
|
} else {
|
|
onSuccess({
|
|
HOST: "US.nextlgsdp.com",
|
|
"X-User-Number": "US2210240095608",
|
|
Authorization:
|
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZXh0bGdzZHAuY29tIiwiYXVkIjoibmV4dGxnc2RwLmNvbSIsImlhdCI6MTcwNzc4NTUyNSwiZXhwIjoxNzA3NzkyNzI1LCJtYWNBZGRyZXNzIjoiZWVkMDQ2NjdiNjUzOWU3YmQxMDA1OTljYjBkYTI5ZjRjZTgyZGZlOGZkNzIzMDAxZGVmMjg4NWRkNWZiODRmNWNiMzZlM2QwNzYzNWZjZGJjYWNjNGVjMzI5NWIwNjZjOTMwNmNmNDI1ZGQzMmQ2MDMxMjc1NWNkOTIyNjEwMzcifQ.vqPdYGnN46diesDBLzA4UhACCJVdIycLs7wZu9M55Hc",
|
|
"X-Authentication": "MkOLvUocrJ69RH/iV1ZABJhjR2g=",
|
|
"X-Device-ID":
|
|
"OemUY5qbPITZv96QKlxrtcqT6ypeX6us2qANLng3/0QCUhv2mecK1UDTMYb/hjpjey9dC/kFycc/5R8u+oK56JIWyYC4V278z64YDPKbDXIsd+eECvyf+Rdm8BneIUPM",
|
|
"X-Device-Product": "webOSTV 5.0",
|
|
"X-Device-Platform": "W20P",
|
|
"X-Device-Model": "HE_DTV_W20P_AFADATAA",
|
|
"X-Device-Eco-Info": "1",
|
|
"X-Device-Country": "US",
|
|
"X-Device-Language": "en-US",
|
|
"X-Device-Netcast-Platform-Version": "6.0.0",
|
|
"X-Device-Publish-Flag": "N",
|
|
"X-Device-Fck": "253",
|
|
"X-Device-Eula":
|
|
"additionalDataAllowed,takeOnAllowed,networkAllowed,generalTermsAllowed,chpAllowed,customAdAllowed,acrOnAllowed,voice2Allowed,voiceAllowed,acrAdAllowed",
|
|
});
|
|
}
|
|
};
|
|
|
|
export const getSystemSettings = (
|
|
parameters,
|
|
{ onSuccess, onFailure, onComplete }
|
|
) => {
|
|
if (
|
|
typeof window === "object" &&
|
|
window.PalmSystem &&
|
|
process.env.REACT_APP_MODE !== "DEBUG"
|
|
) {
|
|
return new LS2Request().send({
|
|
service: "luna://com.webos.settingsservice",
|
|
method: "getSystemSettings",
|
|
subscribe: true,
|
|
parameters: parameters,
|
|
onSuccess,
|
|
onFailure,
|
|
onComplete,
|
|
});
|
|
} else if (typeof window === "object") {
|
|
const language =
|
|
typeof window.navigator === "object"
|
|
? window.navigator.language || window.navigator.userLanguage
|
|
: "en-US";
|
|
const res = {
|
|
settings: {
|
|
smartServiceCountryCode2: language.split("-")[1],
|
|
captionEnable: true,
|
|
},
|
|
returnValue: true,
|
|
};
|
|
onSuccess(res);
|
|
onComplete(res);
|
|
}
|
|
};
|
|
|
|
export function checkValidCountry(ricCode, country) {
|
|
if (ricCode === "aic") {
|
|
if (country === "US") return true;
|
|
else return false;
|
|
} else if (ricCode === "eic") {
|
|
if (country === "GB" || country === "DE") return true;
|
|
else return false;
|
|
} else if (ricCode === "ruc") {
|
|
if (country === "RU") return true;
|
|
else return false;
|
|
} else {
|
|
if (country === "US") {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 3.0 ~ 4.5
|
|
export const setSubtitleEnable = (
|
|
showId,
|
|
captionEnable,
|
|
{ onSuccess, onFailure, onComplete }
|
|
) => {
|
|
if (
|
|
typeof window === "object" &&
|
|
window.PalmSystem &&
|
|
process.env.REACT_APP_MODE !== "DEBUG"
|
|
) {
|
|
if (captionEnable) {
|
|
return new LS2Request().send({
|
|
service: "luna://com.webos.service.tv.subtitle",
|
|
method: "enableSubtitle",
|
|
parameters: { pipelineId: showId },
|
|
onSuccess,
|
|
onFailure,
|
|
onComplete,
|
|
});
|
|
} else {
|
|
return new LS2Request().send({
|
|
service: "luna://com.webos.service.tv.subtitle",
|
|
method: "disableSubtitle",
|
|
parameters: { pipelineId: showId },
|
|
onSuccess,
|
|
onFailure,
|
|
onComplete,
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
// 5.0
|
|
export const setSubtitleEnableOver5 = (
|
|
showId,
|
|
{ onSuccess, onFailure, onComplete }
|
|
) => {
|
|
console.log("#sutitle action");
|
|
if (
|
|
typeof window === "object" &&
|
|
window.PalmSystem &&
|
|
process.env.REACT_APP_MODE !== "DEBUG"
|
|
) {
|
|
console.log("###showId", showId);
|
|
console.log("#onSuccess", onSuccess);
|
|
return new LS2Request().send({
|
|
service: "luna://com.webos.media",
|
|
method: "setSubtitleEnable",
|
|
parameters: { pipelineId: showId },
|
|
onSuccess,
|
|
onFailure,
|
|
onComplete,
|
|
});
|
|
}
|
|
};
|