Skip to content

Commit

Permalink
feat(storage, windows): Add windows support (firebase#11617)
Browse files Browse the repository at this point in the history
* pigeon template setup

* make storage macOS running

* method channel implementation update

* android compilable

* android emulator upload succeed

* add more task listener

* Get event channel working

* pause iOS for now

* first windows checkin

* update message.dart async

* compilable example

* add the c++ into pubspec

* cmake changes to test the mono cpp lib

* make windows event channel working

* Implement more Storage for iOS functionality

* sdk demo ready

* make ios e2e test build

* more e2e test fix

* update with pigeon/messages.dart change

* fix the error message

* make e2e test pass (android)

* android e2e test

* make storage iOS pass e2e

* Add license header

* code format

* Update unit test, remove ones that's not work with pigeon

* add symbolic link for macos files

* make pigeon generated compatible with both iOS and macOS

* fix for analyze check

* add missing analyze fix

* more touch

* get windows pass e2e tests

* more e2e fix

* address part of review comments, majorly android ones

* format changes

* addressing the iOS feedback

* update with cleanup

* address the analyze check

* update e2e test for windows

* fix a few e2e issue

* fix the get data return value

* to address some review comments

* remove the example auto generate test

* update pigeon version

* some tweak

* add comments for a sleep timing

* format cpp and objc files

* add header comments

* remove debug output

* remove dart debug output

* more format fix

* fix the analyze

---------

Co-authored-by: Cynthia Jiang <[email protected]>
Co-authored-by: a-maurice <[email protected]>
  • Loading branch information
3 people authored and LocLt-Mobile committed Oct 29, 2023
1 parent 6fcdb42 commit f6fd619
Show file tree
Hide file tree
Showing 44 changed files with 4,567 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE "${firebase_libs}")

target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
target_link_libraries(${PLUGIN_NAME} PUBLIC flutter flutter_wrapper_plugin)

# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_core/firebase_core/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ endforeach()

set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32 rpcrt4 ole32 icu)

target_link_libraries(${PLUGIN_NAME} PRIVATE "${FIREBASE_LIBS}" "${ADDITIONAL_LIBS}")
target_link_libraries(${PLUGIN_NAME} PUBLIC "${FIREBASE_LIBS}" "${ADDITIONAL_LIBS}")

target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
target_link_libraries(${PLUGIN_NAME} PUBLIC flutter flutter_wrapper_plugin)

# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Autogenerated from Pigeon (v9.2.5), do not edit directly.
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package io.flutter.plugins.firebase.storage;
Expand Down Expand Up @@ -812,7 +812,7 @@ static void setup(
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.getReferencebyPath",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.getReferencebyPath",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -845,7 +845,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.setMaxOperationRetryTime",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.setMaxOperationRetryTime",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -878,7 +878,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.setMaxUploadRetryTime",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.setMaxUploadRetryTime",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -911,7 +911,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.setMaxDownloadRetryTime",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.setMaxDownloadRetryTime",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -944,7 +944,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.useStorageEmulator",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.useStorageEmulator",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -981,7 +981,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceDelete",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceDelete",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1013,7 +1013,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceGetDownloadURL",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceGetDownloadURL",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1045,7 +1045,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceGetMetaData",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceGetMetaData",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1077,7 +1077,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceList",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceList",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1110,7 +1110,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceListAll",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceListAll",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1142,7 +1142,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceGetData",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceGetData",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1179,7 +1179,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referencePutData",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referencePutData",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1220,7 +1220,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referencePutString",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referencePutString",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1263,7 +1263,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referencePutFile",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referencePutFile",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1304,7 +1304,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceDownloadFile",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceDownloadFile",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1343,7 +1343,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.referenceUpdateMetadata",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.referenceUpdateMetadata",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1375,7 +1375,9 @@ public void error(Throwable error) {
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.FirebaseStorageHostApi.taskPause", getCodec());
binaryMessenger,
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.taskPause",
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
Expand Down Expand Up @@ -1407,7 +1409,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.taskResume",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.taskResume",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down Expand Up @@ -1440,7 +1442,7 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FirebaseStorageHostApi.taskCancel",
"dev.flutter.pigeon.firebase_storage_platform_interface.FirebaseStorageHostApi.taskCancel",
getCodec());
if (api != null) {
channel.setMessageHandler(
Expand Down
44 changes: 44 additions & 0 deletions packages/firebase_storage/firebase_storage/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
30 changes: 30 additions & 0 deletions packages/firebase_storage/firebase_storage/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "2e05371c88da377d72bb1de95dcd25b4cbe3fe1a"
channel: "master"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 2e05371c88da377d72bb1de95dcd25b4cbe3fe1a
base_revision: 2e05371c88da377d72bb1de95dcd25b4cbe3fe1a
- platform: windows
create_revision: 2e05371c88da377d72bb1de95dcd25b4cbe3fe1a
base_revision: 2e05371c88da377d72bb1de95dcd25b4cbe3fe1a

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class DefaultFirebaseOptions {
return ios;
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
return android;
}

throw UnsupportedError(
Expand Down
39 changes: 33 additions & 6 deletions packages/firebase_storage/firebase_storage/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ Future<void> main() async {
options: DefaultFirebaseOptions.currentPlatform,
);

final emulatorHost =
(!kIsWeb && defaultTargetPlatform == TargetPlatform.android)
? '10.0.2.2'
: 'localhost';

await FirebaseStorage.instance.useStorageEmulator(emulatorHost, 9199);
if (defaultTargetPlatform != TargetPlatform.windows) {
// window currently don't support storage emulator
final emulatorHost =
(!kIsWeb && defaultTargetPlatform == TargetPlatform.android)
? '10.0.2.2'
: 'localhost';

await FirebaseStorage.instance.useStorageEmulator(emulatorHost, 9199);
}

runApp(StorageExampleApp());
}
Expand Down Expand Up @@ -206,6 +209,18 @@ class _TaskManager extends State<TaskManager> {
);
}

Future<void> _delete(Reference ref) async {
await ref.delete();

ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Success!\n deleted ${ref.name} \n from bucket: ${ref.bucket}\n '
'at path: ${ref.fullPath} \n'),
),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -253,6 +268,9 @@ class _TaskManager extends State<TaskManager> {
return _downloadFile(_uploadTasks[index].snapshot.ref);
}
},
onDelete: () async {
return _delete(_uploadTasks[index].snapshot.ref);
},
),
),
);
Expand All @@ -268,6 +286,7 @@ class UploadTaskListTile extends StatelessWidget {
required this.onDismissed,
required this.onDownload,
required this.onDownloadLink,
required this.onDelete,
}) : super(key: key);

/// The [UploadTask].
Expand All @@ -282,6 +301,9 @@ class UploadTaskListTile extends StatelessWidget {
/// Triggered when the user presses the "link" button on a completed upload task.
final VoidCallback /*!*/ onDownloadLink;

/// Triggered when the user presses the "delete" button on a completed upload task.
final VoidCallback /*!*/ onDelete;

/// Displays the current transferred bytes of the task.
String _bytesTransferred(TaskSnapshot snapshot) {
return '${snapshot.bytesTransferred}/${snapshot.totalBytes}';
Expand Down Expand Up @@ -347,6 +369,11 @@ class UploadTaskListTile extends StatelessWidget {
icon: const Icon(Icons.link),
onPressed: onDownloadLink,
),
if (state == TaskState.success)
IconButton(
icon: const Icon(Icons.delete),
onPressed: onDelete,
),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
flutter/ephemeral/

# Visual Studio user-specific files.
*.suo
*.user
*.userosscache
*.sln.docstates

# Visual Studio build-related files.
x64/
x86/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
Loading

0 comments on commit f6fd619

Please sign in to comment.