Ejemplo n.º 1
0
        public void Update()
        {
            if (m_data != null)
            {
                if (Time.realtimeSinceStartup - updateDelay > .1f)
                {
                    needsReload |= m_data.Update();
                }

                if (needsReload && Time.realtimeSinceStartup - lastUpdateTime > .3f)
                {
                    Reload();
                    lastUpdateTime = Time.realtimeSinceStartup;
                    needsReload    = false;
                }
            }
        }
Ejemplo n.º 2
0
        public void ExecuteAction(ActionBase action, BlockBase sourceBlock, Node sourceNode, long sourceViewID)
        {
            if (action != null)
            {
                switch (action.ActionType)
                {
                    #region UI element visibility

                case ActionType.SetVisibility:
                {
                    SetVisibilityAction sv = action as SetVisibilityAction;

                    if (sv != null)
                    {
                        BlockBase target = FindBlock(sv.BlockSignpost, sourceBlock);

                        if (target != null)
                        {
                            target.Visibility = sv.IsVisible ? Visibility.Visible : Visibility.Collapsed;
                        }
                    }

                    break;
                }

                case ActionType.ToggleVisibility:
                {
                    ToggleVisibilityAction tv = action as ToggleVisibilityAction;

                    if (tv != null)
                    {
                        BlockBase target = FindBlock(tv.BlockSignpost, sourceBlock);

                        if (target != null)
                        {
                            if (target.Visibility == Visibility.Visible)
                            {
                                target.Visibility = Visibility.Collapsed;
                            }
                            else
                            {
                                target.Visibility = Visibility.Visible;
                            }
                        }
                    }

                    break;
                }

                    #endregion

                    #region Slot management

                case ActionType.SetSlotContent:
                {
                    SetSlotContentAction ssca = action as SetSlotContentAction;

                    if (ssca != null)
                    {
                        DisplayData data = FindSignpostedData((short)ssca.Target.ID, sourceBlock.Host.ID);

                        if (data != null)
                        {
                            data.Update(ssca.Data);
                        }
                    }

                    break;
                }

                    #endregion

                    #region Telephony and contacts

                case ActionType.GetContact:
                {
                    GetContactAction gca = action as GetContactAction;

                    if (gca != null)
                    {
                        DisplayData target = FindSignpostedData(gca.TargetSignpost, sourceViewID);

                        if (target != null)
                        {
                            TelephonyHelper.ChoosePhoneNumber(
                                (sender, e) =>
                                {
                                    if ((e != null) && (target != null))
                                    {
                                        target.Data = e.Data;
                                    }

                                    //TODO: create payload message for sourceBlock
                                });
                        }
                    }

                    break;
                }

                case ActionType.TelephonySendSMSWithMessage:
                {
                    TelephonySendSMSWithMessageAction ssmswm = action as TelephonySendSMSWithMessageAction;

                    if (ssmswm != null)
                    {
                        TelephonyHelper.SendText(ssmswm.PhoneNumber, ssmswm.Message);
                    }

                    break;
                }

                case ActionType.TelephonySendSMSSSP:
                {
                    TelephonySendSMSSSPAction ssmsssp = action as TelephonySendSMSSSPAction;

                    if (ssmsssp != null)
                    {
                        DisplayData numberData  = FindSignpostedData(ssmsssp.NumberSignpost, sourceViewID);
                        DisplayData messageData = FindSignpostedData(ssmsssp.MessageSignpost, sourceViewID);
                        BlockBase   numberBlock = FindBlock(ssmsssp.NumberSignpost, sourceBlock);

                        string phoneNumber = null;
                        string message     = null;

                        if ((numberBlock != null) && !String.IsNullOrWhiteSpace(numberBlock.FormSubmissionValue))
                        {
                            phoneNumber = numberBlock.FormSubmissionValue;
                        }
                        else if ((numberData != null) && (numberData.DisplayType == DisplayType.String))
                        {
                            phoneNumber = numberData.Data as string;
                        }

                        if ((messageData != null) && (messageData.DisplayType == DisplayType.String))
                        {
                            message = messageData.Data as string;
                        }

                        TelephonyHelper.SendText(phoneNumber, message);
                    }

                    break;
                }

                    #endregion

                    #region E-mail

                case ActionType.SendEmail:
                {
                    SendMailAction sm = action as SendMailAction;

                    if (sm != null)
                    {
                        TelephonyHelper.SendEmail(sm.To, sm.Subject, sm.Body);
                    }

                    break;
                }

                case ActionType.SendEmailSSP:
                {
                    SendMailSSPAction smssp = action as SendMailSSPAction;

                    if (smssp != null)
                    {
                        TelephonyHelper.SendEmail(
                            FindSignpostedData(smssp.ToSignpost, sourceBlock),
                            FindSignpostedData(smssp.SubjectSignpost, sourceBlock),
                            FindSignpostedData(smssp.BodySignpost, sourceBlock));
                    }

                    break;
                }

                    #endregion

                    #region Media

                case ActionType.FullScreenVideo:
                    break;

                case ActionType.PlayMedia:
                {
                    PlayMediaAction pma = action as PlayMediaAction;

                    if (pma != null)
                    {
                        Core.Downloads.OpenMediaStream(pma.MediaContentReference);
                    }

                    break;
                }

                case ActionType.PlayMediaSSP:
                    break;

                case ActionType.PlayMediaWithAd:
                {
                    //TODO: add support for advertising
                    PlayMediaWithAdAction pma = action as PlayMediaWithAdAction;

                    if (pma != null)
                    {
                        Core.Downloads.OpenMediaStream(pma.MediaContentReference);
                    }

                    break;
                }

                    #endregion

                    #region Geolocation

                case ActionType.SetLocationSharing:
                {
                    SetLocationSharingAction loc = action as SetLocationSharingAction;

                    if (loc != null)
                    {
                        if (loc.Enable)
                        {
                            Core.System.Location.Start();
                        }
                        else
                        {
                            Core.System.Location.Stop();
                        }
                    }

                    break;
                }

                    #endregion

                    #region Web browsing

                case ActionType.ConnectOpenBrowser:
                {
                    OpenBrowserAction ob = action as OpenBrowserAction;

                    if (ob != null)
                    {
                        BrowserHelper.Launch(ob.URL);
                    }

                    break;
                }

                case ActionType.OpenEmbeddedBrowser:
                {
                    OpenBrowserEmbeddedAction obe = action as OpenBrowserEmbeddedAction;

                    if (obe != null)
                    {
                        BrowserHelper.LaunchEmbedded(obe.URL);
                    }

                    break;
                }

                    #endregion

                    #region Social

                case ActionType.PublishOnOnlineCommunity:
                {
                    PublishOnSocialNetworkAction posn = action as PublishOnSocialNetworkAction;

                    if (posn != null)
                    {
                        SocialHelper.PublishSocial(posn.Target, posn.MessageData);
                    }

                    break;
                }

                case ActionType.PublishOnOnlineCommunitySSP:
                {
                    PublishOnSocialNetworkSSPAction posnssp = action as PublishOnSocialNetworkSSPAction;

                    if (posnssp != null)
                    {
                        string message = FindSignpostedData(posnssp.MessageSignpost, sourceBlock);

                        if (message != null)
                        {
                            SocialHelper.PublishSocial(posnssp.Target, message);
                        }
                    }

                    break;
                }

                    #endregion

                    #region Extensibility

                case ActionType.Custom:
                {
                    CustomAction cs = action as CustomAction;

                    if ((cs != null) && (cs.Actions.Count > 0))
                    {
                        switch (cs.Actions[0])
                        {
                        case CustomActions.NativeMessageBox:
                        {
                            if (sourceNode.NativeMessageBox != null)
                            {
                                sourceNode.NativeMessageBox.Execute();
                            }

                            break;
                        }

                        case CustomActions.ClearBackstack:
                        {
                            View view = Core.UI[sourceViewID];

                            if (view != null)
                            {
                                view.ClearBackstack();
                            }

                            break;
                        }

                        case CustomActions.ActionSheet:
                        {
                            if (cs.Actions.Count > 1)
                            {
                                // cross-frame
                                if (Core.UI.HasRootView)
                                {
                                    View target = Core.UI.RootView.FindChildView(cs.Actions[1]);

                                    if ((target != null) && (target.ActionSheet != null))
                                    {
                                        target.ActionSheet.Launch();
                                    }
                                }
                            }
                            else
                            {
                                // local frame only
                                View view = Core.UI[sourceViewID];

                                if ((view != null) && (view.ActionSheet != null))
                                {
                                    view.ActionSheet.Launch();
                                }
                            }

                            break;
                        }

                        case CustomActions.EnableSimpleTileUpdates:
                        {
                            if (cs.Actions.Count > 1)
                            {
                                string url = cs.Actions[1], user = null, pass = null;

                                if (Core.Application.HasLogin)
                                {
                                    user = Core.Application.Login;
                                    pass = Core.Application.PasswordString;
                                }

                                BackgroundHelper.EnableBackgroundTask(url, user, pass);
                                BackgroundHelper.AddOrRenewBackgroundTask();
                            }

                            break;
                        }

                        case CustomActions.DisableSimpleTileUpdates:
                        {
                            BackgroundHelper.DisableBackgroundTask();
                            break;
                        }

                        case CustomActions.MessageBox:
                        {
                            if (cs.Actions.Count > 1)
                            {
                                UIHelper.Message(cs.Actions[1]);
                            }

                            break;
                        }
                        }
                    }

                    break;
                }

                    #endregion
                }
            }
        }