/// <summary>
        /// Open a MEGA file link providing its decryption key.
        /// </summary>
        /// <param name="api">MegaSDK object that started the request</param>
        /// <param name="request">Information about the request.</param>
        /// <param name="decryptionKey">Decryption key of the link.</param>
        private void OpenLink(MegaSDK api, MRequest request, String decryptionKey)
        {
            // Get the used link only if the request type is for login to a folder link
            // or get a public node from a file link
            if (request.getType() == MRequestType.TYPE_LOGIN ||
                request.getType() == MRequestType.TYPE_GET_PUBLIC_NODE)
            {
                _link = request.getLink();
            }

            string[] splittedLink = SplitLink(_link);

            // If the decryption key already includes the "!" character, delete it.
            if (decryptionKey.StartsWith("!"))
            {
                decryptionKey = decryptionKey.Substring(1);
            }

            string link = String.Format("{0}!{1}!{2}", splittedLink[0],
                                        splittedLink[1], decryptionKey);

            // If is a folder link
            if (splittedLink[0].EndsWith("#F"))
            {
                api.loginToFolder(link, new LoginToFolderRequestListener(_folderLinkViewModel));
            }
            else
            {
                api.getPublicNode(link, this);
            }
        }
        protected override void OnSuccesAction(MegaSDK api, MRequest request)
        {
            App.LinkInformation.ActiveLink = request.getLink();
            MNode publicNode = App.LinkInformation.PublicNode = request.getPublicMegaNode();

            if (publicNode != null)
            {
                // Save the handle of the last public node accessed (Task #10800)
                SettingsService.SaveLastPublicNodeHandle(publicNode.getHandle());

                #if WINDOWS_PHONE_80
                // Detect if is an image to allow directly download to camera albums
                bool isImage = false;
                if (publicNode.isFile())
                {
                    FileNodeViewModel node = new FileNodeViewModel(api, null, publicNode, ContainerType.PublicLink);
                    isImage = node.IsImage;
                }
                #endif

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        #if WINDOWS_PHONE_80
                        DialogService.ShowOpenLink(publicNode, _folderViewModel, isImage);
                        #elif WINDOWS_PHONE_81
                        DialogService.ShowOpenLink(publicNode, _folderViewModel);
                        #endif
                    }
                    catch (Exception e)
                    {
                        new CustomMessageDialog(
                            ErrorMessageTitle,
                            String.Format(ErrorMessage, e.Message),
                            App.AppInformation,
                            MessageDialogButtons.Ok).ShowDialog();
                    }
                });
            }
            else
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    new CustomMessageDialog(
                        ErrorMessageTitle,
                        AppMessages.AM_ImportFileFailedNoErrorCode,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                });
            }
        }
        public override void onRequestFinish(MegaSDK api, MRequest request, MError e)
        {
            base.onRequestFinish(api, request, e);

            if (Tcs.Task.IsFaulted)
            {
                return;
            }

            if (request.getType() == MRequestType.TYPE_GET_PAYMENT_ID)
            {
                switch (e.getErrorCode())
                {
                case MErrorType.API_OK:     // Successfull get payment URL process
                    Tcs?.TrySetResult(request.getLink());
                    break;

                default:     // Default error processing
                    Tcs?.TrySetResult(null);
                    break;
                }
            }
        }
        protected override void OnSuccesAction(MegaSDK api, MRequest request)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                var webBrowserTask = new WebBrowserTask();

                switch (_paymentMethodType)
                {
                case MPaymentMethod.PAYMENT_METHOD_CENTILI:
                    webBrowserTask.Uri = new Uri("https://www.centili.com/widget/WidgetModule?api=9e8eee856f4c048821954052a8d734ac&clientid=" + request.getLink());
                    break;

                case MPaymentMethod.PAYMENT_METHOD_FORTUMO:
                    webBrowserTask.Uri = new Uri("http://fortumo.com/mobile_payments/f250460ec5d97fd27e361afaa366db0f?cuid=" + request.getLink());
                    break;
                }

                webBrowserTask.Show();
            });
        }
Beispiel #5
0
 protected override void OnSuccesAction(MegaSDK api, MRequest request)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() => DialogService.ShowShareLink(request.getLink()));
 }