18 changed files with 351 additions and 65 deletions
			
			
		@ -1,12 +1,23 @@
					 | 
				
			||||
cmake_minimum_required(VERSION 3.10) | 
				
			||||
 | 
				
			||||
set(PLUGIN_NAME xdga_directories) | 
				
			||||
project(${PLUGIN_NAME} LANGUAGES CXX) | 
				
			||||
set(PROJECT_NAME path_provider_aurora) | 
				
			||||
set(PLUGIN_NAME  path_provider_aurora_platform_plugin) | 
				
			||||
 | 
				
			||||
project(${PROJECT_NAME} LANGUAGES CXX) | 
				
			||||
 | 
				
			||||
set(CMAKE_CXX_STANDARD 17) | 
				
			||||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | 
				
			||||
 | 
				
			||||
set(CMAKE_CXX_FLAGS "-Wall -Wextra") | 
				
			||||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi") | 
				
			||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3") | 
				
			||||
 | 
				
			||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_CURRENT_BINARY_DIR}/shared) | 
				
			||||
find_package(PkgConfig REQUIRED) | 
				
			||||
pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) | 
				
			||||
 | 
				
			||||
add_library(${PLUGIN_NAME} SHARED path_provider_aurora_plugin.cpp) | 
				
			||||
 | 
				
			||||
set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) | 
				
			||||
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder) | 
				
			||||
 | 
				
			||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | 
				
			||||
target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL) | 
				
			||||
					 | 
				
			||||
@ -0,0 +1,24 @@
					 | 
				
			||||
#ifndef FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H | 
				
			||||
#define FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H | 
				
			||||
 | 
				
			||||
#include <flutter/plugin-interface.h> | 
				
			||||
 | 
				
			||||
#ifdef PLUGIN_IMPL | 
				
			||||
#define PLUGIN_EXPORT __attribute__((visibility("default"))) | 
				
			||||
#else | 
				
			||||
#define PLUGIN_EXPORT | 
				
			||||
#endif | 
				
			||||
 | 
				
			||||
class PLUGIN_EXPORT PathProviderAuroraPlugin final : public PluginInterface | 
				
			||||
{ | 
				
			||||
public: | 
				
			||||
    void RegisterWithRegistrar(PluginRegistrar ®istrar) override; | 
				
			||||
 | 
				
			||||
private: | 
				
			||||
    void onMethodCall(const MethodCall &call); | 
				
			||||
    void onGetApplicationOrg(const MethodCall &call); | 
				
			||||
    void onGetApplicationName(const MethodCall &call); | 
				
			||||
    void unimplemented(const MethodCall &call); | 
				
			||||
}; | 
				
			||||
 | 
				
			||||
#endif /* FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H */ | 
				
			||||
@ -0,0 +1,44 @@
					 | 
				
			||||
#include <path_provider_aurora/path_provider_aurora_plugin.h> | 
				
			||||
#include <flutter/method-channel.h> | 
				
			||||
#include <flutter/application.h> | 
				
			||||
#include <sys/utsname.h> | 
				
			||||
 | 
				
			||||
void PathProviderAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) | 
				
			||||
{ | 
				
			||||
    registrar.RegisterMethodChannel("path_provider_aurora", | 
				
			||||
                                    MethodCodecType::Standard, | 
				
			||||
                                    [this](const MethodCall &call) { this->onMethodCall(call); }); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
void PathProviderAuroraPlugin::onMethodCall(const MethodCall &call) | 
				
			||||
{ | 
				
			||||
    const auto &method = call.GetMethod(); | 
				
			||||
 | 
				
			||||
    if (method == "getApplicationOrg") { | 
				
			||||
        onGetApplicationOrg(call); | 
				
			||||
        return; | 
				
			||||
    } | 
				
			||||
    else if (method == "getApplicationName") { | 
				
			||||
        onGetApplicationName(call); | 
				
			||||
        return; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    unimplemented(call); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
void PathProviderAuroraPlugin::onGetApplicationOrg(const MethodCall &call) | 
				
			||||
{ | 
				
			||||
    const auto [orgname, appname] = Application::GetID(); | 
				
			||||
    call.SendSuccessResponse(orgname); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
void PathProviderAuroraPlugin::onGetApplicationName(const MethodCall &call) | 
				
			||||
{ | 
				
			||||
    const auto [orgname, appname] = Application::GetID(); | 
				
			||||
    call.SendSuccessResponse(appname); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
void PathProviderAuroraPlugin::unimplemented(const MethodCall &call) | 
				
			||||
{ | 
				
			||||
    call.SendSuccessResponse(nullptr); | 
				
			||||
} | 
				
			||||
@ -1,23 +1,85 @@
					 | 
				
			||||
name: path_provider_aurora_example | 
				
			||||
description: Demonstrates how to use the path_provider_aurora plugin. | 
				
			||||
 | 
				
			||||
publish_to: 'none' | 
				
			||||
# The following line prevents the package from being accidentally published to | 
				
			||||
# pub.dev using `flutter pub publish`. This is preferred for private packages. | 
				
			||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev | 
				
			||||
 | 
				
			||||
environment: | 
				
			||||
  sdk: '>=2.18.6 <3.0.0' | 
				
			||||
 | 
				
			||||
# Dependencies specify other packages that your package needs in order to work. | 
				
			||||
# To automatically upgrade your package dependencies to the latest versions | 
				
			||||
# consider running `flutter pub upgrade --major-versions`. Alternatively, | 
				
			||||
# dependencies can be manually updated by changing the version numbers below to | 
				
			||||
# the latest version available on pub.dev. To see which dependencies have newer | 
				
			||||
# versions available, run `flutter pub outdated`. | 
				
			||||
dependencies: | 
				
			||||
  flutter: | 
				
			||||
    sdk: flutter | 
				
			||||
 | 
				
			||||
  path_provider: ^2.0.7 | 
				
			||||
  path_provider_aurora: | 
				
			||||
    # When depending on this package from a real application you should use: | 
				
			||||
    #   path_provider_aurora: ^x.y.z | 
				
			||||
    # See https://dart.dev/tools/pub/dependencies#version-constraints | 
				
			||||
    # The example app is bundled with the plugin so we use a path dependency on | 
				
			||||
    # the parent directory to use the current plugin's version. | 
				
			||||
    path: ../ | 
				
			||||
 | 
				
			||||
  # The following adds the Cupertino Icons font to your application. | 
				
			||||
  # Use with the CupertinoIcons class for iOS style icons. | 
				
			||||
  cupertino_icons: ^1.0.2 | 
				
			||||
 | 
				
			||||
dev_dependencies: | 
				
			||||
  flutter_test: | 
				
			||||
    sdk: flutter | 
				
			||||
 | 
				
			||||
  # The "flutter_lints" package below contains a set of recommended lints to | 
				
			||||
  # encourage good coding practices. The lint set provided by the package is | 
				
			||||
  # activated in the `analysis_options.yaml` file located at the root of your | 
				
			||||
  # package. See that file for information about deactivating specific lint | 
				
			||||
  # rules and activating additional ones. | 
				
			||||
  flutter_lints: ^2.0.0 | 
				
			||||
 | 
				
			||||
# For information on the generic Dart part of this file, see the | 
				
			||||
# following page: https://dart.dev/tools/pub/pubspec | 
				
			||||
 | 
				
			||||
# The following section is specific to Flutter packages. | 
				
			||||
flutter: | 
				
			||||
  uses-material-design: true | 
				
			||||
 | 
				
			||||
  # The following line ensures that the Material Icons font is | 
				
			||||
  # included with your application, so that you can use the icons in | 
				
			||||
  # the material Icons class. | 
				
			||||
  uses-material-design: true | 
				
			||||
 | 
				
			||||
  # To add assets to your application, add an assets section, like this: | 
				
			||||
  # assets: | 
				
			||||
  #   - images/a_dot_burr.jpeg | 
				
			||||
  #   - images/a_dot_ham.jpeg | 
				
			||||
 | 
				
			||||
  # An image asset can refer to one or more resolution-specific "variants", see | 
				
			||||
  # https://flutter.dev/assets-and-images/#resolution-aware | 
				
			||||
 | 
				
			||||
  # For details regarding adding assets from package dependencies, see | 
				
			||||
  # https://flutter.dev/assets-and-images/#from-packages | 
				
			||||
 | 
				
			||||
  # To add custom fonts to your application, add a fonts section here, | 
				
			||||
  # in this "flutter" section. Each entry in this list should have a | 
				
			||||
  # "family" key with the font family name, and a "fonts" key with a | 
				
			||||
  # list giving the asset and other descriptors for the font. For | 
				
			||||
  # example: | 
				
			||||
  # fonts: | 
				
			||||
  #   - family: Schyler | 
				
			||||
  #     fonts: | 
				
			||||
  #       - asset: fonts/Schyler-Regular.ttf | 
				
			||||
  #       - asset: fonts/Schyler-Italic.ttf | 
				
			||||
  #         style: italic | 
				
			||||
  #   - family: Trajan Pro | 
				
			||||
  #     fonts: | 
				
			||||
  #       - asset: fonts/TrajanPro.ttf | 
				
			||||
  #       - asset: fonts/TrajanPro_Bold.ttf | 
				
			||||
  #         weight: 700 | 
				
			||||
  # | 
				
			||||
  # For details regarding fonts from package dependencies, | 
				
			||||
  # see https://flutter.dev/custom-fonts/#from-packages | 
				
			||||
					 | 
				
			||||
@ -0,0 +1,21 @@
					 | 
				
			||||
import 'package:flutter/foundation.dart'; | 
				
			||||
import 'package:flutter/services.dart'; | 
				
			||||
 | 
				
			||||
import 'path_provider_aurora_platform_interface.dart'; | 
				
			||||
 | 
				
			||||
/// An implementation of [PathProviderAuroraPlatform] that uses method channels. | 
				
			||||
class MethodChannelPathProviderAurora extends PathProviderAuroraPlatform { | 
				
			||||
  /// The method channel used to interact with the native platform. | 
				
			||||
  @visibleForTesting | 
				
			||||
  final methodChannel = const MethodChannel('path_provider_aurora'); | 
				
			||||
 | 
				
			||||
  @override | 
				
			||||
  Future<String?> getApplicationOrg() async { | 
				
			||||
    return await methodChannel.invokeMethod<String>('getApplicationOrg'); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  @override | 
				
			||||
  Future<String?> getApplicationName() async { | 
				
			||||
    return await methodChannel.invokeMethod<String>('getApplicationName'); | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,33 @@
					 | 
				
			||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; | 
				
			||||
 | 
				
			||||
import 'path_provider_aurora_method_channel.dart'; | 
				
			||||
 | 
				
			||||
abstract class PathProviderAuroraPlatform extends PlatformInterface { | 
				
			||||
  /// Constructs a PathProviderAuroraPlatform. | 
				
			||||
  PathProviderAuroraPlatform() : super(token: _token); | 
				
			||||
 | 
				
			||||
  static final Object _token = Object(); | 
				
			||||
 | 
				
			||||
  static PathProviderAuroraPlatform _instance = MethodChannelPathProviderAurora(); | 
				
			||||
 | 
				
			||||
  /// The default instance of [PathProviderAuroraPlatform] to use. | 
				
			||||
  /// | 
				
			||||
  /// Defaults to [MethodChannelPathProviderAurora]. | 
				
			||||
  static PathProviderAuroraPlatform get instance => _instance; | 
				
			||||
 | 
				
			||||
  /// Platform-specific implementations should set this with their own | 
				
			||||
  /// platform-specific class that extends [PathProviderAuroraPlatform] when | 
				
			||||
  /// they register themselves. | 
				
			||||
  static set instance(PathProviderAuroraPlatform instance) { | 
				
			||||
    PlatformInterface.verifyToken(instance, _token); | 
				
			||||
    _instance = instance; | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  Future<String?> getApplicationOrg() { | 
				
			||||
    throw UnimplementedError('getApplicationOrg() has not been implemented.'); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  Future<String?> getApplicationName() { | 
				
			||||
    throw UnimplementedError('getApplicationName() has not been implemented.'); | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
@ -1,24 +1,34 @@
					 | 
				
			||||
// import 'package:flutter/services.dart'; | 
				
			||||
// import 'package:flutter_test/flutter_test.dart'; | 
				
			||||
// import 'package:path_provider_aurora/path_provider_aurora_method_channel.dart'; | 
				
			||||
// | 
				
			||||
// void main() { | 
				
			||||
//   MethodChannelPathProviderAurora platform = MethodChannelPathProviderAurora(); | 
				
			||||
//   const MethodChannel channel = MethodChannel('path_provider_aurora'); | 
				
			||||
// | 
				
			||||
//   TestWidgetsFlutterBinding.ensureInitialized(); | 
				
			||||
// | 
				
			||||
//   setUp(() { | 
				
			||||
//     channel.setMockMethodCallHandler((MethodCall methodCall) async { | 
				
			||||
//       return '42'; | 
				
			||||
//     }); | 
				
			||||
//   }); | 
				
			||||
// | 
				
			||||
//   tearDown(() { | 
				
			||||
//     channel.setMockMethodCallHandler(null); | 
				
			||||
//   }); | 
				
			||||
// | 
				
			||||
//   test('getPlatformVersion', () async { | 
				
			||||
//     expect(await platform.getPlatformVersion(), '42'); | 
				
			||||
//   }); | 
				
			||||
// } | 
				
			||||
import 'package:flutter/services.dart'; | 
				
			||||
import 'package:flutter_test/flutter_test.dart'; | 
				
			||||
import 'package:path_provider_aurora/path_provider_aurora_method_channel.dart'; | 
				
			||||
 | 
				
			||||
void main() { | 
				
			||||
  MethodChannelPathProviderAurora platform = MethodChannelPathProviderAurora(); | 
				
			||||
  const MethodChannel channel = MethodChannel('path_provider_aurora'); | 
				
			||||
 | 
				
			||||
  TestWidgetsFlutterBinding.ensureInitialized(); | 
				
			||||
 | 
				
			||||
  setUp(() { | 
				
			||||
    channel.setMockMethodCallHandler((MethodCall methodCall) async { | 
				
			||||
      switch (methodCall.method) { | 
				
			||||
        case 'getApplicationOrg': | 
				
			||||
          return 'com.example'; | 
				
			||||
        case 'getApplicationName': | 
				
			||||
          return 'path_provider_aurora'; | 
				
			||||
      } | 
				
			||||
      return ''; | 
				
			||||
    }); | 
				
			||||
  }); | 
				
			||||
 | 
				
			||||
  tearDown(() { | 
				
			||||
    channel.setMockMethodCallHandler(null); | 
				
			||||
  }); | 
				
			||||
 | 
				
			||||
  test('onGetApplicationOrg', () async { | 
				
			||||
    expect(await platform.getApplicationOrg(), 'com.example'); | 
				
			||||
  }); | 
				
			||||
 | 
				
			||||
  test('onGetApplicationName', () async { | 
				
			||||
    expect(await platform.getApplicationName(), 'path_provider_aurora'); | 
				
			||||
  }); | 
				
			||||
} | 
				
			||||
					 | 
				
			||||
@ -1,21 +1,36 @@
					 | 
				
			||||
// import 'package:flutter_test/flutter_test.dart'; | 
				
			||||
// import 'package:path_provider_aurora/path_provider_aurora.dart'; | 
				
			||||
// import 'package:path_provider_aurora/path_provider_aurora_platform_interface.dart'; | 
				
			||||
// import 'package:path_provider_aurora/path_provider_aurora_method_channel.dart'; | 
				
			||||
// import 'package:plugin_platform_interface/plugin_platform_interface.dart'; | 
				
			||||
// | 
				
			||||
// class MockPathProviderAuroraPlatform | 
				
			||||
//     with MockPlatformInterfaceMixin | 
				
			||||
//     implements PathProviderAuroraPlatform { | 
				
			||||
// | 
				
			||||
//   @override | 
				
			||||
//   Future<String?> getPlatformVersion() => Future.value('42'); | 
				
			||||
// } | 
				
			||||
// | 
				
			||||
// void main() { | 
				
			||||
//   final PathProviderAuroraPlatform initialPlatform = PathProviderAuroraPlatform.instance; | 
				
			||||
// | 
				
			||||
//   test('$MethodChannelPathProviderAurora is the default instance', () { | 
				
			||||
//     expect(initialPlatform, isInstanceOf<MethodChannelPathProviderAurora>()); | 
				
			||||
//   }); | 
				
			||||
// } | 
				
			||||
import 'package:flutter_test/flutter_test.dart'; | 
				
			||||
import 'package:path_provider_aurora/path_provider_aurora.dart'; | 
				
			||||
import 'package:path_provider_aurora/path_provider_aurora_platform_interface.dart'; | 
				
			||||
import 'package:path_provider_aurora/path_provider_aurora_method_channel.dart'; | 
				
			||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; | 
				
			||||
 | 
				
			||||
class MockPathProviderAuroraPlatform | 
				
			||||
    with MockPlatformInterfaceMixin | 
				
			||||
    implements PathProviderAuroraPlatform { | 
				
			||||
 | 
				
			||||
  @override | 
				
			||||
  Future<String?> getApplicationName() { | 
				
			||||
    return Future.value('path_provider_aurora'); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  @override | 
				
			||||
  Future<String?> getApplicationOrg() { | 
				
			||||
    return Future.value('com.example'); | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
 | 
				
			||||
void main() { | 
				
			||||
  final PathProviderAuroraPlatform initialPlatform = PathProviderAuroraPlatform.instance; | 
				
			||||
 | 
				
			||||
  test('$MethodChannelPathProviderAurora is the default instance', () { | 
				
			||||
    expect(initialPlatform, isInstanceOf<MethodChannelPathProviderAurora>()); | 
				
			||||
  }); | 
				
			||||
 | 
				
			||||
  test('getDownloadsPath', () async { | 
				
			||||
    PathProviderAurora pathProviderAuroraPlugin = PathProviderAurora(); | 
				
			||||
    MockPathProviderAuroraPlatform fakePlatform = MockPathProviderAuroraPlatform(); | 
				
			||||
    PathProviderAuroraPlatform.instance = fakePlatform; | 
				
			||||
 | 
				
			||||
    expect(await pathProviderAuroraPlugin.getDownloadsPath(), '/home/defaulter/Downloads'); | 
				
			||||
  }); | 
				
			||||
} | 
				
			||||
					 | 
				
			||||
@ -1,15 +1,21 @@
					 | 
				
			||||
cmake_minimum_required(VERSION 3.5) | 
				
			||||
cmake_minimum_required(VERSION 3.10) | 
				
			||||
 | 
				
			||||
project(xdga_directories VERSION 0.0.1) | 
				
			||||
 | 
				
			||||
find_package(Qt5 COMPONENTS Core REQUIRED) | 
				
			||||
find_package(PkgConfig REQUIRED) | 
				
			||||
 | 
				
			||||
pkg_check_modules(Qt5Core REQUIRED IMPORTED_TARGET Qt5Core) | 
				
			||||
 | 
				
			||||
add_library(xdga_directories SHARED xdga_directories.cpp) | 
				
			||||
add_library(xdga_directories SHARED | 
				
			||||
    "xdga_directories.cpp" | 
				
			||||
) | 
				
			||||
 | 
				
			||||
target_link_libraries(xdga_directories Qt5::Core) | 
				
			||||
target_link_libraries(xdga_directories PRIVATE PkgConfig::Qt5Core) | 
				
			||||
 | 
				
			||||
set_target_properties(xdga_directories PROPERTIES | 
				
			||||
    PUBLIC_HEADER xdga_directories.h | 
				
			||||
    PUBLIC_HEADER "xdga_directories.h" | 
				
			||||
    OUTPUT_NAME "xdga_directories" | 
				
			||||
    XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Hex_Identity_ID_Goes_Here" | 
				
			||||
) | 
				
			||||
 | 
				
			||||
target_compile_definitions(xdga_directories PUBLIC DART_SHARED_LIB) | 
				
			||||
 | 
				
			||||
					 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue