diff --git a/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets b/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets index d4d5f4373a0ff8f246dc14a7ec1b218e87eaedbf..720ba968898381712d4644b87e868bd62137bb65 100644 --- a/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets +++ b/interfaces/kits/js/ani/file_cloud_sync/ets/@ohos.file.cloudSync.ets @@ -71,11 +71,13 @@ export default namespace cloudSync { native on(evt: string, callback: GallerySyncCallback): void; - native off(evt: string, callback: GallerySyncCallback): void; + native offWithEvtCallback(evt: string, callback: GallerySyncCallback): void; - native off(evt: string): void; + native offWithEvt(evt: string): void; + + overload off { offWithEvtCallback, offWithEvt }; - start(): Promise { + startReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): int => this.StartInner()); @@ -87,7 +89,7 @@ export default namespace cloudSync { }); } - start(callback: AsyncCallback): void { + startWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StartInner()); promise.then((): void => { let e = new BusinessError(); @@ -98,7 +100,9 @@ export default namespace cloudSync { }); } - stop(): Promise { + overload start { startReturnsPromise, startWithCallback } + + stopReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): int => this.StopInner()); @@ -110,7 +114,7 @@ export default namespace cloudSync { }); } - stop(callback: AsyncCallback): void { + stopWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StopInner()); promise.then((): void => { let e = new BusinessError(); @@ -121,6 +125,8 @@ export default namespace cloudSync { }); } + overload stop { stopReturnsPromise, stopWithCallback } + native GallerySyncStart(): void; native GallerySyncStop(): void; @@ -200,11 +206,13 @@ export default namespace cloudSync { native on(evt: string, callback: DownloadcCallback): void; - native off(evt: string, callback: DownloadcCallback): void; + native offWithEvtCallback(evt: string, callback: DownloadcCallback): void; - native off(evt: string): void; + native offWithEvt(evt: string): void; + + overload off { offWithEvtCallback, offWithEvt }; - start(uri: string): Promise { + startWithUriReturnsPromise(uri: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); @@ -216,7 +224,7 @@ export default namespace cloudSync { }); } - start(uri: string, callback: AsyncCallback): void { + startWithUriCallback(uri: string, callback: AsyncCallback): void { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); promise.then((): void => { let e = new BusinessError(); @@ -227,7 +235,9 @@ export default namespace cloudSync { }); } - stop(uri: string): Promise { + overload start { startWithUriReturnsPromise, startWithUriCallback } + + stopWithUriReturnsPromise(uri: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((uri: string): int => this.StopInner(uri), uri); @@ -239,7 +249,7 @@ export default namespace cloudSync { }); } - stop(uri: string, callback: AsyncCallback): void { + stopWithUriCallback(uri: string, callback: AsyncCallback): void { let promise = taskpool.execute((uri: string): int => this.StopInner(uri), uri); promise.then((): void => { let e = new BusinessError(); @@ -250,6 +260,8 @@ export default namespace cloudSync { }); } + overload stop { stopWithUriReturnsPromise, stopWithUriCallback } + native DownloadStart(uri: string): void; native DownloadStop(uri: string): void; @@ -307,7 +319,8 @@ export default namespace cloudSync { } private nativePtr: long = 0; native constructor(); - native constructor(bundleName: string); + native constructor fromString(bundleName: string); + overload constructor { fromString }; bindNativePtr(ptr: long): void { if (this.nativePtr == 0) { @@ -321,7 +334,7 @@ export default namespace cloudSync { native off(evt: string): void; - start(): Promise { + startReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): int => this.StartInner()); @@ -333,7 +346,7 @@ export default namespace cloudSync { }); } - start(callback: AsyncCallback): void { + startWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StartInner()); promise.then((): void => { let e = new BusinessError(); @@ -344,7 +357,9 @@ export default namespace cloudSync { }); } - stop(): Promise { + overload start { startReturnsPromise, startWithCallback } + + stopReturnsPromise(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): int => this.StopInner()); @@ -356,7 +371,7 @@ export default namespace cloudSync { }); } - stop(callback: AsyncCallback): void { + stopWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): int => this.StopInner()); promise.then((): void => { let e = new BusinessError(); @@ -367,7 +382,9 @@ export default namespace cloudSync { }); } - getLastSyncTime(): Promise { + overload stop { stopReturnsPromise, stopWithCallback } + + getLastSyncTimeReturnsPromise(): Promise { return new Promise((resolve: (result: long) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((): long => this.GallerySyncGetLastSyncTime()); @@ -379,7 +396,7 @@ export default namespace cloudSync { }); } - getLastSyncTime(callback: AsyncCallback): void { + getLastSyncTimeWithCallback(callback: AsyncCallback): void { let promise = taskpool.execute((): long => this.GallerySyncGetLastSyncTime()); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -391,6 +408,8 @@ export default namespace cloudSync { }); } + overload getLastSyncTime { getLastSyncTimeReturnsPromise, getLastSyncTimeWithCallback } + native FileSyncStart(): void; native FileSyncStop(): void; native GallerySyncGetLastSyncTime(): long; @@ -424,7 +443,7 @@ export default namespace cloudSync { native off(evt: string): void; - start(uri: string): Promise { + startWithUriReturnsPromise(uri: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); @@ -436,7 +455,7 @@ export default namespace cloudSync { }); } - start(uri: string, callback: AsyncCallback): void { + startWithUriCallback(uri: string, callback: AsyncCallback): void { let promise = taskpool.execute((uri: string): int => this.StartInner(uri), uri); promise.then((): void => { let e = new BusinessError(); @@ -447,7 +466,9 @@ export default namespace cloudSync { }); } - stop(uri: string, needClean?: boolean): Promise { + overload start { startWithUriReturnsPromise, startWithUriCallback } + + stopWithUriNeedCleanReturnsPromise(uri: string, needClean?: boolean): Promise { let clean: boolean = false; if (needClean !== undefined) { clean = needClean; @@ -465,7 +486,7 @@ export default namespace cloudSync { }); } - stop(uri: string, callback: AsyncCallback): void { + stopWithUriCallback(uri: string, callback: AsyncCallback): void { let clean: boolean = false; let promise = taskpool.execute((uri: string, clean: boolean): int => { return this.StopInner(uri, clean); @@ -479,6 +500,8 @@ export default namespace cloudSync { }); } + overload stop { stopWithUriNeedCleanReturnsPromise, stopWithUriCallback } + native CloudFileCacheStart(uri: string): void; native CloudFileCacheStop(uri: string, clean: boolean): void; native cleanCache(uri: string): void; @@ -561,7 +584,7 @@ export default namespace cloudSync { return promise; } - export function getFileSyncState(uri: Array): Promise> { + export function getFileSyncStateReturnsPromise(uri: Array): Promise> { let promise = new Promise>((resolve, reject) => { let promises = uri.map((v: string): Promise => {return getPromiseFileSyncState(v)}); Promise.all(promises).then((re: Array): void => { @@ -576,7 +599,7 @@ export default namespace cloudSync { return promise; } - export function getFileSyncState(uri: Array, callback: AsyncCallback>): void { + export function getFileSyncStateWithCallback(uri: Array, callback: AsyncCallback>): void { let promises = uri.map((v: string): Promise => {return getPromiseFileSyncState(v)}); Promise.all(promises).then((re: Array): void => { let res: Array = re.map((result: int) => { @@ -591,11 +614,13 @@ export default namespace cloudSync { }); } - export function getFileSyncState(uri: string): FileSyncState { + export function getFileSyncStateWithUri(uri: string): FileSyncState { let res: int = StaticFunction.getFileSyncStateInner(uri); return res as FileSyncState; } + export overload getFileSyncState { getFileSyncStateReturnsPromise, getFileSyncStateWithCallback, getFileSyncStateWithUri } + export function registerChange(uri: string, recursion: boolean, callback: Callback): void { StaticFunction.registerChangeInner(uri, recursion, callback); }