Esempio n. 1
0
        /// <summary>
        /// The App control event callback function.
        /// </summary>
        /// <param name="source">The application instance.</param>
        /// <param name="e">The event argument for AppControl.</param>
        private void OnAppControl(object source, NUIApplicationAppControlEventArgs e)
        {
            Log.Info("NUI", "NUICorebackend OnAppControl Called");
            var handler = Handlers[EventType.AppControlReceived] as Action <AppControlReceivedEventArgs>;
            SafeAppControlHandle handle = new SafeAppControlHandle(e.VoidP, false);

            handler?.Invoke(new AppControlReceivedEventArgs(new ReceivedAppControl(handle)));
        }
Esempio n. 2
0
        private static void BindSafeHandleAction(Notification notification)
        {
            SafeAppControlHandle appcontrol = null;

            Interop.Notification.GetAppControl(notification.Handle, LaunchOption.AppControl, out appcontrol);
            if (appcontrol != null && appcontrol.IsInvalid == false)
            {
                notification.Action = new AppControl(appcontrol);
            }
        }
        public void AppControlReceivedEventArgs_INIT()
        {
            /* TEST CODE */
            AppControl           MyAppControl   = new AppControl();
            SafeAppControlHandle SafeHandle     = MyAppControl.SafeAppControlHandle;
            ReceivedAppControl   receiveAppCtrl = new ReceivedAppControl(SafeHandle);
            var _appctrlReceivedArgs            = new AppControlReceivedEventArgs(receiveAppCtrl);

            Assert.IsNotNull(_appctrlReceivedArgs, "AppControlReceivedEventArgs should not null after initializing");
            Assert.IsInstanceOf <AppControlReceivedEventArgs>(_appctrlReceivedArgs);
        }
Esempio n. 4
0
        private void OnAppControlNative(IntPtr appControlHandle, IntPtr data)
        {
            if (_handlers.ContainsKey(WatchEventType.AppControlReceived))
            {
                SafeAppControlHandle safeHandle = new SafeAppControlHandle(appControlHandle, false);

                var handler = _handlers[WatchEventType.AppControlReceived] as Action <AppControlReceivedEventArgs>;

                handler?.Invoke(new AppControlReceivedEventArgs(new ReceivedAppControl(safeHandle)));
            }
        }
Esempio n. 5
0
 private void ResultEventListenStart()
 {
     Interop.AttachPanel.ErrorCode err = 0;
     SetResultListener = (attachPanel, category, resulthandler, resultCode, userData) =>
     {
         SafeAppControlHandle handle = new SafeAppControlHandle(resulthandler, false);
         AppControl           result = new AppControl(handle);
         _resultEventHandler?.Invoke(null, new ResultEventArgs((ContentCategory)category, result, (AppControlReplyResult)resultCode));
     };
     err = Interop.AttachPanel.SetResultCb(_attachPanel, SetResultListener, IntPtr.Zero);
     CheckException(err);
 }
Esempio n. 6
0
        private void OnAppControlNative(IntPtr appControlHandle)
        {
            if (Handlers.ContainsKey(EventType.AppControlReceived))
            {
                // Create a SafeAppControlHandle but the ownsHandle is false,
                // because the appControlHandle will be closed by native appfw after this method automatically.
                SafeAppControlHandle safeHandle = new SafeAppControlHandle(appControlHandle, false);

                var handler = Handlers[EventType.AppControlReceived] as Action <AppControlReceivedEventArgs>;
                handler?.Invoke(new AppControlReceivedEventArgs(new ReceivedAppControl(safeHandle)));
            }
        }
Esempio n. 7
0
 private void OnStartCallback(IntPtr context, IntPtr appControl, bool restarted, IntPtr userData)
 {
     foreach (FrameComponent fc in Instances)
     {
         if (fc.Handle == context)
         {
             SafeAppControlHandle handle  = new SafeAppControlHandle(appControl, false);
             AppControl           control = new AppControl(handle);
             fc.OnStart(control, restarted);
             break;
         }
     }
 }
