Exemplo n.º 1
0
        public void PPMResponseHandler(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Error)
            {
                /// Handle errors
                Log.Error(Utility.LOG_TAG, "Error in Request Permission");
                tcs.SetResult(false);
                return;
            }

            switch (e.result)
            {
            case RequestResult.AllowForever:
                /* Update UI and start accessing protected functionality */
                Log.Debug(Utility.LOG_TAG, "Response: RequestResult.AllowForever");
                tcs.SetResult(true);
                break;

            case RequestResult.DenyForever:
            case RequestResult.DenyOnce:
                /* Show a message and terminate the application */
                Log.Debug(Utility.LOG_TAG, "Response: RequestResult." + e.result.ToString());
                tcs.SetResult(false);
                break;
            }
        }
        /// <summary>
        /// Privacy Privilege Manager request response callback.
        /// </summary>
        /// <param name="sender"> Parameter about which object is invoked the current event.</param>
        /// <param name="e"> Event arguments.</param>
        private static void PpmRequestResponse(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Answer)
            {
                switch (e.result)
                {
                case RequestResult.AllowForever:
                    Console.WriteLine("User allowed usage of privilege {0} definitely", e.privilege);
                    break;

                case RequestResult.DenyForever:
                    // If privacy privilege is denied, app is terminated.
                    Console.WriteLine(" User denied usage of privilege {0} definitely", e.privilege);
                    System.Environment.Exit(1);
                    break;

                case RequestResult.DenyOnce:
                    // If privacy privilege is denied, app is terminated.
                    Console.WriteLine("User denied usage of privilege {0} this time", e.privilege);
                    System.Environment.Exit(1);
                    break;
                }

                --callbackCount;
                if (callbackCount == 0)
                {
                    // Remove Callback
                    context.ResponseFetched -= PpmRequestResponse;
                }
            }
            else
            {
                Console.WriteLine("Error occured during requesting permission for {0}", e.privilege);
            }
        }
        /// <summary>
        /// Invoked when the user responds to your app's permission request
        /// We can get the user response through it
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">RequestResponseEventArgs</param>
        public void PPMResponseHandler(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Error)
            {
                /// Handle errors
                Log.Error(Utility.LOG_TAG, "An error occurred while requesting an user permission");
                tcs.SetResult(false);
                return;
            }

            // Now, we can check if the permission is granted or not
            switch (e.result)
            {
            case RequestResult.AllowForever:
                // Permission is granted.
                // We can do this permission-related task we want to do.
                Log.Debug(Utility.LOG_TAG, "Response: RequestResult.AllowForever");
                tcs.SetResult(true);
                break;

            case RequestResult.DenyForever:
            case RequestResult.DenyOnce:
                // Functionality that depends on this permission will not be available
                Log.Debug(Utility.LOG_TAG, "Response: RequestResult." + e.result.ToString());
                tcs.SetResult(false);
                break;
            }
        }
Exemplo n.º 4
0
 ///
 /// ------------------------------------------------------------------------------------------------
 /// Name		HandleError
 ///
 /// <summary>	Checks the RequestResponseEventArgs for any error following a request completing.
 ///             The approriate message is displayed for any error found, the method returns TRUE
 ///             if there was no error.
 /// </summary>
 /// <param name="response">		The request response object.</param>
 ///
 /// <remarks>
 /// </remarks>
 /// ------------------------------------------------------------------------------------------------
 ///
 private bool HandleError(RequestResponseEventArgs response)
 {
     if (response.Error == null)
     {
         return(true);
     }
     //
     //if (Reachability.InternetConnectionStatus() == ReachabilityNetworkStatus.NotReachable)
     //    AlertView.Build("Network Error",
     //                    "It was not possible to complete the action due to a loss of network access. Please connect the device to a network and try again.").Show();
     //else if (response.AuthenticationError)
     //    AlertView.Build("Authentication Required",
     //                    "Your session has expired and you are required to re-authenticate before completing any further actions.\r\n\nWould you like to start a new session now?",
     //                    "No", new AlertView.Button("Yes", () =>
     //                    {
     //                        AppData.MainModel.CurrentUser = new SRiUser()
     //                        {
     //                            Environment = AppData.MainModel.CurrentUser.Environment,
     //                            IdoxId = AppData.MainModel.CurrentUser.IdoxId
     //                        };
     //                    })).Show();
     //else
     //    AlertView.Build("Request Error",
     //                    string.IsNullOrEmpty(response.Text) ? response.Error.Message : response.Text).Show();
     ////
     return(false);
 }
