diff --git a/analysis_options.yaml b/analysis_options.yaml index 7090ee1..3820af2 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -3,6 +3,7 @@ include: package:pedantic/analysis_options.yaml linter: rules: - camel_case_types + - avoid_print analyzer: errors: diff --git a/android/app/build.gradle b/android/app/build.gradle index f8c52de..916bd43 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -44,7 +44,7 @@ android { defaultConfig { applicationId "chat.fluffy.fluffychat" - minSdkVersion 16 + minSdkVersion 18 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj deleted file mode 100644 index 0df4ebe..0000000 --- a/ios/Runner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,587 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 825E8C4DDFD87D133ACCCC1A /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14FAF412639B88C5C2721D00 /* Pods_Runner.framework */; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; - 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; - 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 9705A1C41CF9048500538489 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 0EF69A899CE7F4E07C5F6599 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 14FAF412639B88C5C2721D00 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; - 6D40C7CF338C6054DF530EE6 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; - 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; - 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; - 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - B7CDE45F1181122C41ED566D /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 97C146EB1CF9000F007C117D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, - 825E8C4DDFD87D133ACCCC1A /* Pods_Runner.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 587F23226AD40CECE246E2A7 /* Pods */ = { - isa = PBXGroup; - children = ( - 0EF69A899CE7F4E07C5F6599 /* Pods-Runner.debug.xcconfig */, - 6D40C7CF338C6054DF530EE6 /* Pods-Runner.release.xcconfig */, - B7CDE45F1181122C41ED566D /* Pods-Runner.profile.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; - 9740EEB11CF90186004384FC /* Flutter */ = { - isa = PBXGroup; - children = ( - 3B80C3931E831B6300D905FE /* App.framework */, - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 9740EEB31CF90195004384FC /* Generated.xcconfig */, - ); - name = Flutter; - sourceTree = ""; - }; - 97C146E51CF9000F007C117D = { - isa = PBXGroup; - children = ( - 9740EEB11CF90186004384FC /* Flutter */, - 97C146F01CF9000F007C117D /* Runner */, - 97C146EF1CF9000F007C117D /* Products */, - 587F23226AD40CECE246E2A7 /* Pods */, - 9BE4B8D2394D0E419F06E05E /* Frameworks */, - ); - sourceTree = ""; - }; - 97C146EF1CF9000F007C117D /* Products */ = { - isa = PBXGroup; - children = ( - 97C146EE1CF9000F007C117D /* Runner.app */, - ); - name = Products; - sourceTree = ""; - }; - 97C146F01CF9000F007C117D /* Runner */ = { - isa = PBXGroup; - children = ( - 97C146FA1CF9000F007C117D /* Main.storyboard */, - 97C146FD1CF9000F007C117D /* Assets.xcassets */, - 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, - 97C147021CF9000F007C117D /* Info.plist */, - 97C146F11CF9000F007C117D /* Supporting Files */, - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, - 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, - 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, - ); - path = Runner; - sourceTree = ""; - }; - 97C146F11CF9000F007C117D /* Supporting Files */ = { - isa = PBXGroup; - children = ( - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 9BE4B8D2394D0E419F06E05E /* Frameworks */ = { - isa = PBXGroup; - children = ( - 14FAF412639B88C5C2721D00 /* Pods_Runner.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 97C146ED1CF9000F007C117D /* Runner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; - buildPhases = ( - F4901FBEE4C8B0FA7B998652 /* [CP] Check Pods Manifest.lock */, - 9740EEB61CF901F6004384FC /* Run Script */, - 97C146EA1CF9000F007C117D /* Sources */, - 97C146EB1CF9000F007C117D /* Frameworks */, - 97C146EC1CF9000F007C117D /* Resources */, - 9705A1C41CF9048500538489 /* Embed Frameworks */, - 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - BAF2985AB306D24B14B17E3F /* [CP] Embed Pods Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Runner; - productName = Runner; - productReference = 97C146EE1CF9000F007C117D /* Runner.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 97C146E61CF9000F007C117D /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1020; - ORGANIZATIONNAME = "The Chromium Authors"; - TargetAttributes = { - 97C146ED1CF9000F007C117D = { - CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = 4HV29TJN3A; - LastSwiftMigration = 1100; - }; - }; - }; - buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 97C146E51CF9000F007C117D; - productRefGroup = 97C146EF1CF9000F007C117D /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 97C146ED1CF9000F007C117D /* Runner */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 97C146EC1CF9000F007C117D /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, - 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, - 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, - 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Thin Binary"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; - }; - 9740EEB61CF901F6004384FC /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; - }; - BAF2985AB306D24B14B17E3F /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - F4901FBEE4C8B0FA7B998652 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 97C146EA1CF9000F007C117D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 97C146FA1CF9000F007C117D /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 97C146FB1CF9000F007C117D /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 97C147001CF9000F007C117D /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 249021D3217E4FDB00AE95B9 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Profile; - }; - 249021D4217E4FDB00AE95B9 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 4HV29TJN3A; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - PRODUCT_BUNDLE_IDENTIFIER = chat.fluffy.fluffychat; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Profile; - }; - 97C147031CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 97C147041CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 97C147061CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 4HV29TJN3A; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - PRODUCT_BUNDLE_IDENTIFIER = chat.fluffy.fluffychat; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Debug; - }; - 97C147071CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 4HV29TJN3A; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - PRODUCT_BUNDLE_IDENTIFIER = chat.fluffy.fluffychat; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 97C147031CF9000F007C117D /* Debug */, - 97C147041CF9000F007C117D /* Release */, - 249021D3217E4FDB00AE95B9 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 97C147061CF9000F007C117D /* Debug */, - 97C147071CF9000F007C117D /* Release */, - 249021D4217E4FDB00AE95B9 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 97C146E61CF9000F007C117D /* Project object */; -} diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 1d526a1..0000000 --- a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme deleted file mode 100644 index a28140c..0000000 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 21a3cc1..0000000 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/lib/components/matrix.dart b/lib/components/matrix.dart index 6a7d7d7..a012d51 100644 --- a/lib/components/matrix.dart +++ b/lib/components/matrix.dart @@ -6,8 +6,8 @@ import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/event_extension.dart'; +import 'package:fluffychat/utils/famedlysdk_store.dart'; import 'package:fluffychat/utils/room_extension.dart'; -import 'package:fluffychat/utils/sqflite_store.dart'; import 'package:fluffychat/views/chat.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -48,52 +48,8 @@ class MatrixState extends State { String activeRoomId; - /// Used to load the old account if there is no store available. - void loadAccount() async { - final LocalStorage storage = LocalStorage('LocalStorage'); - await storage.ready; - - final credentialsStr = storage.getItem(widget.clientName); - if (credentialsStr == null || credentialsStr.isEmpty) { - client.onLoginStateChanged.add(LoginState.loggedOut); - return; - } - print("[Matrix] Restoring account credentials"); - final Map credentials = json.decode(credentialsStr); - client.connect( - newDeviceID: credentials["deviceID"], - newDeviceName: credentials["deviceName"], - newHomeserver: credentials["homeserver"], - newLazyLoadMembers: credentials["lazyLoadMembers"], - //newMatrixVersions: credentials["matrixVersions"], // FIXME: wrong List type - newToken: credentials["token"], - newUserID: credentials["userID"], - ); - } - - /// Used to save the current account persistently if there is no store available. - Future saveAccount() async { - if (!kIsWeb) return; - print("[Matrix] Save account credentials in crypted preferences"); - final Map credentials = { - "deviceID": client.deviceID, - "deviceName": client.deviceName, - "homeserver": client.homeserver, - "lazyLoadMembers": client.lazyLoadMembers, - "matrixVersions": client.matrixVersions, - "token": client.accessToken, - "userID": client.userID, - }; - - final LocalStorage storage = LocalStorage('LocalStorage'); - await storage.ready; - await storage.setItem(widget.clientName, json.encode(credentials)); - return; - } - void clean() async { if (!kIsWeb) return; - print("Clear session..."); final LocalStorage storage = LocalStorage('LocalStorage'); await storage.ready; @@ -202,7 +158,7 @@ class MatrixState extends State { (r) => r.isFirst); } catch (_) { Toast.show("Failed to open chat...", context); - print(_); + debugPrint(_); } }; @@ -211,7 +167,6 @@ class MatrixState extends State { AndroidInitializationSettings('notifications_icon'); var initializationSettingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: (i, a, b, c) { - print("onDidReceiveLocalNotification: $i $a $b $c"); return null; }); var initializationSettings = InitializationSettings( @@ -313,7 +268,7 @@ class MatrixState extends State { platformChannelSpecifics, payload: roomId); } catch (exception) { - print("[Push] Error while processing notification: " + + debugPrint("[Push] Error while processing notification: " + exception.toString()); } return null; @@ -322,7 +277,7 @@ class MatrixState extends State { // Currently fires unexpectetly... https://github.com/FirebaseExtended/flutterfire/issues/1060 //onLaunch: goToRoom, ); - print("[Push] Firebase initialized"); + debugPrint("[Push] Firebase initialized"); return; } @@ -331,13 +286,15 @@ class MatrixState extends State { IosNotificationSettings(sound: true, badge: true, alert: true)); _firebaseMessaging.onIosSettingsRegistered .listen((IosNotificationSettings settings) { - print("Settings registered: $settings"); + debugPrint("Settings registered: $settings"); }); } void _initWithStore() async { Future initLoginState = client.onLoginStateChanged.stream.first; - client.store = Store(client); + client.storeAPI = kIsWeb ? Store(client) : ExtendedStore(client); + debugPrint( + "[Store] Store is extended: ${client.storeAPI.extended.toString()}"); if (await initLoginState == LoginState.logged) { await setupFirebase(); } @@ -346,14 +303,9 @@ class MatrixState extends State { @override void initState() { if (widget.client == null) { - print("[Matrix] Init matrix client"); + debugPrint("[Matrix] Init matrix client"); client = Client(widget.clientName, debug: false); - if (!kIsWeb) { - _initWithStore(); - } else { - print("[Web] Web platform detected - Store disabled!"); - loadAccount(); - } + _initWithStore(); } else { client = widget.client; } diff --git a/lib/utils/sqflite_store.dart b/lib/utils/famedlysdk_store.dart similarity index 69% rename from lib/utils/sqflite_store.dart rename to lib/utils/famedlysdk_store.dart index a385a3d..91691bb 100644 --- a/lib/utils/sqflite_store.dart +++ b/lib/utils/famedlysdk_store.dart @@ -1,94 +1,158 @@ -/* - * Copyright (c) 2019 Zender & Kurtz GbR. - * - * Authors: - * Christian Pauly - * Marcel Radzio - * - * This file is part of famedlysdk_store_sqflite. - * - * famedlysdk_store_sqflite is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * famedlysdk_store_sqflite is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with famedlysdk_store_sqflite. If not, see . - */ - -library famedlysdk_store_sqflite; - -import 'dart:async'; import 'dart:convert'; -import 'dart:core'; import 'package:famedlysdk/famedlysdk.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:localstorage/localstorage.dart'; +import 'dart:async'; +import 'dart:core'; import 'package:path/path.dart' as p; import 'package:sqflite/sqflite.dart'; -/// Responsible to store all data persistent and to query objects from the -/// database. class Store extends StoreAPI { final Client client; + final LocalStorage storage; + final FlutterSecureStorage secureStorage; - Store(this.client) { + Store(this.client) + : storage = !kIsWeb ? null : LocalStorage('LocalStorage'), + secureStorage = kIsWeb ? null : FlutterSecureStorage() { _init(); } + Future getItem(String key) async { + if (kIsWeb) { + await storage.ready; + return await storage.getItem(key); + } + return await secureStorage.read(key: key); + } + + Future setItem(String key, String value) async { + if (kIsWeb) { + await storage.ready; + return await storage.setItem(key, value); + } + return await secureStorage.write(key: key, value: value); + } + + _init() async { + final credentialsStr = await getItem(client.clientName); + + if (credentialsStr == null || credentialsStr.isEmpty) { + client.onLoginStateChanged.add(LoginState.loggedOut); + return; + } + debugPrint("[Matrix] Restoring account credentials"); + final Map credentials = json.decode(credentialsStr); + client.connect( + newDeviceID: credentials["deviceID"], + newDeviceName: credentials["deviceName"], + newHomeserver: credentials["homeserver"], + newLazyLoadMembers: credentials["lazyLoadMembers"], + newMatrixVersions: List.from(credentials["matrixVersions"]), + newToken: credentials["token"], + newUserID: credentials["userID"], + newPrevBatch: kIsWeb + ? null + : (credentials["prev_batch"]?.isEmpty ?? true) + ? null + : credentials["prev_batch"], + ); + } + + Future storeClient() async { + final Map credentials = { + "deviceID": client.deviceID, + "deviceName": client.deviceName, + "homeserver": client.homeserver, + "lazyLoadMembers": client.lazyLoadMembers, + "matrixVersions": client.matrixVersions, + "token": client.accessToken, + "userID": client.userID, + }; + await setItem(client.clientName, json.encode(credentials)); + return; + } + + Future clear() => kIsWeb ? storage.clear() : secureStorage.deleteAll(); +} + +/// Responsible to store all data persistent and to query objects from the +/// database. +class ExtendedStore extends Store implements ExtendedStoreAPI { + @override + final bool extended = true; + + ExtendedStore(Client client) : super(client); + Database _db; + var txn; /// SQLite database for all persistent data. It is recommended to extend this /// SDK instead of writing direct queries to the database. //Database get db => _db; + @override _init() async { + // Open the database and migrate if necessary. var databasePath = await getDatabasesPath(); String path = p.join(databasePath, "FluffyMatrix.db"); - _db = await openDatabase(path, version: 15, + _db = await openDatabase(path, version: 16, onCreate: (Database db, int version) async { await createTables(db); }, onUpgrade: (Database db, int oldVersion, int newVersion) async { - print("[Store] Migrate databse from version $oldVersion to $newVersion"); + debugPrint( + "[Store] Migrate database from version $oldVersion to $newVersion"); if (oldVersion != newVersion) { - schemes.forEach((String name, String scheme) async { - if (name != "Clients") await db.execute("DROP TABLE IF EXISTS $name"); - }); - await createTables(db); - await db.rawUpdate("UPDATE Clients SET prev_batch='' WHERE client=?", - [client.clientName]); + // Look for an old entry in an old clients library + List list = []; + try { + list = await db.rawQuery( + "SELECT * FROM Clients WHERE client=?", [client.clientName]); + } on DatabaseException catch (_) {} catch (_) { + rethrow; + } + + if (list.length == 1) { + debugPrint("[Store] Found old client from deprecated store"); + var clientList = list[0]; + _db = db; + client.connect( + newToken: clientList["token"], + newHomeserver: clientList["homeserver"], + newUserID: clientList["matrix_id"], + newDeviceID: clientList["device_id"], + newDeviceName: clientList["device_name"], + newLazyLoadMembers: clientList["lazy_load_members"] == 1, + newMatrixVersions: + clientList["matrix_versions"].toString().split(","), + newPrevBatch: null, + ); + await db.execute("DROP TABLE IF EXISTS Clients"); + if (client.debug) { + debugPrint( + "[Store] Restore client credentials from deprecated database of ${client.userID}"); + } + schemes.forEach((String name, String scheme) async { + await db.execute("DROP TABLE IF EXISTS $name"); + }); + await createTables(db); + } + } else { + client.onLoginStateChanged.add(LoginState.loggedOut); } }); + // Mark all pending events as failed. await _db.rawUpdate("UPDATE Events SET status=-1 WHERE status=0"); + super._init(); + } - List list = await _db - .rawQuery("SELECT * FROM Clients WHERE client=?", [client.clientName]); - if (list.length == 1) { - var clientList = list[0]; - print("[Store] Previous batch: '${clientList["prev_batch"].toString()}'"); - client.connect( - newToken: clientList["token"], - newHomeserver: clientList["homeserver"], - newUserID: clientList["matrix_id"], - newDeviceID: clientList["device_id"], - newDeviceName: clientList["device_name"], - newLazyLoadMembers: clientList["lazy_load_members"] == 1, - newMatrixVersions: clientList["matrix_versions"].toString().split(","), - newPrevBatch: clientList["prev_batch"].toString().isEmpty - ? null - : clientList["prev_batch"], - ); - if (client.debug) { - print("[Store] Restore client credentials of ${client.userID}"); - } - } else { - client.onLoginStateChanged.add(LoginState.loggedOut); - } + Future setRoomPrevBatch(String roomId, String prevBatch) async { + await txn.rawUpdate( + "UPDATE Rooms SET prev_batch=? WHERE room_id=?", [roomId, prevBatch]); + return; } Future createTables(Database db) async { @@ -97,36 +161,12 @@ class Store extends StoreAPI { }); } - Future queryPrevBatch() async { - List list = await txn.rawQuery( - "SELECT prev_batch FROM Clients WHERE client=?", [client.clientName]); - return list[0]["prev_batch"]; - } - - /// Will be automatically called when the client is logged in successfully. - Future storeClient() async { - await _db - .rawInsert('INSERT OR IGNORE INTO Clients VALUES(?,?,?,?,?,?,?,?,?)', [ - client.clientName, - client.accessToken, - client.homeserver, - client.userID, - client.deviceID, - client.deviceName, - client.prevBatch, - client.matrixVersions.join(","), - client.lazyLoadMembers, - ]); - return; - } - /// Clears all tables from the database. Future clear() async { - await _db - .rawDelete("DELETE FROM Clients WHERE client=?", [client.clientName]); schemes.forEach((String name, String scheme) async { - if (name != "Clients") await _db.rawDelete("DELETE FROM $name"); + await _db.rawDelete("DELETE FROM $name"); }); + await super.clear(); return; } @@ -138,11 +178,13 @@ class Store extends StoreAPI { }); } - /// Will be automatically called on every synchronisation. Must be called inside of - // /// [transaction]. - void storePrevBatch(String prevBatch) { - txn.rawUpdate("UPDATE Clients SET prev_batch=? WHERE client=?", - [prevBatch, client.clientName]); + /// Will be automatically called on every synchronisation. + Future storePrevBatch(String prevBatch) async { + final credentialsStr = await getItem(client.clientName); + if (credentialsStr == null) return; + final Map credentials = json.decode(credentialsStr); + credentials["prev_batch"] = prevBatch; + await setItem(client.clientName, json.encode(credentials)); } Future storeRoomPrevBatch(Room room) async { @@ -345,37 +387,6 @@ class Store extends StoreAPI { return Event.fromJson(res[0], room).asUser; } - /// Loads all Users in the database to provide a contact list - /// except users who are in the Room with the ID [exceptRoomID]. - Future> loadContacts({String exceptRoomID = ""}) async { - List> res = await _db.rawQuery( - "SELECT * FROM RoomStates WHERE state_key LIKE '@%:%' AND state_key!=? AND room_id!=? GROUP BY state_key ORDER BY state_key", - [client.userID, exceptRoomID]); - List userList = []; - for (int i = 0; i < res.length; i++) { - userList.add(Event.fromJson(res[i], Room(id: "", client: client)).asUser); - } - return userList; - } - - /// Returns all users of a room by a given [roomID]. - Future> loadParticipants(Room room) async { - List> res = await _db.rawQuery( - "SELECT * " + - " FROM RoomStates " + - " WHERE room_id=? " + - " AND type='m.room.member'", - [room.id]); - - List participants = []; - - for (num i = 0; i < res.length; i++) { - participants.add(Event.fromJson(res[i], room).asUser); - } - - return participants; - } - /// Returns a list of events for the given room and sets all participants. Future> getEventList(Room room) async { List> eventRes = await _db.rawQuery( @@ -416,17 +427,6 @@ class Store extends StoreAPI { return roomList; } - /// Returns a room without events and participants. - @deprecated - Future getRoomById(String id) async { - List> res = - await _db.rawQuery("SELECT * FROM Rooms WHERE room_id=?", [id]); - if (res.length != 1) return null; - return Room.getRoomFromTableRow(res[0], client, - roomAccountData: getAccountDataFromRoomId(id), - states: getStatesFromRoomId(id)); - } - Future>> getStatesFromRoomId(String id) async { return _db.rawQuery("SELECT * FROM RoomStates WHERE room_id=?", [id]); } @@ -487,48 +487,7 @@ class Store extends StoreAPI { return; } - Future forgetNotification(String roomID) async { - assert(roomID != ""); - await _db - .rawDelete("DELETE FROM NotificationsCache WHERE chat_id=?", [roomID]); - return; - } - - Future addNotification(String roomID, String eventId, int uniqueID) async { - assert(roomID != ""); - assert(eventId != ""); - await _db.rawInsert( - "INSERT OR REPLACE INTO NotificationsCache(id, chat_id, event_id) VALUES (?, ?, ?)", - [uniqueID, roomID, eventId]); - // Make sure we got the same unique ID everywhere - await _db.rawUpdate("UPDATE NotificationsCache SET id=? WHERE chat_id=?", - [uniqueID, roomID]); - return; - } - - Future>> getNotificationByRoom( - String roomId) async { - assert(roomId != ""); - List> res = await _db - .rawQuery("SELECT * FROM NotificationsCache WHERE chat_id=?", [roomId]); - if (res.isEmpty) return null; - return res; - } - static final Map schemes = { - /// The database scheme for the Client class. - "Clients": 'CREATE TABLE IF NOT EXISTS Clients(' + - 'client TEXT PRIMARY KEY, ' + - 'token TEXT, ' + - 'homeserver TEXT, ' + - 'matrix_id TEXT, ' + - 'device_id TEXT, ' + - 'device_name TEXT, ' + - 'prev_batch TEXT, ' + - 'matrix_versions TEXT, ' + - 'lazy_load_members INTEGER, ' + - 'UNIQUE(client))', - /// The database scheme for the Room class. 'Rooms': 'CREATE TABLE IF NOT EXISTS Rooms(' + 'room_id TEXT PRIMARY KEY, ' + @@ -587,12 +546,5 @@ class Store extends StoreAPI { 'sender TEXT, ' + 'content TEXT, ' + 'UNIQUE(sender))', - - /// The database scheme for the NotificationsCache class. - "NotificationsCache": 'CREATE TABLE IF NOT EXISTS NotificationsCache(' + - 'id int, ' + - 'chat_id TEXT, ' + // The chat id - 'event_id TEXT, ' + // The matrix id of the Event - 'UNIQUE(event_id))', }; } diff --git a/lib/utils/url_launcher.dart b/lib/utils/url_launcher.dart index 81555bd..da30dd8 100644 --- a/lib/utils/url_launcher.dart +++ b/lib/utils/url_launcher.dart @@ -11,7 +11,6 @@ class UrlLauncher { const UrlLauncher(this.context, this.url); void launchUrl() { - print("Open url: $url"); if (url.startsWith("https://matrix.to/#/")) { return openMatrixToUrl(); } @@ -22,7 +21,6 @@ class UrlLauncher { final matrix = Matrix.of(context); final String identifier = url.replaceAll("https://matrix.to/#/", ""); if (identifier.substring(0, 1) == "#") { - print("Join room ${Uri.encodeFull(identifier)}"); final response = await matrix.tryRequestWithLoadingDialog( matrix.client.joinRoomById( Uri.encodeComponent(identifier), @@ -35,7 +33,6 @@ class UrlLauncher { (r) => r.isFirst, ); } else if (identifier.substring(0, 1) == "@") { - print("Start chat with user $identifier"); final User user = User( identifier, room: Room(id: "", client: matrix.client), diff --git a/lib/views/auth_web_view.dart b/lib/views/auth_web_view.dart index e2c2383..34ce4b1 100644 --- a/lib/views/auth_web_view.dart +++ b/lib/views/auth_web_view.dart @@ -14,7 +14,6 @@ class AuthWebView extends StatelessWidget { Widget build(BuildContext context) { final String url = Matrix.of(context).client.homeserver + "/_matrix/client/r0/auth/$authType/fallback/web?session=$session"; - print(url); return Scaffold( appBar: AppBar( title: Text(I18n.of(context).authentication), diff --git a/lib/views/chat_list.dart b/lib/views/chat_list.dart index 3694815..fc03145 100644 --- a/lib/views/chat_list.dart +++ b/lib/views/chat_list.dart @@ -85,9 +85,7 @@ class _ChatListState extends State { void getSharedData() { // For sharing or opening urls/text coming from outside the app while the app is in the memory _intentDataStreamSubscription = ReceiveSharingIntent.getTextStream() - .listen(processSharedText, onError: (err) { - print("getLinkStream error: $err"); - }); + .listen(processSharedText, onError: (err) {}); // For sharing or opening urls/text coming from outside the app while the app is closed ReceiveSharingIntent.getInitialText().then(processSharedText); } diff --git a/lib/views/content_web_view.dart b/lib/views/content_web_view.dart index fce4823..fc9f1e3 100644 --- a/lib/views/content_web_view.dart +++ b/lib/views/content_web_view.dart @@ -13,7 +13,6 @@ class ContentWebView extends StatelessWidget { @override Widget build(BuildContext context) { final String url = content.getDownloadLink(Matrix.of(context).client); - print(url); return Scaffold( appBar: AppBar( title: Text( diff --git a/lib/views/login.dart b/lib/views/login.dart index bb5ce3e..a9c36b4 100644 --- a/lib/views/login.dart +++ b/lib/views/login.dart @@ -50,7 +50,6 @@ class _LoginState extends State { } try { - print("[Login] Check server..."); setState(() => loading = true); if (!await matrix.client.checkServer(homeserver)) { setState( @@ -63,7 +62,6 @@ class _LoginState extends State { return setState(() => loading = false); } try { - print("[Login] Try to login..."); await matrix.client.login( usernameController.text, passwordController.text, initialDeviceDisplayName: matrix.widget.clientName); @@ -76,19 +74,14 @@ class _LoginState extends State { } if (!kIsWeb) { try { - print("[Login] Setup Firebase..."); await matrix.setupFirebase(); } catch (exception) { - print("[Login] Failed to setup Firebase. Logout now..."); await matrix.client.logout(); matrix.clean(); setState(() => passwordError = exception.toString()); return setState(() => loading = false); } } - - print("[Login] Store account and go to ChatListView"); - await Matrix.of(context).saveAccount(); setState(() => loading = false); await Navigator.of(context).pushAndRemoveUntil( AppRoute.defaultRoute(context, ChatListView()), (r) => false); diff --git a/lib/views/settings.dart b/lib/views/settings.dart index ba71178..437c99d 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -76,7 +76,6 @@ class _SettingsState extends State { ), ), ); - print(success); if (success != false) { Toast.show( I18n.of(context).avatarHasBeenChanged, diff --git a/lib/views/sign_up.dart b/lib/views/sign_up.dart index 490e03b..7f24dcd 100644 --- a/lib/views/sign_up.dart +++ b/lib/views/sign_up.dart @@ -58,7 +58,6 @@ class _SignUpState extends State { } try { - print("[Sign Up] Check server..."); setState(() => loading = true); if (!await matrix.client.checkServer(homeserver)) { setState( @@ -72,7 +71,6 @@ class _SignUpState extends State { } try { - print("[Sign Up] Check if username is available..."); await matrix.client.usernameAvailable(preferredUsername); } on MatrixException catch (exception) { setState(() => usernameError = exception.errorMessage); diff --git a/lib/views/sign_up_password.dart b/lib/views/sign_up_password.dart index c2c0e6f..6835342 100644 --- a/lib/views/sign_up_password.dart +++ b/lib/views/sign_up_password.dart @@ -39,7 +39,6 @@ class _SignUpPasswordState extends State { } try { - print("[Sign Up] Create account..."); setState(() => loading = true); Future waitForLogin = matrix.client.onLoginStateChanged.stream.first; @@ -52,8 +51,6 @@ class _SignUpPasswordState extends State { await waitForLogin; } on MatrixException catch (exception) { if (exception.requireAdditionalAuthentication) { - print(exception.raw); - final List stages = exception.authenticationFlows .firstWhere((a) => !a.stages.contains("m.login.email.identity")) .stages; @@ -90,7 +87,7 @@ class _SignUpPasswordState extends State { return setState(() => loading = false); } } catch (exception) { - print(exception); + debugPrint(exception); setState(() => passwordError = exception.toString()); return setState(() => loading = false); } diff --git a/pubspec.lock b/pubspec.lock index dd06d00..416e8d7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -110,8 +110,8 @@ packages: dependency: "direct main" description: path: "." - ref: "2545995bbe96a1d96fe176ab666f4dd03d591aa6" - resolved-ref: "2545995bbe96a1d96fe176ab666f4dd03d591aa6" + ref: "1ff04785c0fb7db986c8a7b33396bf06301f1a14" + resolved-ref: "1ff04785c0fb7db986c8a7b33396bf06301f1a14" url: "https://gitlab.com/famedly/famedlysdk.git" source: git version: "0.0.1" @@ -160,6 +160,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + url: "https://pub.dartlang.org" + source: hosted + version: "3.3.1+1" flutter_speed_dial: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 14b7a02..f14b3a7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: famedlysdk: git: url: https://gitlab.com/famedly/famedlysdk.git - ref: bc2ca9749cfcc0506c59f97f4ae4987f0e84fbf4 + ref: 1ff04785c0fb7db986c8a7b33396bf06301f1a14 localstorage: ^3.0.1+4 bubble: ^1.1.9+1 @@ -46,6 +46,7 @@ dependencies: webview_flutter: ^0.3.19+4 share: ^0.6.3+5 receive_sharing_intent: ^1.3.2 + flutter_secure_storage: ^3.3.1+1 intl: ^0.16.0 intl_translation: ^0.17.9