示例#1
0
        public Task <IList <string> > GetMuteListAsync()
        {
            var tcs = new TaskCompletionSource <IList <string> >();

            Task.Run(() =>
            {
                int contextKey = XsapiCallbackContext <object, IList <string> > .CreateContext(null, tcs);

                var xsapiResult = PrivacyGetMuteList(this.pCXboxLiveContext, GetPrivacyUserListComplete, (IntPtr)contextKey, XboxLive.DefaultTaskGroupId);
                if (xsapiResult != XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    tcs.SetException(new XboxException(xsapiResult));
                }
            });
            return(tcs.Task);
        }
示例#2
0
        private void GetPrivacyUserListComplete(XSAPI_RESULT_INFO result, IntPtr xboxUserIdList, UInt32 count, IntPtr contextKey)
        {
            XsapiCallbackContext <object, IList <string> > context;

            if (XsapiCallbackContext <object, IList <string> > .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.TaskCompletionSource.SetResult(MarshalingHelpers.Utf8StringArrayToStringList(xboxUserIdList, count));
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                context.Dispose();
            }
        }
示例#3
0
        private void DeleteBlobComplete(XSAPI_RESULT_INFO result, IntPtr contextKey)
        {
            XsapiCallbackContext <object, object> context;

            if (XsapiCallbackContext <object, object> .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.TaskCompletionSource.SetResult(null);
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                context.Dispose();
            }
        }
示例#4
0
        private void CheckPermissionWithTargetUserComplete(XSAPI_RESULT_INFO result, XSAPI_PRIVACY_PERMISSION_CHECK_RESULT payload, IntPtr contextKey)
        {
            XsapiCallbackContext <object, PermissionCheckResult> context;

            if (XsapiCallbackContext <object, PermissionCheckResult> .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.TaskCompletionSource.SetResult(new PermissionCheckResult(payload));
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                context.Dispose();
            }
        }
示例#5
0
        internal void GetBlobMetadataComplete(XSAPI_RESULT_INFO result, XSAPI_TITLE_STORAGE_BLOB_METADATA_RESULT payload, IntPtr contextKey)
        {
            XsapiCallbackContext <object, TitleStorageBlobMetadataResult> context;

            if (XsapiCallbackContext <object, TitleStorageBlobMetadataResult> .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.TaskCompletionSource.SetResult(new TitleStorageBlobMetadataResult(payload, this));
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                context.Dispose();
            }
        }
示例#6
0
        private void GetQuotaComplete(XSAPI_RESULT_INFO result, XSAPI_TITLE_STORAGE_QUOTA quota, IntPtr contextKey)
        {
            XsapiCallbackContext <object, TitleStorageQuota> context;

            if (XsapiCallbackContext <object, TitleStorageQuota> .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.TaskCompletionSource.SetResult(new TitleStorageQuota(quota));
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }

                context.Dispose();
            }
        }
示例#7
0
        private void UploadBlobComplete(XSAPI_RESULT_INFO result, IntPtr pBlobMetadata, IntPtr contextKey)
        {
            XsapiCallbackContext <TitleStorageBlobMetadata, TitleStorageBlobMetadata> context;

            if (XsapiCallbackContext <TitleStorageBlobMetadata, TitleStorageBlobMetadata> .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.Context.Refresh();
                    context.TaskCompletionSource.SetResult(context.Context);
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                context.Dispose();
            }
        }
示例#8
0
        /// <summary>
        /// Gets the metadata of the next group of blobs
        /// </summary>
        /// <param name="maxItems">[Optional] The maximum number of items the result can contain.  Pass 0 to attempt retrieving all items.</param>
        /// <returns>An instance of the <see cref="TitleStorageBlobMetadataResult"/> class containing metadata of the included blobs.</returns>
        public Task <TitleStorageBlobMetadataResult> GetNextAsync(uint maxItems = 0)
        {
            var tcs = new TaskCompletionSource <TitleStorageBlobMetadataResult>();

            Task.Run(() =>
            {
                int contextKey;
                var context = XsapiCallbackContext <object, TitleStorageBlobMetadataResult> .CreateContext(null, tcs, out contextKey);

                var xsapiResult = TitleStorageBlobMetadataResultGetNext(metadataResultStruct, maxItems, titleStorageService.GetBlobMetadataComplete,
                                                                        (IntPtr)contextKey, XboxLive.DefaultTaskGroupId);

                if (xsapiResult != XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    tcs.SetException(new XboxException(xsapiResult));
                }
            });
            return(tcs.Task);
        }
