From 056581f52e8064a2464bfaedf56e9fd020ecf1da Mon Sep 17 00:00:00 2001
From: hrxiang <xianghairui@126.com>
Date: Thu, 13 Jul 2023 15:46:01 +0800
Subject: [PATCH] 3.0

---
 android/build.gradle                         |  2 +-
 example/ios/Podfile.lock                     |  4 +-
 ios/Classes/Module/ConversationManager.swift |  2 +-
 ios/Classes/Module/IMManager.swift           | 95 ++++++++++++--------
 lib/src/manager/im_manager.dart              |  2 +-
 pubspec.lock                                 | 36 ++++----
 6 files changed, 80 insertions(+), 61 deletions(-)

diff --git a/android/build.gradle b/android/build.gradle
index 2d31ca3..f08c8b9 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -53,5 +53,5 @@ dependencies {
     // 本地依赖,现将aar复制到libs/io/openim/core-sdk/0.0.1/ 下,命名core-sdk-0.0.1.aar
 //    implementation 'io.openim:core-sdk:0.0.1@aar'
 //    api 'io.openim:core-sdk:2.3.5-t44@aar'
-    implementation 'io.openim:core-sdk:3.0.0-beta11@aar'
+    implementation 'io.openim:core-sdk:3.0.0-beta13@aar'
 }
\ No newline at end of file
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index 008ac40..73b1388 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -3,7 +3,7 @@ PODS:
   - flutter_openim_sdk (0.0.1):
     - Flutter
     - OpenIMSDKCore (= 3.0.0)
-  - OpenIMSDKCore (3.0.0)
+  - "OpenIMSDKCore (3.0.0+1)"
 
 DEPENDENCIES:
   - Flutter (from `Flutter`)
@@ -22,7 +22,7 @@ EXTERNAL SOURCES:
 SPEC CHECKSUMS:
   Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
   flutter_openim_sdk: 12daf3769f8bf40001970304445b6155c146b7eb
-  OpenIMSDKCore: cf4fa9f9599cc6741f7acc5ef260647f34541e87
+  OpenIMSDKCore: 2e38a5b9be23e588b5049ebd378161cf277e41a0
 
 PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d
 
diff --git a/ios/Classes/Module/ConversationManager.swift b/ios/Classes/Module/ConversationManager.swift
index 80b3754..13ff2b6 100644
--- a/ios/Classes/Module/ConversationManager.swift
+++ b/ios/Classes/Module/ConversationManager.swift
@@ -111,7 +111,7 @@ public class ConversationManager: BaseServiceManager {
     }
     
     func setConversationBurnDuration(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
-        Open_im_sdkSetConversationBurnDuration(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[int: "burnDuration"])
+        Open_im_sdkSetConversationBurnDuration(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[int32: "burnDuration"])
     }
 }
 
