23#include <QRegularExpression>
54 pEntry->m_Data.Append(
new MHUnion(
true));
56 pEntry->m_Data.Append(
new MHUnion(
true));
129 std::chrono::milliseconds nNextTime = 0ms;
131 bool at_least_once {
true} ;
134 at_least_once =
false;
159 if (nAppTime != 0ms && (nNextTime == 0ms || nAppTime < nNextTime))
161 nNextTime = nAppTime;
200 if (text.size() == 0)
209 unsigned char ch = text[0];
210 std::unique_ptr<MHParseBase>
parser;
211 std::unique_ptr<MHGroup> pRes;
215 parser = std::make_unique<MHParseBinary>(text);
219 parser = std::make_unique<MHParseText>(text);
223 std::unique_ptr<MHParseNode> pTree (
parser->Parse() );
225 switch (pTree->GetTagNo())
228 pRes = std::make_unique<MHApplication>();
231 pRes = std::make_unique<MHScene>();
237 pRes->Initialise(pTree.get(),
this);
238 return pRes.release();
245 if (csPath.isEmpty() || csPath.startsWith(
"DSM:") || csPath.startsWith(
"~"))
247 if (csPath.startsWith(
"hybrid:"))
249 if (csPath.startsWith(
"http:") || csPath.startsWith(
"https:"))
251 if (csPath.startsWith(
"CI:"))
254 int firstColon = csPath.indexOf(
':');
255 int firstSlash = csPath.indexOf(
'/');
256 if (firstColon > 0 && firstSlash > 0 && firstColon < firstSlash)
292 if (! pProgram->m_fIsApp)
332 pProgram->m_path = csPath;
333 int nPos = pProgram->m_path.lastIndexOf(
'/');
337 pProgram->m_path =
"";
341 pProgram->m_path = pProgram->m_path.left(nPos);
399 else if (
nullptr != pApp)
454 MHERROR(
"Application disappeared");
501 if (
nullptr != pScene)
528 QString csPath = QString::fromUtf8((
const char *)str.
Bytes(), str.
Size());
541 if (csPath.startsWith(
"DSM:"))
542 csPath = csPath.mid(4);
543 else if (csPath.startsWith(
"~"))
544 csPath = csPath.mid(1);
545 if (!csPath.startsWith(
"//"))
551 csPath = pApp->
m_path + csPath;
558 while ((nPos = csPath.indexOf(
"/../")) >= 0)
562 while (nPos >= 1 && csPath[nPos-1] !=
'/')
567 csPath = csPath.left(nPos) + csPath.mid(nEnd);
607 throw "FindObject failed";
633 catch(
const std::exception& ex)
697 pEvent->m_eventType = ev;
698 pEvent->m_eventData = evData;
714 link->MatchEvent(sourceRef, ev, un,
this);
732 for (
int i = actions.
Size(); i > 0; i--)
786 Redraw(pVis->GetVisibleArea());
804 Redraw(pVis->GetVisibleArea());
838 Redraw(pVis->GetVisibleArea());
869 Redraw(pVis->GetVisibleArea());
880 if (toDraw.isEmpty())
885 while (nStackPos >= 0)
892 if (! drawArea.isEmpty())
1013 if (csPath.isEmpty())
1029 reinterpret_cast< const unsigned char *
>(text.constData()),
1032 catch(
const std::exception& ex)
1057 pContent->m_pRequester = pRequester;
1058 pContent->m_time.start();
1101 .arg(text.size()) );
1106 reinterpret_cast< const unsigned char *
>(text.constData()),
1109 catch(
const std::exception& ex)
1130 else if (pContent->
m_time.elapsed() > 60000)
1154 QString
const csFile = QString::fromUtf8(
1155 (
const char *)fileName.
Bytes(), fileName.
Size() );
1177 "Load Persistent(%1) #%2: no such file")
1178 .arg(csFile).arg(variables.
Size()) );
1189 if (pEntry ==
nullptr)
1198 "Load Persistent(%1): size mismatch").arg(csFile));
1202 for (i = 0; i < variables.
Size(); i++)
1206 .arg(csFile).arg(i).arg(pValue->
Printable()) );
1220 for (i = 0; i < variables.
Size(); i++)
1226 .arg(csFile, pValue->Printable(), QString::number(i)) );
1236 QString csFeat = QString::fromUtf8((
const char *)
feature.Bytes(),
feature.Size());
1237 static const QRegularExpression kSeparatorRE { R
"([\(\,\)])" };
1238 QStringList strings = csFeat.split(kSeparatorRE);
1242 if (strings[0] ==
"ApplicationStacking" || strings[0] ==
"ASt")
1248 if (strings[0] ==
"Cloning" || strings[0] ==
"Clo")
1253 if (strings[0] ==
"SceneCoordinateSystem" || strings[0] ==
"SCS")
1255 return strings.count() >= 3 && strings[1] ==
"720" && strings[2] ==
"576";
1260 if (strings[0] ==
"MultipleAudioStreams" || strings[0] ==
"MAS")
1262 return strings.count() >= 2 && (strings[1] ==
"0" || strings[1] ==
"1");
1265 if (strings[0] ==
"MultipleVideoStreams" || strings[0] ==
"MVS")
1267 return strings.count() >= 2 && (strings[1] ==
"0" || strings[1] ==
"1");
1271 if (strings[0] ==
"OverlappingVisibles" || strings[0] ==
"OvV")
1276 if (strings[0] ==
"SceneAspectRatio" || strings[0] ==
"SAR")
1278 if (strings.count() < 3)
1282 return (strings[1] ==
"4" && strings[2] ==
"3") || (strings[1] ==
"16" && strings[2] ==
"9");
1286 if (strings[0] ==
"VideoScaling" || strings[0] ==
"VSc")
1288 if (strings.count() < 4 || strings[1] !=
"10")
1292 return (strings[2] ==
"720" && strings[3] ==
"576") || (strings[2] ==
"360" && strings[3] ==
"288");
1295 if (strings[0] ==
"BitmapScaling" || strings[0] ==
"BSc")
1297 if (strings.count() < 4 || strings[1] !=
"2")
1301 return (strings[2] ==
"720" && strings[3] ==
"576") || (strings[2] ==
"360" && strings[3] ==
"288");
1305 if (strings[0] ==
"VideoDecodeOffset" || strings[0] ==
"VDO")
1307 return strings.count() >= 3 && strings[1] ==
"10" && strings[1] ==
"0";
1311 if (strings[0] ==
"BitmapDecodeOffset" || strings[0] ==
"BDO")
1313 if (strings.count() >= 3 && strings[1] ==
"2" && (strings[2] ==
"0" || strings[2] ==
"1"))
1317 if (strings.count() >= 2 && (strings[1] ==
"4" || strings[1] ==
"6"))
1324 if (strings[0] ==
"UKEngineProfile" || strings[0] ==
"UniversalEngineProfile" || strings[0] ==
"UEP")
1326 if (strings.count() < 2)
1348 if (strings[1] ==
"2")
1350 if (strings[1] ==
"1")
1353 if (strings[1] ==
"PANT11001")
1356 if (strings[1] ==
"1285")
1363 if (strings[0] ==
"ICProfile" || strings[0] ==
"ICP") {
1364 if (strings.count() < 2)
return false;
1365 if (strings[1] ==
"0")
1367 if (strings[1] ==
"1")
1372 if (strings[0] ==
"HDExtension" || strings[0] ==
"HDE") {
1373 if (strings.count() < 2)
return false;
1374 if (strings[1] ==
"0")
1376 if (strings[1] ==
"1")
1380 if (strings[0] ==
"HDGraphicsPlaneExtension" || strings[0] ==
"HDG") {
1381 if (strings.count() < 2)
return false;
1383 return strings[1] ==
"0";
1515 str.
Copy(
"plain.24.24.0");
1530 QByteArray
tmp = logtext.toLatin1();
void MHSetLogging(FILE *logStream, unsigned int logLevel)
void mhlog_fn(const QString &logtext)
static EProtocol PathProtocol(const QString &csPath)
MHEG * MHCreateEngine(MHContext *context)
static constexpr std::chrono::milliseconds CONTENT_CHECK_TIME
#define MHLOG(__level, __text)
@ EventFirstItemPresented
@ EventSliderValueChanged
@ EventInteractionCompleted
static const std::array< featureStruct, 7 > feature
MHColour m_buttonRefColour
MHColour m_highlightRefColour
MHColour m_sliderRefColour
int FindOnStack(const MHRoot *pVis)
void Activation(MHEngine *engine) override
MHSequence< MHVisible * > m_displayStack
MHOctetString m_fontAttrs
MHScene * m_pCurrentScene
void SetFromString(const char *str, int nLen)
void Copy(const MHColour &col)
MHOctetString m_contentRef
virtual bool CheckCarouselObject(const QString &objectPath)=0
virtual const char * GetReceiverId(void)=0
virtual bool CheckStop(void)=0
virtual void DrawBackground(const QRegion ®)=0
virtual bool GetCarouselData(const QString &objectPath, QByteArray &result)=0
virtual void SetInputRegister(int nReg)=0
virtual void RequireRedraw(const QRegion ®ion)=0
virtual const char * GetDSMCCId(void)=0
virtual void Perform(MHEngine *engine)=0
virtual void PrintMe(FILE *fd, int nTabs) const
MHEngine(MHContext *context)
void RemoveFromDisplayStack(MHVisible *pVis)
std::chrono::milliseconds RunAll(void) override
void Redraw(const QRegion ®ion)
void CheckContentRequests()
void TransitionToScene(const MHObjectRef &target)
QQueue< MHAsynchEvent * > m_eventQueue
void DrawDisplay(const QRegion &toDraw) override
MHRoot * FindObject(const MHObjectRef &oRef, bool failOnNotFound=true)
QList< MHExternContent * > m_externContentTable
bool Launch(const MHObjectRef &target, bool fIsSpawn=false)
void AddLink(MHLink *pLink)
bool LoadStorePersistent(bool fIsLoad, const MHOctetString &fileName, const MHSequence< MHObjectRef * > &variables)
QStack< MHElemAction * > m_actionStack
bool GetEngineSupport(const MHOctetString &feature)
QList< MHLink * > m_linkTable
void SetInputRegister(int nReg)
int GetDefaultTextCHook()
MHOwnPtrSequence< MHPSEntry > m_persistentStore
void GetDefaultBGColour(MHColour &colour)
QString GetPathName(const MHOctetString &str)
void PutBehind(const MHRoot *pVis, const MHRoot *pRef)
void RemoveLink(MHLink *pLink)
void RequestExternalContent(MHIngredient *pRequester)
static const char * MHEGEngineProviderIdString
QStack< MHApplication * > m_applicationStack
void AddToDisplayStack(MHVisible *pVis)
void EventTriggered(MHRoot *pSource, enum EventType ev)
void GetDefaultButtonRefColour(MHColour &colour)
void GenerateUserAction(int nCode) override
MHGroup * ParseProgram(QByteArray &text)
void CheckLinks(const MHObjectRef &sourceRef, enum EventType ev, const MHUnion &un)
void GetDefaultHighlightRefColour(MHColour &colour)
void CancelExternalContentRequest(MHIngredient *pRequester)
void GetDefaultTextColour(MHColour &colour)
void PutBefore(const MHRoot *pVis, const MHRoot *pRef)
MHInteractible * m_interacting
void BringToFront(const MHRoot *pVis)
void GetDefaultFontAttrs(MHOctetString &str)
void AddActions(const MHActionSequence &actions)
int GetDefaultStreamCHook()
void SendToBack(const MHRoot *pVis)
void StreamStarted(MHStream *stream, bool bStarted) override
void GetDefaultSliderRefColour(MHColour &colour)
MHApplication * CurrentApp()
void DrawRegion(const QRegion &toDraw, int nStackPos)
void EngineEvent(int nCode) override
int GetDefaultBitmapCHook()
MHIngredient * m_pRequester
void PrintMe(FILE *fd, int nTabs) const override
void Preparation(MHEngine *engine) override
MHRoot * FindByObjectNo(int n) override
void Destruction(MHEngine *engine) override
MHOwnPtrSequence< MHIngredient > m_items
std::chrono::milliseconds CheckTimers(MHEngine *engine)
void Deactivation(MHEngine *engine) override
void Activation(MHEngine *engine) override
MHContentRef m_contentRef
virtual void ContentArrived(const unsigned char *, int, MHEngine *)
virtual void KeyEvent(MHEngine *, int)
static QString EventTypeToString(enum EventType ev)
QString Printable() const
void Copy(const MHOctetString &str)
const unsigned char * Bytes() const
bool Equal(const MHOctetString &str) const
MHOwnPtrSequence< MHUnion > m_Data
static void Failure(const char *p)
MHObjectRef m_ObjectReference
virtual void Deactivation(MHEngine *engine)
virtual void GetVariableValue(MHUnion &, MHEngine *)
virtual void SetVariableValue(const MHUnion &)
void InsertAt(BASE b, int n)
QString Printable() const
virtual QRegion GetOpaqueArea()
virtual QRegion GetVisibleArea()
virtual void Display(MHEngine *)=0