1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
#ifndef JORSERVER_H
#define JORSERVER_H
#include "JSystem/JHostIO/JOREntry.h"
#include "JSystem/JHostIO/JORMContext.h"
#include "JSystem/JHostIO/JHIComm.h"
#include "JSystem/JHostIO/JHIhioASync.h"
#include "JSystem/JGadget/linklist.h"
#include "JSystem/JUtility/JUTAssert.h"
u32 JORMessageBox(const char* message, const char* title, u32 style);
int JORShellExecute(const char* param_0, const char* param_1, const char* param_2, const char* param_3, int param_4);
struct JOREventCallbackListNode {
JOREventCallbackListNode(u32, u32, bool);
void JORAppend();
void JORRemove();
virtual int JORAct(u32, const char*);
virtual ~JOREventCallbackListNode();
bool JORIsAcceptableID(u32 eventID) const {
bool result = false;
if (field_0xc <= eventID && eventID <= field_0x10) {
result = true;
}
return result;
}
/* 0x04 */ JGadget::TLinkListNode m_node;
/* 0x0C */ u32 field_0xc;
/* 0x10 */ u32 field_0x10;
};
class JORFile;
class JORDir;
class JORHostInfo_String;
class JORHostInfo_CalendarTime;
class JORServer : public JHITag<JHICmnMem> {
public:
typedef void (*EventFunc)(u32,char *);
typedef JGadget::TLinkList<JOREventCallbackListNode, -4> CallbackLinkList;
enum ECommand {
ECommand_GetRootObj = 1,
ECommand_GenObjInfo = 3,
ECommand_NodeEvent = 6,
ECommand_PropertyEvent = 7,
ECommand_FIO = 9,
ECommand_ReadResultS32 = 10,
ECommand_ReadOrEvent = 11,
ECommand_DIR = 13,
ECommand_HostInfo = 14,
ECommand_ReadResultU32 = 15,
};
JORServer() : JHITag<JHICmnMem>('ORef'),
m_event(false),
m_eventDone(true),
m_eventFunc(NULL),
m_isEventCallbackListEnabled(false)
{}
static JORServer* create();
void receive(const char*, s32);
JORMContext* attachMCTX(u32);
void releaseMCTX(JORMContext*);
void appendEventCallbackListNode(JOREventCallbackListNode* p) {
JUT_ASSERT(256, p!=NULL);
m_eventCallbackList.Push_front(p);
}
void removeEventCallbackListNode(JOREventCallbackListNode* p) {
JUT_ASSERT(257, p!=NULL);
m_eventCallbackList.Remove(p);
}
static void defSetVal(void*, u32, s32);
static void defSetBitVal(void*, u32, u16, u16);
void fio_openFile_(JSUMemoryInputStream&);
void fio_closeFile_(JSUMemoryInputStream&);
void fio_readData_(JSUMemoryInputStream&);
void fio_writeData_(JSUMemoryInputStream&);
void fio_dispatchMessage_(JSUMemoryInputStream&);
void dir_findFirstFile_(JSUMemoryInputStream&, JORDir*);
void dir_findNextFile_(JSUMemoryInputStream&, JORDir*);
void dir_browseForFolder_(JSUMemoryInputStream&, JORDir*);
void readResultS32_(JSUMemoryInputStream&);
void readOrEvent_(JSUMemoryInputStream&);
void dir_dispatchMessage_(JSUMemoryInputStream&);
void hostinfo_dispatchMessage_(JSUMemoryInputStream&);
void hostinfo_recvString_(JSUMemoryInputStream&, JORHostInfo_String*);
void hostinfo_localTime_(JSUMemoryInputStream&, JORHostInfo_CalendarTime*);
void readResultU32_(JSUMemoryInputStream&);
void sendReset();
void setRootNode(const char*, JORReflexible*, u32, u32);
void doneEvent();
bool getEvent() { return m_event; }
void setEvent(bool event) { m_event = event; }
void setEventDone(bool eventDone) { m_eventDone = eventDone; }
u32 getEventNum() { return m_eventNum; }
char* getEventName() { return m_eventName; }
EventFunc getEventFunc() { return m_eventFunc; }
void setEventFunc(EventFunc func) { m_eventFunc = func; }
bool isEventCallbackListEnabled() const { return m_isEventCallbackListEnabled; }
void enableEventCallbackList(bool enable) { m_isEventCallbackListEnabled = enable; }
CallbackLinkList* referEventCallbackList() { return &m_eventCallbackList; }
static JORServer* getInstance() { return instance; }
static JORServer* instance;
/* 0x0000C */ JORMContext m_context;
/* 0x10020 */ JORReflexible* mp_rootObj;
/* 0x10024 */ char m_rootName[64];
/* 0x10064 */ u32 field_0x10064;
/* 0x10068 */ u32 field_0x10068;
/* 0x1006C */ bool m_event;
/* 0x1006D */ bool m_eventDone;
/* 0x10070 */ u32 m_eventNum;
/* 0x10074 */ char m_eventName[0x1000];
/* 0x11074 */ EventFunc m_eventFunc;
/* 0x11078 */ bool m_isEventCallbackListEnabled;
/* 0x1107C */ CallbackLinkList m_eventCallbackList;
};
inline u32 JOR_MESSAGELOOP() {
JORServer* server = JORServer::getInstance();
JHIComPortManager<JHICmnMem>::getInstance()->dispatchMessage();
if (server->getEvent()) {
server->setEvent(false);
server->setEventDone(false);
u32 eventNum = server->getEventNum();
char* eventName = server->getEventName();
if (server->isEventCallbackListEnabled() && eventNum >= 0x80000000) {
JORServer::CallbackLinkList* list = server->referEventCallbackList();
JORServer::CallbackLinkList::iterator end = list->end();
for (JORServer::CallbackLinkList::iterator it = list->begin(); it != end;) {
JOREventCallbackListNode& callback = *it;
++it;
if (!callback.JORIsAcceptableID(eventNum)) {
continue;
}
if (callback.JORAct(eventNum, eventName)) {
break;
}
}
} else {
JORServer::EventFunc func = server->getEventFunc();
if (func) {
func(eventNum, eventName);
}
}
server->doneEvent();
}
return JHIEventLoop();
}
inline void JOR_INIT() {
JORInit();
JORServer::getInstance()->setEventFunc(NULL);
}
inline void JOR_SETROOTNODE(const char* name, JORReflexible* node, u32 param_3, u32 param_4) {
JORServer::getInstance()->setRootNode(name, node, param_3, param_4);
}
inline JORMContext* attachJORMContext(u32 msgID) {
return JORServer::getInstance()->attachMCTX(msgID);
}
inline JORMContext* JORAttachMContext(u32 msgID) {
return JORServer::getInstance()->attachMCTX(msgID);
}
inline void releaseJORMContext(JORMContext* mctx) {
JORServer::getInstance()->releaseMCTX(mctx);
}
inline void JORReleaseMContext(JORMContext* mctx) {
JORServer::getInstance()->releaseMCTX(mctx);
}
inline void JOR_ENABLEEVENTCALLBACKLIST(bool enable) {
JORServer::getInstance()->enableEventCallbackList(enable);
}
#endif /* JORSERVER_H */
|