-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtension.cpp
More file actions
226 lines (184 loc) · 6.79 KB
/
Copy pathExtension.cpp
File metadata and controls
226 lines (184 loc) · 6.79 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#include "Common.hpp"
///
/// EXTENSION CONSTRUCTOR/DESTRUCTOR
///
#ifdef _WIN32
Extension::Extension(RunObject* const _rdPtr, const EDITDATA* const edPtr, const CreateObjectInfo* const cobPtr) :
rdPtr(_rdPtr), rhPtr(_rdPtr->get_rHo()->get_AdRunHeader()), Runtime(this), FusionDebugger(this)
#elif defined(__ANDROID__)
Extension::Extension(const EDITDATA* const edPtr, const jobject javaExtPtr) :
javaExtPtr(javaExtPtr, "Extension::javaExtPtr from Extension ctor"),
Runtime(this, this->javaExtPtr), FusionDebugger(this)
#else
Extension::Extension(const EDITDATA* const edPtr, void* const objCExtPtr) :
objCExtPtr(objCExtPtr), Runtime(this, objCExtPtr), FusionDebugger(this)
#endif
{
/*
Link all your action/condition/expression functions to their IDs to match the
IDs in the JSON here
*/
/*LinkAction(0, ActionExample);
LinkAction(1, SecondActionExample);*/
LinkAction(0, WriteText);
LinkAction(1, ReadText);
LinkAction(2, ClearText);
LinkAction(3, EnablePasteCapture);
LinkAction(4, DisablePasteCapture);
LinkAction(5, ArmNextClickRead);
LinkAction(6, ArmNextClickWrite);
LinkAction(7, QueryReadPermission);
LinkAction(8, QueryWritePermission);
LinkAction(9, WarmUpReadPermission);
LinkAction(10, ResetErrors);
LinkAction(11, SetOperationTimeout);
/*LinkCondition(0, AreTwoNumbersEqual);*/
LinkCondition(0, OnReadSuccess);
LinkCondition(1, OnReadFailed);
LinkCondition(2, OnWriteSuccess);
LinkCondition(3, OnWriteFailed);
LinkCondition(4, OnTimeout);
LinkCondition(5, OnPaste);
LinkCondition(6, OnPermissionReadResult);
LinkCondition(7, OnPermissionWriteResult);
LinkCondition(8, OnArmedGestureFired);
LinkCondition(9, IsApiSupported);
LinkCondition(10, HasUserActivation);
LinkCondition(11, HasFocusCnd);
LinkCondition(12, IsVisibleCnd);
/*LinkExpression(0, Add);
LinkExpression(1, HelloWorld);*/
LinkExpression(0, ClipboardText);
LinkExpression(1, PasteText);
LinkExpression(2, HasError);
LinkExpression(3, LastError);
LinkExpression(4, LastErrorMessage);
LinkExpression(5, LastErrorCode);
LinkExpression(6, PermissionReadState);
LinkExpression(7, PermissionReadStateCode);
LinkExpression(8, PermissionWriteState);
LinkExpression(9, PermissionWriteStateCode);
LinkExpression(10, IsSupportedExp);
LinkExpression(11, HasUserActivationExp);
LinkExpression(12, HasFocusExp);
LinkExpression(13, IsVisibleExp);
LinkExpression(14, PendingOp);
LinkExpression(15, PendingOpCode);
LinkExpression(16, TAG_ErrOK);
LinkExpression(17, TAG_ErrNotAllowed);
LinkExpression(18, TAG_ErrNotFound);
LinkExpression(19, TAG_ErrSecurity);
LinkExpression(20, TAG_ErrType);
LinkExpression(21, TAG_ErrUnknown);
LinkExpression(22, TAG_ErrNameOK);
LinkExpression(23, TAG_ErrNameNotAllowed);
LinkExpression(24, TAG_ErrNameNotFound);
LinkExpression(25, TAG_ErrNameSecurity);
LinkExpression(26, TAG_ErrNameType);
LinkExpression(27, TAG_ErrNameUnknown);
LinkExpression(28, TAG_PermGranted);
LinkExpression(29, TAG_PermPrompt);
LinkExpression(30, TAG_PermDenied);
LinkExpression(31, TAG_PermUnsupported);
LinkExpression(32, TAG_PermNameGranted);
LinkExpression(33, TAG_PermNamePrompt);
LinkExpression(34, TAG_PermNameDenied);
LinkExpression(35, TAG_PermNameUnsupported);
LinkExpression(36, TAG_OpNone);
LinkExpression(37, TAG_OpRead);
LinkExpression(38, TAG_OpWrite);
LinkExpression(39, TAG_OpNameNone);
LinkExpression(40, TAG_OpNameRead);
LinkExpression(41, TAG_OpNameWrite);
/*
This is where you'd do anything you'd do in CreateRunObject in the original SDK
It's the only place you'll get access to edPtr at runtime, so you should transfer
anything from edPtr to the extension class here.
*/
// Don't use "this" inside these lambda functions, always ext.
// There can be nothing in the [] section of the lambda.
// If you're not sure about lambdas, you can remove this debugger stuff without any side effects;
// it's just an example of how to use the debugger. You can view it in Fusion itself to see.
/*FusionDebugger.AddItemToDebugger(
// reader function for your debug item
[](Extension *ext, std::tstring &writeTo) {
writeTo = _T("My text is: ") + ext->exampleDebuggerTextItem;
},
// writer function (can be null if you don't want user to be able to edit it in debugger)
[](Extension *ext, std::tstring &newText)
{
ext->exampleDebuggerTextItem = newText;
return true; // accept the changes
}, 500, NULL
);*/
// Read object DarkEdif properties; you can pass property name, or property index
// This will work on all platforms the same way.
/*bool checkboxWithinFolder = edPtr->Props.IsPropChecked("Checkbox within folder"sv);
std::tstring editable6Text = edPtr->Props.GetPropertyStr("Editable 6"sv);*/
// These lines do nothing, but prevent the compiler warning the variables are unused
/*(void)checkboxWithinFolder;
(void)editable6Text;*/
}
Extension::~Extension()
{
}
REFLAG Extension::Handle()
{
/*
If your extension will draw to the MMF window you should first
check if anything about its display has changed :
if (rdPtr->roc.rcChanged)
return REFLAG::DISPLAY;
else
return REFLAG::NONE;
You will also need to make sure you change this flag yourself
to 1 whenever you want to redraw your object
If your extension won't draw to the window, but it still needs
to do something every MMF loop use :
return REFLAG::NONE;
If you don't need to do something every loop, use :
return REFLAG::ONE_SHOT;
This doesn't mean this function can never run again. If you want MMF
to handle your object again (causing this code to run) use this function:
Runtime.Rehandle();
At the end of the loop this code will run
*/
// Will not be called next loop
return REFLAG::ONE_SHOT;
}
REFLAG Extension::Display()
{
/*
If you return REFLAG_DISPLAY in Handle() this routine will run.
*/
// Ok
return REFLAG::DISPLAY;
}
short Extension::FusionRuntimePaused()
{
// Ok
return 0;
}
short Extension::FusionRuntimeContinued()
{
// Ok
return 0;
}
// These are called if there's no function linked to an ID
void Extension::UnlinkedAction(int ID)
{
DarkEdif::MsgBox::Error(_T("Extension::UnlinkedAction() called"), _T("Running a fallback for action ID %d. Make sure you ran LinkAction()."), ID);
}
long Extension::UnlinkedCondition(int ID)
{
DarkEdif::MsgBox::Error(_T("Extension::UnlinkedCondition() called"), _T("Running a fallback for condition ID %d. Make sure you ran LinkCondition()."), ID);
return 0;
}
long Extension::UnlinkedExpression(int ID)
{
DarkEdif::MsgBox::Error(_T("Extension::UnlinkedExpression() called"), _T("Running a fallback for expression ID %d. Make sure you ran LinkExpression()."), ID);
// Unlinked A/C/E is fatal error, but try not to return null string and definitely crash it
if ((size_t)ID < Edif::SDK->ExpressionInfos.size() && Edif::SDK->ExpressionInfos[ID]->Flags.ef == ExpReturnType::String)
return (long)Runtime.CopyString(_T(""));
return 0;
}