Esempio n. 8
0
        internal static void BindObject(NotificationEventArgs eventargs, int index)
        {
            string text;
            bool   isExisted = false;
            SafeAppControlHandle appcontrol = null;

            NotificationEventArgs.ButtonActionArgs button = new NotificationEventArgs.ButtonActionArgs();

            button.Index = (ButtonIndex)index;

            Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Button_1 + index, out text);
            if (string.IsNullOrEmpty(text) == false)
            {
                isExisted        = true;
                button.ImagePath = text;
            }

            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.FirstButton + index, out text);
            if (string.IsNullOrEmpty(text) == false)
            {
                isExisted   = true;
                button.Text = text;
            }

            Interop.NotificationEventListener.GetEventHandler(eventargs.Handle, index, out appcontrol);

            if (appcontrol != null && appcontrol.IsInvalid == false)
            {
                button.Action = new AppControl(appcontrol);
                isExisted     = true;
            }

            if (isExisted)
            {
                NotificationEventArgs.ActiveStyleArgs activeStyle = eventargs.Style["Active"] as NotificationEventArgs.ActiveStyleArgs;
                if (activeStyle != null)
                {
                    activeStyle.Button.Add(button);
                }
            }
        }
Esempio n. 9
0
 internal static extern ErrorCode SendLaunchRequestSync(IntPtr context, SafeAppControlHandle appControl,
                                                        SafeAppControlHandle replyControl, out int result);
Esempio n. 10
0
 internal static extern ErrorCode SendLaunchRequestAsync(IntPtr context, SafeAppControlHandle appControl,
                                                         ResultCallback resultCallback, ReplyCallback replyCallback, IntPtr userData);
Esempio n. 11
0
 internal static extern ErrorCode IsReplyRequested(SafeAppControlHandle handle, out bool requested);
Esempio n. 12
0
 internal static extern ErrorCode GetCaller(SafeAppControlHandle handle, out string caller);
Esempio n. 13
0
 internal static extern ErrorCode GetLaunchMode(SafeAppControlHandle handle, out int mode);
Esempio n. 14
0
 internal static extern ErrorCode SetAppId(SafeAppControlHandle handle, string appId);
Esempio n. 15
0
 internal static extern ErrorCode ReplyToLaunchRequest(SafeAppControlHandle reply, SafeAppControlHandle request, int result);
Esempio n. 16
0
 internal static extern ErrorCode IsExtraDataArray(SafeAppControlHandle handle, string key, out bool array);
