Skip to content

Commit 3767508

Browse files
committed
Fixed structures
Added requestid to loaded handled
1 parent 425e74f commit 3767508

5 files changed

Lines changed: 30 additions & 36 deletions

File tree

src/EmptyFlow.SciterAPI/Client/SciterAPIGlobalCallbacks.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class SciterAPIGlobalCallbacks {
1919
private Dictionary<string, Func<string, byte[]>> m_protocolHandlers = new Dictionary<string, Func<string, byte[]>> ();
2020

2121
[DynamicDependency ( DynamicallyAccessedMemberTypes.All, typeof ( SciterAPIGlobalCallbacks ) )]
22-
private Action<string, uint, uint> m_loadedDataAction;
22+
private Action<string, uint, uint, nint> m_loadedDataAction;
2323

2424
[DynamicDependency ( DynamicallyAccessedMemberTypes.All, typeof ( SciterAPIGlobalCallbacks ) )]
2525
private Action m_engineDestroyedAction;
@@ -48,7 +48,7 @@ public SciterAPIGlobalCallbacks ( SciterAPIHost host ) {
4848
m_sciterHostCallback = SciterHostCallback;
4949
}
5050

51-
public Action<string, uint, uint> LoadedDataAction {
51+
public Action<string, uint, uint, nint> LoadedDataAction {
5252
get => m_loadedDataAction;
5353
set => m_loadedDataAction = value;
5454
}
@@ -113,7 +113,7 @@ private uint SciterHostCallback ( IntPtr pns, IntPtr callbackParam ) {
113113
return OnLoadData ( loadDataStructure );
114114
case SciterCallbackNotificationCode.SC_DATA_LOADED:
115115
var loadedDataStructure = Marshal.PtrToStructure<SciterCallbackNotificationLoadedData> ( pns );
116-
m_loadedDataAction ( loadedDataStructure.uri, loadedDataStructure.status, loadedDataStructure.dataSize );
116+
m_loadedDataAction ( loadedDataStructure.uri, loadedDataStructure.status, loadedDataStructure.dataSize, loadedDataStructure.requestId );
117117
return 0;
118118
case SciterCallbackNotificationCode.SC_ATTACH_BEHAVIOR:
119119
var behaviourStructure = Marshal.PtrToStructure<SciterCallbackNotificationAttachBehaviour> ( pns );
@@ -157,8 +157,8 @@ private uint OnLoadData ( SciterCallbackNotificationLoadData loadDataStruct ) {
157157
return (uint) LoadDataReturnCode.LOAD_OK; // in this case we don't need override load something
158158
}
159159

160-
private void EmptyLoadedDataAction ( string uri, uint status, uint dataSize ) {
161-
Console.WriteLine ( $"{uri} - {status}({dataSize})" );
160+
private void EmptyLoadedDataAction ( string uri, uint status, uint dataSize, nint request ) {
161+
Console.WriteLine ( $"{uri}, size: {dataSize}" );
162162
}
163163

164164
private void EmptyAction () {

src/EmptyFlow.SciterAPI/Client/SciterAPIHost.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,15 @@ public void PrepareRequestApi () {
195195
m_requestApi = Marshal.PtrToStructure<RequestApiStruct> ( pointer );
196196
}
197197

198+
public void Initialization () {
199+
m_basicApi.SciterExec ( ApplicationCommand.SCITER_APP_INIT, nint.Zero, nint.Zero );
200+
}
201+
198202
public int Process () {
199203
if (m_mainWindow != nint.Zero) ShowWindow ( m_mainWindow );
200204

205+
Initialization ();
206+
201207
// run loop for waiting close all windows
202208
var code = m_basicApi.SciterExec ( ApplicationCommand.SCITER_APP_LOOP, nint.Zero, nint.Zero );
203209

src/EmptyFlow.SciterAPI/EmptyFlow.SciterAPI.csproj

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,9 @@
2121
<Version>1.2.6.0</Version>
2222
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2323
<PackageReleaseNotes>
24-
SciterAPIHost.GetNodeType get node type
25-
SciterAPIHost.GetNodeText get node text
26-
SciterAPIHost.SetNodeText set node text
27-
SciterAPIHost.NodeParent get node parent
28-
SciterAPIHost.NodeNthChild get nth child of node
29-
SciterAPIHost.NodeChildrenCount get children count
30-
SciterAPIHost.NodeCastFromElement cast element to node
31-
SciterAPIHost.NodeCastToElement cast node to element
32-
SciterAPIHost.NodeInsert insert node to another node
33-
SciterAPIHost.NodeCreateTextNode create text node
34-
SciterAPIHost.NodeCreateCommentNode create comment node
35-
SciterValue.ToBoolean convert to C# boolean value
36-
From many methods Graphics API removed redundant check
37-
SciterAPIHost.GraphicsPath create path
38-
SciterAPIHost.GraphicsDrawPath draw path
39-
SciterAPIHost.GraphicsFillMode set fill mode
24+
SciterAPIHost.Initialization for run initialization
25+
SciterCallbackNotificationLoadedData fix structure
26+
SciterCallbackNotificationLoadData fix structure
4027
</PackageReleaseNotes>
4128
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4229
</PropertyGroup>
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
using System.Runtime.InteropServices;
22

33
namespace EmptyFlow.SciterAPI {
4-
[StructLayout ( LayoutKind.Sequential )]
5-
public struct SciterCallbackNotificationLoadData { // original name LPSCN_LOAD_DATA
6-
public SciterCallbackNotificationCode code;
7-
public IntPtr hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
8-
[MarshalAs ( UnmanagedType.LPWStr )] public string uri; // [in] Zero terminated string, fully qualified uri, for example "http://server/folder/file.ext".*/
9-
IntPtr outData; // [in,out] pointer to loaded data to return. if data exists in the cache then this field contain pointer to it
10-
uint outDataSize; // [in,out] loaded data size to return.
11-
uint dataType; // [in] SciterResourceType
12-
IntPtr requestId; // [in] request handle that can be used with sciter-x-request API */
13-
IntPtr principal; // Element
14-
IntPtr initiator; // Initiator
15-
}
4+
5+
[StructLayout ( LayoutKind.Sequential )]
6+
public struct SciterCallbackNotificationLoadData { // original name LPSCN_LOAD_DATA
7+
public SciterCallbackNotificationCode code;
8+
public nint hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
9+
[MarshalAs ( UnmanagedType.LPWStr )] public string uri; // [in] Zero terminated string, fully qualified uri, for example "http://server/folder/file.ext".*/
10+
public nint outData; // [in,out] pointer to loaded data to return. if data exists in the cache then this field contain pointer to it
11+
public uint outDataSize; // [in,out] loaded data size to return.
12+
public uint dataType; // [in] SciterResourceType
13+
public nint requestId; // [in] request handle that can be used with sciter-x-request API */
14+
public nint principal; // Element
15+
public nint initiator; // Initiator
16+
}
1617

1718
}

src/EmptyFlow.SciterAPI/Structs/SciterCallbackNotificationLoadedData.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ namespace EmptyFlow.SciterAPI {
44
[StructLayout ( LayoutKind.Sequential )]
55
public struct SciterCallbackNotificationLoadedData { // original name SCN_DATA_LOADED
66
public SciterCallbackNotificationCode code;
7-
public IntPtr hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
7+
public nint hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
88
[MarshalAs ( UnmanagedType.LPWStr )] public string uri; // [in] Zero terminated string, fully qualified uri, for example "http://server/folder/file.ext".*/
9-
public IntPtr data; // [in] pointer to loaded data.
9+
public nint data; // [in] pointer to loaded data.
1010
public uint dataSize; // [in] loaded data size (in bytes).
1111
public uint dataType; // [in] SciterResourceType
1212
public uint status; // [in] status = 0 (dataSize == 0) - unknown error. status = 100..505 - http response status, Note: 200 - OK! status > 12000 - wininet error code, see ERROR_INTERNET_*** in wininet.h
13-
public uint requestId; // [in] request handle that can be used with sciter-x-request API
13+
public nint requestId; // [in] request handle that can be used with sciter-x-request API
1414
}
1515

1616
}

0 commit comments

Comments
 (0)