Exemplo n.º 5
0
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		Content
        /// <summary>
        /// To prepare text content for the label
        /// </summary>
        /// <param name="args"> Request Response Args.</param>
        /// <returns> String </returns>
        /// ------------------------------------------------------------------------------------------------
        ///
        public static string Content(RequestResponseEventArgs args)
        {
            StringBuilder body;

            //
            body = new StringBuilder();
            body.AppendLine(args.Details);
            body.AppendLine(GetOfficerInfo());
            body.AppendLine(GetDeviceInfo());
            //
            return(body.ToString());
        }
 // Invoked when an app user responses for the permission request
 private void Context_ResponseFetched(object sender, RequestResponseEventArgs e)
 {
     if (e.result == RequestResult.AllowForever)
     {
         // User allows an app to grant privacy privilege
         GrantedPermission = 1;
     }
     else
     {
         // User doesn't allow an app to grant privacy privilege
         GrantedPermission = 0;
     }
 }
 /// <summary>
 /// Handles privilege request response from the privacy privilege manager.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="requestResponseEventArgs">Event arguments.</param>
 private void PrivilegeManagerOnResponseFetched(object sender,
                                                RequestResponseEventArgs requestResponseEventArgs)
 {
     if (requestResponseEventArgs.cause == CallCause.Answer)
     {
         _checkPrivilegesTask.SetResult(requestResponseEventArgs.result == RequestResult.AllowForever);
     }
     else
     {
         Log.Error("HeartRateMonitor", "Error occurred during requesting permission");
         _checkPrivilegesTask.SetResult(false);
     }
 }
 // Invoked when an app user responses for the permission request
 private void Context_ResponseFetched(object sender, RequestResponseEventArgs e)
 {
     if (e.result == RequestResult.AllowForever)
     {
         // User allows an app to grant privacy privilege
         tcs.SetResult(true);
     }
     else
     {
         // User doesn't allow an app to grant privacy privilege
         tcs.SetResult(false);
     }
 }
Exemplo n.º 9
0
        /// ------------------------------------------------------------------------------------------------
        #region Public Constructor
        /// ------------------------------------------------------------------------------------------------
        ///

        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		RequestErrorPopup
        /// <summary>
        /// Constructor fires when the param type is RequestResponseEventArgs
        /// </summary>
        /// <param name="responseArgs"> Request Response Args.</param>
        /// ------------------------------------------------------------------------------------------------
        ///
        public RequestErrorPopup(RequestResponseEventArgs responseArgs)
        {
            InitializeComponent();
            m_oResponseArgs = responseArgs;
            TapGestures();
            SetContent();
            //
            EdUserInfo.Text      = UserInfoPlaceholder;
            EdUserInfo.TextColor = Styles.WindowBackgroundDark;
            this.Done           += () =>
            {
                SplitView.CenterPopupContent.DismisPopup();
                SendMail();
                SplitView.Instace().DisplayAlert("Mail Sent", "The mail has sent successfully", "Ok");
            };
        }
Exemplo n.º 10
0
        /// <summary>
        /// Handles privilege request response.
        /// </summary>
        /// <param name="sender">Event sender. Not used.</param>
        /// <param name="e">Event arguments.</param>
        private static void PrivilegeRequestResponse(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Answer)
            {
                switch (e.result)
                {
                case RequestResult.AllowForever:
                    SetPermission(e.privilege, true);
                    break;

                case RequestResult.DenyForever:
                case RequestResult.DenyOnce:
                    SetPermission(e.privilege, false);
                    break;
                }
            }

            AllPrivilegesChecked();
        }