Esempio n. 17
0
        internal static void BindSafeHandle(Notification notification)
        {
            int appList;

            Interop.Notification.GetApplist(notification.Handle, out appList);

            if ((appList & (int)NotificationDisplayApplist.Active) != 0)
            {
                Notification.ActiveStyle active = new Notification.ActiveStyle();
                bool   autoRemove;
                string path, text;
                SafeAppControlHandle appcontrol = null;
                string replyKey = "__PARENT_INDEX__";

                for (int i = (int)ButtonIndex.First; i <= (int)ButtonIndex.Third; i++)
                {
                    appcontrol = null;

                    Interop.Notification.GetImage(notification.Handle, NotificationImage.FirstButton + i, out path);
                    Interop.Notification.GetText(notification.Handle, NotificationText.FirstButton + i, out text);
                    Interop.Notification.GetEventHandler(notification.Handle, i, out appcontrol);

                    if (string.IsNullOrEmpty(path) == false || string.IsNullOrEmpty(text) == false ||
                        (appcontrol != null && appcontrol.IsInvalid == false))
                    {
                        Notification.ButtonAction button = new Notification.ButtonAction();
                        if (appcontrol != null && appcontrol.IsInvalid == false)
                        {
                            button.Action = new AppControl(appcontrol);
                        }

                        button.ImagePath = path;
                        button.Text      = text;
                        button.Index     = (ButtonIndex)i;
                        active.AddButtonAction(button);
                    }
                }

                appcontrol = null;
                Interop.Notification.GetExtensionAction(notification.Handle, NotificationEventType.HiddenByUser, out appcontrol);
                if (appcontrol != null && appcontrol.IsInvalid == false)
                {
                    active.HiddenByUserAction = new AppControl(appcontrol);
                }

                appcontrol = null;
                Interop.Notification.GetExtensionAction(notification.Handle, NotificationEventType.HiddenByTimeout, out appcontrol);
                if (appcontrol != null && appcontrol.IsInvalid == false)
                {
                    active.HiddenByTimeoutAction = new AppControl(appcontrol);
                }

                appcontrol = null;
                Interop.Notification.GetExtensionAction(notification.Handle, NotificationEventType.HiddenByExternal, out appcontrol);
                if (appcontrol != null && appcontrol.IsInvalid == false)
                {
                    active.HiddenByExternalAction = new AppControl(appcontrol);
                }

                Interop.Notification.GetAutoRemove(notification.Handle, out autoRemove);
                active.IsAutoRemove = autoRemove;
                if (autoRemove)
                {
                    int hidetime, deletetime;
                    Interop.Notification.GetHideTime(notification.Handle, out hidetime);
                    try
                    {
                        Interop.Notification.GetDeleteTime(notification.Handle, out deletetime);
                    }
                    catch (TypeLoadException)
                    {
                        // To support in API version 3.0
                        deletetime = 60;
                    }

                    active.SetRemoveTime(hidetime, deletetime);
                }

                Interop.Notification.GetImage(notification.Handle, NotificationImage.Background, out path);
                if (string.IsNullOrEmpty(path) == false)
                {
                    active.BackgroundImage = path;
                }

                int defaultIndex;
                Interop.Notification.GetDefaultButton(notification.Handle, out defaultIndex);
                active.DefaultButton = (ButtonIndex)(defaultIndex - 1);

                appcontrol = null;
                Interop.Notification.GetImage(notification.Handle, NotificationImage.TextInputButton, out path);
                Interop.Notification.GetText(notification.Handle, NotificationText.InputButton, out text);
                Interop.Notification.GetEventHandler(notification.Handle, (int)NotificationEventType.ClickOnTextInputButton, out appcontrol);

                if (string.IsNullOrEmpty(path) == false || string.IsNullOrEmpty(text) == false ||
                    (appcontrol != null && appcontrol.IsInvalid == false))
                {
                    Notification.ReplyAction  reply  = new Notification.ReplyAction();
                    Notification.ButtonAction button = new Notification.ButtonAction();
                    if (appcontrol != null && appcontrol.IsInvalid == false)
                    {
                        button.Action = new AppControl(appcontrol);
                    }

                    button.ImagePath = path;
                    button.Text      = text;
                    reply.Button     = button;

                    Interop.Notification.GetText(notification.Handle, NotificationText.PlaceHolder, out text);
                    reply.PlaceHolderText = text;

                    int holderLength;
                    Interop.Notification.GetPlaceHolderLength(notification.Handle, out holderLength);
                    reply.ReplyMax = holderLength;

                    try
                    {
                        SafeBundleHandle bundleHandle;
                        Interop.Notification.GetExtensionData(notification.Handle, replyKey, out bundleHandle);
                        Bundle bundle = new Bundle(bundleHandle);
                        reply.ParentIndex = (ButtonIndex)int.Parse(bundle.GetItem(replyKey).ToString());
                        bundle.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(Notification.LogTag, ex.ToString());
                    }

                    active.ReplyAction = reply;
                }

                notification.AddStyle(active);
            }
        }
Esempio n. 18
0
 internal static extern ErrorCode SetOperation(SafeAppControlHandle handle, string operation);