diff --git a/ios/Classes/Module/IMManager.swift b/ios/Classes/Module/IMManager.swift
index d70d1ac..ea8e793 100644
--- a/ios/Classes/Module/IMManager.swift
+++ b/ios/Classes/Module/IMManager.swift
@@ -11,7 +11,7 @@ public class IMMananger: BaseServiceManager {
         self["login"] = login
         self["logout"] = logout
         self["getLoginStatus"] = getLoginStatus
-        self["putFile"] = putFile
+        self["uploadFile"] = uploadFile
         self["updateFcmToken"] = updateFcmToken
         self["setAppBackgroundStatus"] = setAppBackgroundStatus
         self["networkStatusChanged"] = networkStatusChanged
@@ -22,7 +22,7 @@ public class IMMananger: BaseServiceManager {
                                                selector: #selector(applicationWillEnterForeground),
                                                name: UIApplication.willEnterForegroundNotification,
                                                object: nil)
-                
+        
         NotificationCenter.default.addObserver(self,
                                                selector: #selector(applicationDidEnterBackground),
                                                name: UIApplication.didEnterBackgroundNotification,
@@ -51,7 +51,7 @@ public class IMMananger: BaseServiceManager {
         Open_im_sdkSetAppBackgroundStatus(BaseCallback(result: { _ in
         }), UUID().uuidString, true)
     }
-
+    
     @objc
     fileprivate func applicationWillEnterForeground() {
         Open_im_sdkSetAppBackgroundStatus(BaseCallback(result: { _ in
@@ -75,8 +75,8 @@ public class IMMananger: BaseServiceManager {
         callBack(result, Open_im_sdkGetLoginStatus(methodCall[string: "operationID"]))
     }
     
-    func putFile(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
-        Open_im_sdkPutFile(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString(),PutFileListener(channel: self.channel,putID: methodCall[string: "putID"]))
+    func uploadFile(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
+        Open_im_sdkUploadFile(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString(), UploadFileListener(channel: self.channel,id: methodCall[string: "id"]))
     }
     
     func updateFcmToken(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
@@ -102,7 +102,7 @@ public class ConnListener: NSObject, Open_im_sdk_callbackOnConnListenerProtocol
     public func onConnectFailed(_ errCode: Int32, errMsg: String?) {
         CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onConnectFailed", errCode: errCode, errMsg: errMsg, data: nil)
     }
-
+    
     public func onConnectSuccess() {
         CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onConnectSuccess", errCode: nil, errMsg: nil, data: nil)
     }
@@ -120,60 +120,79 @@ public class ConnListener: NSObject, Open_im_sdk_callbackOnConnListenerProtocol
     }
 }
 
-public class PutFileListener: NSObject, Open_im_sdk_callbackPutFileCallbackProtocol {
+public class UploadFileListener: NSObject, Open_im_sdk_callbackUploadFileCallbackProtocol {
+    
     private let channel:FlutterMethodChannel
-    private let putID: String
+    private let id: String
     
-    init(channel:FlutterMethodChannel, putID: String) {
+    init(channel:FlutterMethodChannel, id: String) {
         self.channel = channel
-        self.putID = putID
+        self.id = id
+    }
+    
+    public func complete(_ size: Int64, url: String?, typ: Int32) {
+        var values: [String: Any] = [:]
+        values["id"] = id
+        values["size"] = size
+        values["url"] = url
+        values["type"] = typ
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "complete", errCode: nil, errMsg: nil, data: values)
     }
     
-    public func hashComplete(_ hash: String?, total: Int64) {
+    public func hashPartComplete(_ partsHash: String?, fileHash: String?) {
         var values: [String: Any] = [:]
-        values["putID"] = putID
-        values["hash"] = hash
-        values["total"] = total
-        CommonUtil.emitEvent(channel: channel, method: "putFileListener", type: "hashComplete", errCode: nil, errMsg: nil, data: values)
+        values["id"] = id
+        values["partHash"] = partsHash
+        values["fileHash"] = fileHash
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "hashPartComplete", errCode: nil, errMsg: nil, data: values);<#code#>
     }
     
-    public func hashProgress(_ current: Int64, total: Int64) {
+    public func hashPartProgress(_ index: Int32, size: Int64, partHash: String?) {
         var values: [String: Any] = [:]
-        values["putID"] = putID
-        values["current"] = current
-        values["total"] = total
-        CommonUtil.emitEvent(channel: channel, method: "putFileListener", type: "hashProgress", errCode: nil, errMsg: nil, data: values)
+        values["id"] = id
+        values["index"] = index
+        values["size"] = size
+        values["partHash"] = partHash
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "hashPartProgress", errCode: nil, errMsg: nil, data: values)
     }
     
     public func open(_ size: Int64) {
         var values: [String: Any] = [:]
-        values["putID"] = putID
+        values["id"] = id
         values["size"] = size
-        CommonUtil.emitEvent(channel: channel, method: "putFileListener", type: "open", errCode: nil, errMsg: nil, data: values)
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "open", errCode: nil, errMsg: nil, data: values)
+    }
+    
+    public func partSize(_ partSize: Int64, num: Int32) {
+        var values: [String: Any] = [:]
+        values["id"] = id
+        values["partSize"] = partSize
+        values["num"] = num
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "partSize", errCode: nil, errMsg: nil, data: values)
     }
     
-    public func putComplete(_ total: Int64, putType: Int) {
+    public func uploadComplete(_ fileSize: Int64, streamSize: Int64, storageSize: Int64) {
         var values: [String: Any] = [:]
-        values["putID"] = putID
-        values["putType"] = putType
-        values["total"] = total
-        CommonUtil.emitEvent(channel: channel, method: "putFileListener", type: "putComplete", errCode: nil, errMsg: nil, data: values)
+        values["id"] = id
+        values["fileSize"] = fileSize
+        values["streamSize"] = streamSize
+        values["storageSize"] = storageSize
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "uploadProgress", errCode: nil, errMsg: nil, data: values)
     }
     
-    public func putProgress(_ save: Int64, current: Int64, total: Int64) {
+    public func uploadID(_ uploadID: String?) {
         var values: [String: Any] = [:]
-        values["putID"] = putID
-        values["save"] = save
-        values["current"] = current
-        values["total"] = total
-        CommonUtil.emitEvent(channel: channel, method: "putFileListener", type: "putProgress", errCode: nil, errMsg: nil, data: values)
+        values["id"] = id
+        values["uploadID"] = uploadID
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "uploadID", errCode: nil, errMsg: nil, data: values)
     }
     
-    public func putStart(_ current: Int64, total: Int64) {
+    public func uploadPartComplete(_ index: Int32, partSize: Int64, partHash: String?) {
         var values: [String: Any] = [:]
-        values["putID"] = putID
-        values["current"] = current
-        values["total"] = total
-        CommonUtil.emitEvent(channel: channel, method: "putFileListener", type: "putStart", errCode: nil, errMsg: nil, data: values)
+        values["id"] = id
+        values["index"] = index
+        values["partSize"] = partSize
+        values["partHash"] = partHash
+        CommonUtil.emitEvent(channel: channel, method: "uploadFileListener", type: "uploadPartComplete", errCode: nil, errMsg: nil, data: values);<#code#>
     }
 }
diff --git a/lib/src/manager/im_manager.dart b/lib/src/manager/im_manager.dart
index d6c9a84..ca0077c 100644
--- a/lib/src/manager/im_manager.dart
+++ b/lib/src/manager/im_manager.dart
@@ -500,7 +500,7 @@ class IMManager {
   /// 获取当前登录用户信息
   Future<UserInfo> getLoginUserInfo() async => userInfo;
 
-  ///
+  ///[id] 跟 [OnUploadFileListener] id一致,区分是哪个文件的回调
   Future uploadFile({
     required String id,
     required String filePath,
diff --git a/pubspec.lock b/pubspec.lock
index 4ac96db..dd4cb56 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -6,7 +6,7 @@ packages:
     description:
       name: async
       sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "2.10.0"
   boolean_selector:
@@ -14,7 +14,7 @@ packages:
     description:
       name: boolean_selector
       sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "2.1.1"
   characters:
@@ -22,7 +22,7 @@ packages:
     description:
       name: characters
       sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.2.1"
   clock:
@@ -30,7 +30,7 @@ packages:
     description:
       name: clock
       sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.1.1"
   collection:
@@ -38,7 +38,7 @@ packages:
     description:
       name: collection
       sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.17.0"
   fake_async:
@@ -46,7 +46,7 @@ packages:
     description:
       name: fake_async
       sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.3.1"
   flutter:
@@ -64,7 +64,7 @@ packages:
     description:
       name: js
       sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "0.6.5"
   matcher:
@@ -72,7 +72,7 @@ packages:
     description:
       name: matcher
       sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "0.12.13"
   material_color_utilities:
@@ -80,7 +80,7 @@ packages:
     description:
       name: material_color_utilities
       sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "0.2.0"
   meta:
@@ -88,7 +88,7 @@ packages:
     description:
       name: meta
       sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.8.0"
   path:
@@ -96,7 +96,7 @@ packages:
     description:
       name: path
       sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.8.2"
   sky_engine:
@@ -109,7 +109,7 @@ packages:
     description:
       name: source_span
       sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.9.1"
   stack_trace:
@@ -117,7 +117,7 @@ packages:
     description:
       name: stack_trace
       sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.11.0"
   stream_channel:
@@ -125,7 +125,7 @@ packages:
     description:
       name: stream_channel
       sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "2.1.1"
   string_scanner:
@@ -133,7 +133,7 @@ packages:
     description:
       name: string_scanner
       sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.2.0"
   term_glyph:
@@ -141,7 +141,7 @@ packages:
     description:
       name: term_glyph
       sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "1.2.1"
   test_api:
@@ -149,7 +149,7 @@ packages:
     description:
       name: test_api
       sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "0.4.16"
   vector_math:
@@ -157,7 +157,7 @@ packages:
     description:
       name: vector_math
       sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
-      url: "https://pub.dev"
+      url: "https://pub.flutter-io.cn"
     source: hosted
     version: "2.1.4"
 sdks: