示例#1
0
        public PrivacyInfo GetAsPrivacyInfo()
        {
            PrivacyInfo privacyInfo = this.ReadCurrentStateIntoPrivacyInfo();

            privacyInfo.CleanupAllowedDeniedArraysBasedOnPrivacyType();
            return(privacyInfo);
        }
示例#2
0
 public void ReadFromPrivacyInfo(PrivacyInfo privacyInfo)
 {
     this._allowedDeniedCollection.Clear();
     this._inputPrivacyInfo = privacyInfo;
     this._privacyType      = privacyInfo.PrivacyType;
     this.GenerateAllowedDenied();
 }
 public void ReadFromPrivacyInfo(PrivacyInfo privacyInfo)
 {
     ((Collection <Group <FriendHeader> >) this._allowedDeniedCollection).Clear();
     this._inputPrivacyInfo = privacyInfo;
     this._privacyType      = privacyInfo.PrivacyType;
     this.GenerateAllowedDenied();
 }
 public CreateEditVideoAlbumViewModel(long albumId = 0, long groupId = 0, string name = "", PrivacyInfo pi = null)
 {
     this._albumId       = albumId;
     this._groupId       = groupId;
     this._name          = name;
     this._pi            = pi ?? new PrivacyInfo();
     this.AlbumPrivacyVM = new EditPrivacyViewModel(CommonResources.VideoCatalog_WhoCanViewThisAlbum, this._pi, "", (List <string>)null);
 }
示例#5
0
 public EditPrivacyViewModel(string title, PrivacyInfo privacyInfo, string key = "", List <string> supportedValues = null)
 {
     this.PrivacyQuestion = title;
     this.ReadFromPrivacyInfo(privacyInfo);
     this._key = key;
     if (supportedValues != null)
     {
         this._supportedValues = supportedValues;
     }
     EventAggregator.Current.Subscribe((object)this);
 }
示例#6
0
 public EditPrivacyViewModel(EditPrivacyViewModel vm, Action <PrivacyInfo> saveCallback)
 {
     this.PrivacyQuestion   = vm.PrivacyQuestion;
     this._inputPrivacyInfo = new PrivacyInfo(vm._inputPrivacyInfo.ToString());
     this._key             = vm.Key;
     this._supportedValues = vm._supportedValues;
     this._privacyType     = this._inputPrivacyInfo.PrivacyType;
     this._saveCallback    = saveCallback;
     this.GenerateAllowedDenied();
     EventAggregator.Current.Subscribe((object)this);
 }
 internal void UpdatePrivacy(EditPrivacyViewModel vm, PrivacyInfo pi)
 {
     AccountService.Instance.SetPrivacy(vm.Key, pi.ToString(), (Action <BackendResult <ResponseWithId, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() =>
     {
         if (res.ResultCode != ResultCode.Succeeded)
         {
             GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", (VKRequestsDispatcher.Error)null);
         }
         else
         {
             vm.ReadFromPrivacyInfo(pi);
         }
     }))));
 }