Esempio n. 19
0
 internal static extern ErrorCode DangerousClone(out SafeAppControlHandle clone, IntPtr handle);
Esempio n. 20
0
 internal static extern ErrorCode Create(out SafeAppControlHandle handle);
Esempio n. 21
0
 internal static extern ErrorCode EnableAppStartedResultEvent(SafeAppControlHandle handle);
Esempio n. 22
0
 internal static extern ErrorCode ForeachExtraData(SafeAppControlHandle handle, ExtraDataCallback callback, IntPtr userData);
Esempio n. 23
0
 internal static extern ErrorCode SendLaunchRequest(SafeAppControlHandle handle, ReplyCallback callback, IntPtr userData);
Esempio n. 24
0
 internal static extern ErrorCode SendTerminateRequest(SafeAppControlHandle handle);
Esempio n. 25
0
 internal static extern ErrorCode SetUri(SafeAppControlHandle handle, string uri);
Esempio n. 26
0
 internal static extern ErrorCode ForeachAppMatched(SafeAppControlHandle handle, AppMatchedCallback callback, IntPtr userData);
Esempio n. 27
0
        internal static void BindObject(NotificationEventArgs eventargs)
        {
            string text;
            int    max;
            bool   isExisted = false;
            SafeAppControlHandle appcontrol = null;
            Bundle bundle;

            NotificationEventArgs.ReplyActionArgs  reply  = new NotificationEventArgs.ReplyActionArgs();
            NotificationEventArgs.ButtonActionArgs button = new NotificationEventArgs.ButtonActionArgs();
            string replyKey = "__PARENT_INDEX__";

            Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.TextInputButton, out text);
            if (string.IsNullOrEmpty(text) == false)
            {
                isExisted        = true;
                button.ImagePath = text;
            }

            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.InputButton, out text);
            if (string.IsNullOrEmpty(text) == false)
            {
                isExisted   = true;
                button.Text = text;
            }

            Interop.NotificationEventListener.GetEventHandler(eventargs.Handle, (int)ClickEventType.InputButton, out appcontrol);

            if (appcontrol != null && appcontrol.IsInvalid == false)
            {
                button.Action = new AppControl(appcontrol);
                isExisted     = true;
            }

            reply.Button = button;

            Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.PlaceHolder, out text);

            if (string.IsNullOrEmpty(text) == false)
            {
                isExisted             = true;
                reply.PlaceHolderText = text;
            }

            Interop.NotificationEventListener.GetPlaceHolderLength(eventargs.Handle, out max);
            reply.ReplyMax = max;
            if (max > 0)
            {
                isExisted = true;
            }

            if (eventargs.ExtraData.TryGetValue(replyKey, out bundle))
            {
                if (bundle.Contains(replyKey))
                {
                    string parentIndex;
                    if (bundle.TryGetItem(replyKey, out parentIndex))
                    {
                        try
                        {
                            reply.ParentIndex = (ButtonIndex)int.Parse(parentIndex);
                            isExisted         = true;
                        }
                        catch (Exception ex)
                        {
                            Log.Error(LogTag, "unable to get ParentIndex " + ex.Message);
                        }
                    }
                }
            }

            if (isExisted)
            {
                NotificationEventArgs.ActiveStyleArgs activeStyle = eventargs.Style["Active"] as NotificationEventArgs.ActiveStyleArgs;
                if (activeStyle != null)
                {
                    activeStyle.Reply = reply;
                }
            }
        }
Esempio n. 28
0
 internal static extern ErrorCode SetMime(SafeAppControlHandle handle, string mime);
Esempio n. 29
0
 public static extern void FlutterDesktopNotifyAppControl(
     FlutterDesktopEngine engine,
     SafeAppControlHandle handle);
Esempio n. 30
0
 internal static extern ErrorCode SetCategory(SafeAppControlHandle handle, string category);