Exemplo n.º 11
0
        private void PrivilegeResponseHandler(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Error)
            {
                return;
            }

            switch (e.result)
            {
            case RequestResult.AllowForever:
                CreateHRM();
                HRM.Start();
                break;

            case RequestResult.DenyForever:
            case RequestResult.DenyOnce:
                break;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Used to set privilege event listener and request the privilege.
        /// </summary>
        private static void PPM_RequestResponse(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Answer)
            {
                switch (e.result)
                {
                // Allow clicked case
                case RequestResult.AllowForever:
                    if (e.privilege == "http://tizen.org/privilege/calendar.read")
                    {
                        pEvent.AllowCalendarReadPrivilege();
                    }
                    else if (e.privilege == "http://tizen.org/privilege/contact.read")
                    {
                        pEvent.AllowContactReadPrivilege();
                    }
                    break;

                case RequestResult.DenyForever:
                    break;

                case RequestResult.DenyOnce:
                    break;
                }
                ;

                // Unset event listener for privilege
                PrivacyPrivilegeManager.GetResponseContext(e.privilege).TryGetTarget(out context);
                if (context != null)
                {
                    context.ResponseFetched -= PPM_RequestResponse;
                }
            }
            else
            {
                Console.WriteLine("Error occurs during requesting permission for {0}", e.privilege);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Handles privilege request response.
        /// Starts application when privilege check is complete.
        /// </summary>
        /// <param name="sender">Event sender. Not used.</param>
        /// <param name="e">Event arguments.</param>
        private void PPM_RequestResponse(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Answer)
            {
                switch (e.result)
                {
                case RequestResult.AllowForever:
                    ViewModels.ViewModelLocator.ViewModel.IsGPSAvailable = true;
                    break;

                case RequestResult.DenyForever:
                    ViewModels.ViewModelLocator.ViewModel.IsGPSAvailable = false;
                    break;

                case RequestResult.DenyOnce:
                    ViewModels.ViewModelLocator.ViewModel.IsGPSAvailable = false;
                    break;
                }
                ;

                StartApplication();
            }
        }
Exemplo n.º 14
0
        private static void PPMResponseHandler(object sender, RequestResponseEventArgs e)
        {
            if (e.cause == CallCause.Error)
            {
                /// Handle errors
                return;
            }

            switch (e.result)
            {
            case RequestResult.AllowForever:
                /// Update UI and start accessing protected functionality
                break;

            case RequestResult.DenyForever:
                /// Show a message and terminate the application
                break;

            case RequestResult.DenyOnce:
                /// Show a message with explanation
                break;
            }
        }
Exemplo n.º 15
0
        public void OnChangeNameResult(Packet packet)
        {
            int    result   = packet.ReadInt();
            string name     = packet.ReadString();
            int    IDClient = packet.ReadInt();

            if (result == 200 && !string.IsNullOrWhiteSpace(name))
            {
                PlayerChangeNameEventArgs e = new PlayerChangeNameEventArgs()
                {
                    Message     = $"Successfuly change username to {name}.",
                    MessageType = MessageType.OnChangeNameResult,
                    Packet      = packet,
                    Protocol    = Protocol.TCP,
                    RequestType = RequestType.Receive,
                    IDPlayer    = IDClient,
                    Name        = name,
                };
                client.PacketReceived(e);
            }
            else
            {
                RequestResponseEventArgs e = new RequestResponseEventArgs()
                {
                    Message       = $"Failed change username to {name}.",
                    MessageType   = MessageType.OnChangeNameResult,
                    Packet        = packet,
                    Protocol      = Protocol.TCP,
                    RequestStatus = RequestStatus.Failed,
                    RequestType   = RequestType.Receive,
                    Request       = "ChangeName",
                    Response      = "403",
                    Arguments     = new string[] { name },
                };
                client.PacketReceived(e);
            }
        }