示例#8
0
        public void AddAlbum(string albumName, PrivacyInfo albumPrivacy, Action <BackendResult <VideoAlbum, ResultCode> > callback, long?groupId = null)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["title"] = albumName;
            if (groupId.HasValue && groupId.Value != 0L)
            {
                parameters["group_id"] = groupId.Value.ToString();
            }
            if (albumPrivacy != null)
            {
                parameters["privacy"] = albumPrivacy.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <VideoAlbum>("video.addAlbum", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
 internal void UpdatePrivacy(EditPrivacyViewModel vm, PrivacyInfo pi)
 {
     AccountService.Instance.SetPrivacy(vm.Key, pi.ToString(), delegate(BackendResult <ResponseWithId, ResultCode> res)
     {
         Execute.ExecuteOnUIThread(delegate
         {
             if (res.ResultCode != ResultCode.Succeeded)
             {
                 VKClient.Common.UC.GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", null);
                 return;
             }
             vm.ReadFromPrivacyInfo(pi);
         });
     });
 }
 protected override void HandleOnNavigatedTo(NavigationEventArgs e)
 {
   base.HandleOnNavigatedTo(e);
   if (!this._isInitialized)
   {
     this._albumId = long.Parse(((Page) this).NavigationContext.QueryString["AlbumId"]);
     this._groupId = long.Parse(((Page) this).NavigationContext.QueryString["GroupId"]);
     this._name = ((Page) this).NavigationContext.QueryString["Name"];
     this._groupId = long.Parse(((Page) this).NavigationContext.QueryString["GroupId"]);
     this._pi = ParametersRepository.GetParameterForIdAndReset("AlbumPrivacyInfo") as PrivacyInfo;
     CreateEditVideoAlbumViewModel videoAlbumViewModel = new CreateEditVideoAlbumViewModel(this._albumId, this._groupId, this._name, this._pi);
     videoAlbumViewModel.PropertyChanged += new PropertyChangedEventHandler(this.vm_PropertyChanged);
     base.DataContext = videoAlbumViewModel;
     this._isInitialized = true;
   }
   this.UpdateAppBar();
 }
示例#11
0
 private void LoadAllowedDenied()
 {
     this._inputPrivacyInfo = this.ReadCurrentStateIntoPrivacyInfo();
     this._allowedDeniedCollection.Clear();
     if (this.PrivacyType == PrivacyType.CertainUsers)
     {
         Group <FriendHeader> group = new Group <FriendHeader>("", false);
         group.Id = 0;
         this.AddListsAndUsersToGroup(group, this._inputPrivacyInfo.AllowedLists, this._inputPrivacyInfo.AllowedUsers);
         this._allowedDeniedCollection.Add(group);
     }
     if (this.DenyIsApplicable)
     {
         Group <FriendHeader> group = new Group <FriendHeader>(CommonResources.Privacy_DeniedTo, false);
         group.Id = 1;
         this.AddListsAndUsersToGroup(group, this._inputPrivacyInfo.DeniedLists, this._inputPrivacyInfo.DeniedUsers);
         this._allowedDeniedCollection.Add(group);
     }
     this.NotifyPropertyChanged <string>((System.Linq.Expressions.Expression <Func <string> >)(() => this.UserFriendlyDesc));
 }
示例#12
0
        private PrivacyInfo ReadCurrentStateIntoPrivacyInfo()
        {
            PrivacyInfo privacyInfo = new PrivacyInfo(this._inputPrivacyInfo.ToString());

            privacyInfo.PrivacyType = this.PrivacyType;
            Group <FriendHeader> source1 = this._allowedDeniedCollection.FirstOrDefault <Group <FriendHeader> >((Func <Group <FriendHeader>, bool>)(g => g.Id == 0));

            if (source1 != null)
            {
                privacyInfo.AllowedUsers = source1.Where <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.IsFriend)).Select <FriendHeader, long>((Func <FriendHeader, long>)(fh => fh.UserId)).ToList <long>();
                privacyInfo.AllowedLists = source1.Where <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.IsFriendList)).Select <FriendHeader, long>((Func <FriendHeader, long>)(fh => fh.FriendListId)).ToList <long>();
            }
            Group <FriendHeader> source2 = this._allowedDeniedCollection.FirstOrDefault <Group <FriendHeader> >((Func <Group <FriendHeader>, bool>)(g => g.Id == 1));

            if (source2 != null)
            {
                privacyInfo.DeniedUsers = source2.Where <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.IsFriend)).Select <FriendHeader, long>((Func <FriendHeader, long>)(fh => fh.UserId)).ToList <long>();
                privacyInfo.DeniedLists = source2.Where <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.IsFriendList)).Select <FriendHeader, long>((Func <FriendHeader, long>)(fh => fh.FriendListId)).ToList <long>();
            }
            return(privacyInfo);
        }
示例#13
0
        public void UploadVideo(Stream stream, bool isPrivate, long albumId, long groupId, string name, string description, Action <BackendResult <SaveVideoResponse, ResultCode> > callback, Action <double> progressCallback = null, Cancellation c = null, PrivacyInfo privacyViewInfo = null, PrivacyInfo privacyCommentInfo = null)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["is_private"] = isPrivate ? "1" : "0";
            if (groupId != 0L)
            {
                parameters["group_id"] = groupId.ToString();
            }
            if (albumId != 0L)
            {
                parameters["album_id"] = albumId.ToString();
            }
            if (!string.IsNullOrEmpty(name))
            {
                parameters["name"] = name;
            }
            if (!string.IsNullOrEmpty(description))
            {
                parameters["description"] = description;
            }
            if (privacyViewInfo != null && groupId == 0L)
            {
                parameters["privacy_view"] = privacyViewInfo.ToString();
            }
            if (privacyCommentInfo != null && groupId == 0L)
            {
                parameters["privacy_comment"] = privacyCommentInfo.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <SaveVideoResponse>("video.save", parameters, (Action <BackendResult <SaveVideoResponse, ResultCode> >)(res =>
            {
                if (res.ResultCode != ResultCode.Succeeded)
                {
                    callback(new BackendResult <SaveVideoResponse, ResultCode>(res.ResultCode));
                }
                else
                {
                    SaveVideoResponse svr = res.ResultData;
                    JsonWebRequest.Upload(svr.upload_url, stream, "video_file", "video", (Action <JsonResponseData>)(uploadRes =>
                    {
                        if (uploadRes.IsSucceeded)
                        {
                            callback(new BackendResult <SaveVideoResponse, ResultCode>(ResultCode.Succeeded, svr));
                        }
                        else
                        {
                            callback(new BackendResult <SaveVideoResponse, ResultCode>(ResultCode.UnknownError));
                        }
                    }), null, progressCallback, c);
                }
            }), null, false, true, new CancellationToken?(), null);
        }
示例#14
0
        public void EditVideo(long videoId, long ownerId, string name, string description, PrivacyInfo privacyView, PrivacyInfo privacyComment, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (ownerId != 0L)
            {
                parameters["owner_id"] = ownerId.ToString();
            }
            parameters["video_id"]        = videoId.ToString();
            parameters["name"]            = name;
            parameters["desc"]            = description;
            parameters["privacy_view"]    = privacyView.ToString();
            parameters["privacy_comment"] = privacyComment.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("video.edit", parameters, callback, null, false, true, new CancellationToken?(), null);
        }