Ejemplo n.º 1
0
 /// <summary>
 /// Page is focusing a text entry area in IME mode
 /// </summary>
 public void IMEFocusIn(ref UWKMessage msg)
 {
     IMEActive    = true;
     IMEInputRect = new Rect(msg.iParams[0], msg.iParams[1], msg.iParams[2], msg.iParams[3]);
     IMEInputType = UWKPlugin.GetMessageString(ref msg, 0);
     IMEText      = UWKPlugin.GetMessageString(ref msg, 1);
 }
Ejemplo n.º 2
0
    private static void processMessage(IntPtr pcmd)
    {
        UWKMessage msg = (UWKMessage)Marshal.PtrToStructure(pcmd, typeof(UWKMessage));

        msg._this = pcmd;
        UWKCore.ProcessMessage(ref msg);
    }
Ejemplo n.º 3
0
    public static bool GetMsgDataBytes(ref UWKMessage msg, int index, int sz, byte[] bytes)
    {
        GCHandle pinned = GCHandle.Alloc(bytes, GCHandleType.Pinned);
        bool     r      = UWK_GetMsgDataBytes(msg._this, index, pinned.AddrOfPinnedObject(), sz);

        pinned.Free();
        return(r);
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Page is focusing a text entry area in IME mode
 /// </summary>
 public void IMEFocusIn(ref UWKMessage msg)
 {
     IMEActive = true;
     IMEInputRect = new Rect(msg.iParams[0], msg.iParams[1], msg.iParams[2], msg.iParams[3]);
     IMEInputType = UWKPlugin.GetMessageString(ref msg, 0);
     IMEText = UWKPlugin.GetMessageString(ref msg, 1);
 }
Ejemplo n.º 5
0
 public static int GetMsgDataSize(ref UWKMessage msg, int index)
 {
     return UWK_GetMsgDataSize(msg._this, index);
 }
Ejemplo n.º 6
0
 public static bool GetMsgDataBytes(ref UWKMessage msg, int index, int sz, byte[] bytes)
 {
     GCHandle pinned = GCHandle.Alloc (bytes, GCHandleType.Pinned);
     bool r = UWK_GetMsgDataBytes (msg._this, index, pinned.AddrOfPinnedObject (), sz);
     pinned.Free ();
     return r;
 }
Ejemplo n.º 7
0
 public static string GetMessageString(ref UWKMessage msg, int index)
 {
     IntPtr address = UWK_GetMessageDataPtr(msg._this, index);
     return stringFromNativeUtf8(address);
 }
Ejemplo n.º 8
0
    public static string GetMessageString(ref UWKMessage msg, int index)
    {
        IntPtr address = UWK_GetMessageDataPtr(msg._this, index);

        return(stringFromNativeUtf8(address));
    }
Ejemplo n.º 9
0
 public static int GetMsgDataSize(ref UWKMessage msg, int index)
 {
     return(UWK_GetMsgDataSize(msg._this, index));
 }
Ejemplo n.º 10
0
    /// <summary>
    /// Internal Plugin -> Unity message receiving
    /// </summary>
    public static void ProcessMessage(ref UWKMessage msg)
    {
        UWKWebView view = null;

        bool msgView = false;

        switch (msg.type)
        {
        case UWKMessageType.UMSG_VIEW_LOADFINISHED:
        case UWKMessageType.UMSG_VIEW_URLCHANGED:
        case UWKMessageType.UMSG_VIEW_TITLECHANGED:
        case UWKMessageType.UMSG_VIEW_LOADPROGRESS:
        case UWKMessageType.UMSG_VIEW_ICONCHANGED:
        case UWKMessageType.UMSG_JAVASCRIPT_CONSOLE:
        case UWKMessageType.UMSG_JAVASCRIPT_MESSAGE:
        case UWKMessageType.UMSG_VIEW_CONTENTSIZECHANGED:
        case UWKMessageType.UMSG_IME_FOCUSIN:
        case UWKMessageType.UMSG_IME_FOCUSOUT:
        case UWKMessageType.UMSG_VIEW_REQUESTNEWVIEW:
            msgView = true;
            break;
        }

        if (msgView)
        {
            if (!viewLookup.TryGetValue(msg.browserID, out view))
            {
                Debug.Log("Warning: Unable to get view for message: " + Enum.GetName(typeof(UWKMessageType), msg.type));
                return;
            }
        }

        switch (msg.type)
        {
        case UWKMessageType.UMSG_VIEW_LOADFINISHED:
            view.LoadFinished(view);
            break;

        case UWKMessageType.UMSG_VIEW_URLCHANGED:
            view.URLChanged(view, UWKPlugin.GetMessageString(ref msg, 0));
            break;

        case UWKMessageType.UMSG_VIEW_TITLECHANGED:
            view.TitleChanged(view, UWKPlugin.GetMessageString(ref msg, 0));
            break;

        case UWKMessageType.UMSG_VIEW_LOADPROGRESS:
            view.LoadProgress(view, msg.iParams[0]);
            break;

        case UWKMessageType.UMSG_VIEW_ICONCHANGED:

            int size = UWKPlugin.GetMsgDataSize(ref msg, 0);

            if (size > 0)
            {
                byte[] bytes = new byte[size];

                if (UWKPlugin.GetMsgDataBytes(ref msg, 0, size, bytes))
                {
                    view.IconChanged(msg.iParams[0], msg.iParams[1], bytes);
                }
            }

            break;

        case UWKMessageType.UMSG_JAVASCRIPT_CONSOLE:
            view.JSConsole(view, UWKPlugin.GetMessageString(ref msg, 0), msg.iParams[0], UWKPlugin.GetMessageString(ref msg, 1));
            break;

        case UWKMessageType.UMSG_JAVASCRIPT_MESSAGE:
            var json = UWKPlugin.GetMessageString(ref msg, 1);
            var dict = UWKJson.Deserialize(json) as Dictionary <string, object>;
            view.JSMessageReceived(view, UWKPlugin.GetMessageString(ref msg, 0), json, dict);
            break;

        case UWKMessageType.UMSG_VIEW_CONTENTSIZECHANGED:
            view.ContentSizeChanged(view, msg.iParams[0], msg.iParams[1]);
            break;

        case UWKMessageType.UMSG_IME_FOCUSIN:
            view.IMEFocusIn(ref msg);
            break;

        case UWKMessageType.UMSG_IME_FOCUSOUT:
            view.IMEFocusOut();
            break;

        case UWKMessageType.UMSG_VIEW_REQUESTNEWVIEW:
            view.NewViewRequested(view, UWKPlugin.GetMessageString(ref msg, 0));
            break;

        case UWKMessageType.UMSG_ACTIVATION_STATE:
            #if UNITY_EDITOR
            if (msg.iParams[0] != 1 && msg.iParams[0] != 5)
            {
                if (sInstance.gameObject.GetComponent <UWKActivation>() == null)
                {
                    sInstance.gameObject.AddComponent <UWKActivation>();
                }
            }
            UWKActivation.SetActivationState(msg.iParams[0]);
            #endif

            break;
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Internal Plugin -> Unity message receiving
    /// </summary>
    public static void ProcessMessage(ref UWKMessage msg)
    {
        UWKWebView view = null;

        bool msgView = false;
        switch (msg.type)
        {
            case UWKMessageType.UMSG_VIEW_LOADFINISHED:
            case UWKMessageType.UMSG_VIEW_URLCHANGED:
            case UWKMessageType.UMSG_VIEW_TITLECHANGED:
            case UWKMessageType.UMSG_VIEW_LOADPROGRESS:
            case UWKMessageType.UMSG_VIEW_ICONCHANGED:
            case UWKMessageType.UMSG_JAVASCRIPT_CONSOLE:
            case UWKMessageType.UMSG_JAVASCRIPT_MESSAGE:
            case UWKMessageType.UMSG_VIEW_CONTENTSIZECHANGED:
            case UWKMessageType.UMSG_IME_FOCUSIN:
            case UWKMessageType.UMSG_IME_FOCUSOUT:
            case UWKMessageType.UMSG_VIEW_REQUESTNEWVIEW:
                msgView = true;
                break;
        }

        if (msgView)
        {
            if (!viewLookup.TryGetValue(msg.browserID, out view))
            {
                Debug.Log("Warning: Unable to get view for message: " + Enum.GetName(typeof(UWKMessageType), msg.type));
                return;
            }
        }

        switch (msg.type)
        {
            case UWKMessageType.UMSG_VIEW_LOADFINISHED:
                view.LoadFinished(view);
                break;
            case UWKMessageType.UMSG_VIEW_URLCHANGED:
                view.URLChanged(view, UWKPlugin.GetMessageString(ref msg, 0));
                break;
            case UWKMessageType.UMSG_VIEW_TITLECHANGED:
                view.TitleChanged(view, UWKPlugin.GetMessageString(ref msg, 0));
                break;
            case UWKMessageType.UMSG_VIEW_LOADPROGRESS:
                view.LoadProgress(view, msg.iParams[0]);
                break;
            case UWKMessageType.UMSG_VIEW_ICONCHANGED:

                int size = UWKPlugin.GetMsgDataSize(ref msg, 0);

                if (size > 0)
                {
                    byte[] bytes = new byte[size];

                    if (UWKPlugin.GetMsgDataBytes(ref msg, 0, size, bytes))
                    {
                        view.IconChanged(msg.iParams[0], msg.iParams[1], bytes);
                    }
                }

                break;
            case UWKMessageType.UMSG_JAVASCRIPT_CONSOLE:
                view.JSConsole(view, UWKPlugin.GetMessageString(ref msg, 0), msg.iParams[0], UWKPlugin.GetMessageString(ref msg, 1));
                break;
            case UWKMessageType.UMSG_JAVASCRIPT_MESSAGE:
                var json = UWKPlugin.GetMessageString(ref msg, 1);
                var dict = UWKJson.Deserialize(json) as Dictionary<string,object>;
                view.JSMessageReceived(view, UWKPlugin.GetMessageString(ref msg, 0), json, dict);            
                break;
            case UWKMessageType.UMSG_VIEW_CONTENTSIZECHANGED:
                view.ContentSizeChanged(view, msg.iParams[0], msg.iParams[1]);
                break;
            case UWKMessageType.UMSG_IME_FOCUSIN:
                view.IMEFocusIn(ref msg);
                break;
            case UWKMessageType.UMSG_IME_FOCUSOUT:
                view.IMEFocusOut();
                break;
            case UWKMessageType.UMSG_VIEW_REQUESTNEWVIEW:
                view.NewViewRequested(view, UWKPlugin.GetMessageString(ref msg, 0));
                break;
            case UWKMessageType.UMSG_ACTIVATION_STATE:
            #if UNITY_EDITOR   
	            if (msg.iParams[0] != 1 && msg.iParams[0] != 5)
	            {
					if (sInstance.gameObject.GetComponent<UWKActivation>() == null)
						sInstance.gameObject.AddComponent<UWKActivation>();
	            }
				UWKActivation.SetActivationState(msg.iParams[0]);
            #endif      

                break;

        }

    }