Example #1
0
        protected void AppendMoreGoogleImages()
        {
            Profile pf = Profile.GetUser(Page.User.Identity.Name);

            // Get an update
            FetchingGooglePhotos?.Invoke(this, new EventArgs());

            if (!GooglePhotosDateToRetrieve.HasValue())
            {
                return; // nothing to do.
            }
            DateTime?lastDate = RetrievedGooglePhotosDate;

            // flush results if the requested date has changed because the "more results" link will break otherwise.
            if (lastDate != null && lastDate.HasValue && lastDate.Value.CompareTo(GooglePhotosDateToRetrieve) != 0)
            {
                RetrievedGooglePhotos = new GoogleMediaResponse();
            }

            RetrievedGooglePhotosDate = GooglePhotosDateToRetrieve;

            GoogleMediaResponse result = RetrievedGooglePhotos = GooglePhoto.AppendImagesForDate(pf, GooglePhotosDateToRetrieve, IncludeVideos, RetrievedGooglePhotos).Result;

            lnkMoreGPhotos.Visible = false;
            if (result == null || !result.mediaItems.Any())
            {
                lblGPhotoResult.Text = Resources.LocalizedText.GooglePhotosNoneFound;
                result = new GoogleMediaResponse();
            }

            rptGPhotos.DataSource = result.mediaItems;
            rptGPhotos.DataBind();
            lnkMoreGPhotos.Visible = !String.IsNullOrEmpty(result.nextPageToken);
            pnlGPResult.Visible    = RetrievedGooglePhotos.mediaItems.Any();
        }
Example #2
0
        public void HandleOAuthRedirect()
        {
            if (!String.IsNullOrEmpty(Request.Params[MFBDropbox.szParamDropboxAuth])) // redirect from Dropbox oAuth request.
            {
                CurrentUser.DropboxAccessToken = JsonConvert.SerializeObject(new MFBDropbox().ConvertToken(Request));
                CurrentUser.FCommit();

                Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=backup", Request.Path));
            }
            if (!String.IsNullOrEmpty(Request.Params[GoogleDrive.szParamGDriveAuth])) // redirect from GDrive oAuth request.
            {
                if (String.IsNullOrEmpty(util.GetStringParam(Request, "error")))
                {
                    CurrentUser.GoogleDriveAccessToken = new GoogleDrive().ConvertToken(Request);
                    CurrentUser.FCommit();
                }

                Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=backup", Request.Path));
            }
            if (!String.IsNullOrEmpty(Request.Params[GooglePhoto.szParamGPhotoAuth])) // redirect from Google Photo oAuth request
            {
                if (String.IsNullOrEmpty(util.GetStringParam(Request, "error")))
                {
                    IAuthorizationState token = new GooglePhoto().ConvertToken(Request);
                    string szTokenJSON        = JsonConvert.SerializeObject(token);
                    CurrentUser.SetPreferenceForKey(GooglePhoto.PrefKeyAuthToken, szTokenJSON);
                }
                Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=social", Request.Path));
            }
            if (!String.IsNullOrEmpty(Request.Params[OneDrive.szParam1DriveAuth])) // redirect from OneDrive oAuth request.
            {
                CurrentUser.OneDriveAccessToken = (IAuthorizationState)Session[OneDrive.TokenSessionKey];
                CurrentUser.FCommit();
                Session[OneDrive.TokenSessionKey] = null;

                Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=backup", Request.Path));
            }
        }