示例#9
0
        /// <summary>
        /// Deletes a blob from title storage.
        /// </summary>
        /// <param name="blobMetadata">The blob metadata for the title storage blob to delete.</param>
        /// <param name="deleteOnlyIfEtagMatches">Specifies whether or not to have the delete operation check that the ETag matches before deleting the blob.</param>
        /// <returns>An empty task.</returns>
        public Task DeleteBlobAsync(TitleStorageBlobMetadata blobMetadata, bool deleteOnlyIfEtagMatches)
        {
            var tcs = new TaskCompletionSource <object>();

            Task.Run(() =>
            {
                int contextKey;
                XsapiCallbackContext <object, object> .CreateContext(this, tcs, out contextKey);

                var xsapiResult = TitleStorageDeleteBlob(this.pCXboxLiveContext, blobMetadata.metadataPtr, deleteOnlyIfEtagMatches,
                                                         DeleteBlobComplete, (IntPtr)contextKey, XboxLive.DefaultTaskGroupId);

                if (xsapiResult != XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    tcs.SetException(new XboxException(xsapiResult));
                }
            });
            return(tcs.Task);
        }
示例#10
0
        private void DownloadBlobComplete(XSAPI_RESULT_INFO result, XSAPI_TITLE_STORAGE_BLOB_RESULT blobResult, IntPtr contextKey)
        {
            XsapiCallbackContext <TitleStorageBlobMetadata, TitleStorageBlobResult> context;

            if (XsapiCallbackContext <TitleStorageBlobMetadata, TitleStorageBlobResult> .TryRemove(contextKey.ToInt32(), out context))
            {
                if (result.errorCode == XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    context.Context.Refresh();

                    byte[] buffer = new byte[blobResult.cbBlobBuffer];
                    Marshal.Copy(blobResult.blobBuffer, buffer, 0, (int)blobResult.cbBlobBuffer);

                    context.TaskCompletionSource.SetResult(new TitleStorageBlobResult(context.Context, buffer));
                }
                else
                {
                    context.TaskCompletionSource.SetException(new XboxException(result));
                }
                context.Dispose();
            }
        }
示例#11
0
        /// <summary>
        /// Gets title storage quota information for the specified service configuration and storage type.
        /// For user storage types (TrustedPlatform and Json) the request will be made for the calling user's
        /// Xbox user Id.
        /// </summary>
        /// <param name="user">The Xbox User of the title storage to enumerate. Ignored when enumerating GlobalStorage.</param>
        /// <param name="storageType">Type of the storage type</param>
        /// <returns>An instance of the <see cref="TitleStorageQuota"/> class with the amount of storage space allocated and used.</returns>
        public Task <TitleStorageQuota> GetQuotaAsync(string serviceConfigurationId, TitleStorageType storageType)
        {
            var tcs = new TaskCompletionSource <TitleStorageQuota>();

            Task.Run(() =>
            {
                var scid = MarshalingHelpers.StringToHGlobalUtf8(XboxLive.Instance.AppConfig.ServiceConfigurationId);

                int contextKey;
                var context            = XsapiCallbackContext <object, TitleStorageQuota> .CreateContext(null, tcs, out contextKey);
                context.PointersToFree = new List <IntPtr> {
                    scid
                };

                var xsapiResult = TitleStorageGetQuota(
                    this.pCXboxLiveContext, scid, storageType, GetQuotaComplete, (IntPtr)contextKey, XboxLive.DefaultTaskGroupId);

                if (xsapiResult != XSAPI_RESULT.XSAPI_RESULT_OK)
                {
                    tcs.SetException(new XboxException(xsapiResult));
                }
            });
            return(tcs.Task);
        }