From 98061025f358abda3ff408ac9947830e41913503 Mon Sep 17 00:00:00 2001 From: Woit Date: Tue, 19 Nov 2024 13:59:22 +0100 Subject: [PATCH] wip --- .gitignore | 3 ++ Monal/Classes/MLConstants.h | 4 ++- Monal/Monal.xcodeproj/project.pbxproj | 44 +++++++++++++++++------- Monal/another.im/AnotherIMApp.swift | 11 ++---- Monal/another.im/ContentView.swift | 17 +++------ Monal/another.im/MonalXmppWrapper.swift | 39 +++++++++++++++++++++ Monal/another.im/another.im.entitlements | 7 +++- 7 files changed, 91 insertions(+), 34 deletions(-) create mode 100644 Monal/another.im/MonalXmppWrapper.swift diff --git a/.gitignore b/.gitignore index 8e01f3d..fb7d849 100644 --- a/.gitignore +++ b/.gitignore @@ -51,8 +51,11 @@ Monal/build/* profile *.moved-aside DerivedData + +# Monal/.nvim Monal/buildServer.json +Monal/MY_MARKS.txt # Pods Monal/Pods diff --git a/Monal/Classes/MLConstants.h b/Monal/Classes/MLConstants.h index 199900b..bbd61fe 100644 --- a/Monal/Classes/MLConstants.h +++ b/Monal/Classes/MLConstants.h @@ -39,7 +39,9 @@ static const DDLogLevel ddLogLevel = LOG_LEVEL_STDOUT; #define kBackgroundProcessingTask @"im.monal.process" #define kBackgroundRefreshingTask @"im.monal.refresh" #else - #define kAppGroup @"group.monal" + // fmodf: 19.11.24 - changed to actual another.im group + // #define kAppGroup @"group.monal" + #define kAppGroup @"group.another.im.test" #define kMonalOpenURL [NSURL URLWithString:@"monalOpen://"] #define kBackgroundProcessingTask @"im.monal.process" #define kBackgroundRefreshingTask @"im.monal.refresh" diff --git a/Monal/Monal.xcodeproj/project.pbxproj b/Monal/Monal.xcodeproj/project.pbxproj index 3cb83ee..e04fe1a 100644 --- a/Monal/Monal.xcodeproj/project.pbxproj +++ b/Monal/Monal.xcodeproj/project.pbxproj @@ -130,6 +130,8 @@ 54F0B81C282316F5003664BD /* RegisterAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54F0B81B282316F5003664BD /* RegisterAccount.swift */; }; 6E9488F6997650B805476F25 /* Pods_another_im.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F29121F912380F72CCE51747 /* Pods_another_im.framework */; }; 7D40218FEAB3BA882811A682 /* Pods_Monal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C40963CED187B2F1B4B88F7 /* Pods_Monal.framework */; }; + 7E6AF38F2CEB9110004328B5 /* MonalXmppWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E6AF38E2CEB9110004328B5 /* MonalXmppWrapper.swift */; }; + 7E6AF3902CEB982F004328B5 /* sworim.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 2601D9CA0FBF25EF004DB939 /* sworim.sqlite */; }; 7E995F242CEAC5D2005B30EE /* AnotherIMApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E995F202CEAC5D2005B30EE /* AnotherIMApp.swift */; }; 7E995F252CEAC5D2005B30EE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E995F222CEAC5D2005B30EE /* ContentView.swift */; }; 7E995F272CEAC5D2005B30EE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E995F212CEAC5D2005B30EE /* Assets.xcassets */; }; @@ -594,6 +596,8 @@ 79A6AA4819B69B5FFFA28236 /* Pods-NotificationService.appstore.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.appstore.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.appstore.xcconfig"; sourceTree = ""; }; 7D281334DB441077E42E3E89 /* Pods-another.im.appstore-quicksy.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-another.im.appstore-quicksy.xcconfig"; path = "Target Support Files/Pods-another.im/Pods-another.im.appstore-quicksy.xcconfig"; sourceTree = ""; }; 7D6715099247A9CCC180EE30 /* Pods-MonalUITests.beta.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MonalUITests.beta.xcconfig"; path = "Target Support Files/Pods-MonalUITests/Pods-MonalUITests.beta.xcconfig"; sourceTree = ""; }; + 7E6AF38E2CEB9110004328B5 /* MonalXmppWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonalXmppWrapper.swift; sourceTree = ""; }; + 7E6E446D2CECB76500505D5C /* another.im.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = another.im.entitlements; sourceTree = ""; }; 7E995F062CEAC4B8005B30EE /* another.im.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = another.im.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7E995F202CEAC5D2005B30EE /* AnotherIMApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnotherIMApp.swift; sourceTree = ""; }; 7E995F212CEAC5D2005B30EE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -1375,7 +1379,9 @@ 7E995F232CEAC5D2005B30EE /* another.im */ = { isa = PBXGroup; children = ( + 7E6E446D2CECB76500505D5C /* another.im.entitlements */, 7E995F202CEAC5D2005B30EE /* AnotherIMApp.swift */, + 7E6AF38E2CEB9110004328B5 /* MonalXmppWrapper.swift */, 7E995F212CEAC5D2005B30EE /* Assets.xcassets */, 7E995F222CEAC5D2005B30EE /* ContentView.swift */, ); @@ -1927,6 +1933,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 7E6AF3902CEB982F004328B5 /* sworim.sqlite in Resources */, 7E995F272CEAC5D2005B30EE /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2363,6 +2370,7 @@ files = ( 7E995F242CEAC5D2005B30EE /* AnotherIMApp.swift in Sources */, 7E995F252CEAC5D2005B30EE /* ContentView.swift in Sources */, + 7E6AF38F2CEB9110004328B5 /* MonalXmppWrapper.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3308,11 +3316,13 @@ CLANG_WARN_FRAMEWORK_INCLUDE_PRIVATE_FROM_PUBLIC = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = another.im/another.im.entitlements; + CODE_SIGN_IDENTITY = "Apple Development: Egor Mitrofanov (PM89F56B43)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = K78H7BT98L; + DEVELOPMENT_TEAM = U6CKGHL5VR; ENABLE_PREVIEWS = YES; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; @@ -3342,7 +3352,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; + PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -3391,12 +3401,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_ENTITLEMENTS = another.im/another.im.entitlements; + CODE_SIGN_IDENTITY = "Apple Development: Egor Mitrofanov (PM89F56B43)"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = K78H7BT98L; + DEVELOPMENT_TEAM = U6CKGHL5VR; ENABLE_NS_ASSERTIONS = NO; ENABLE_PREVIEWS = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -3430,7 +3442,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; + PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -3481,12 +3493,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_ENTITLEMENTS = another.im/another.im.entitlements; + CODE_SIGN_IDENTITY = "Apple Development: Egor Mitrofanov (PM89F56B43)"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = K78H7BT98L; + DEVELOPMENT_TEAM = U6CKGHL5VR; ENABLE_NS_ASSERTIONS = NO; ENABLE_PREVIEWS = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -3520,7 +3534,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; + PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -3571,12 +3585,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_ENTITLEMENTS = another.im/another.im.entitlements; + CODE_SIGN_IDENTITY = "Apple Development: Egor Mitrofanov (PM89F56B43)"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = K78H7BT98L; + DEVELOPMENT_TEAM = U6CKGHL5VR; ENABLE_NS_ASSERTIONS = NO; ENABLE_PREVIEWS = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -3610,7 +3626,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; + PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -3661,12 +3677,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_ENTITLEMENTS = another.im/another.im.entitlements; + CODE_SIGN_IDENTITY = "Apple Development: Egor Mitrofanov (PM89F56B43)"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = K78H7BT98L; + DEVELOPMENT_TEAM = U6CKGHL5VR; ENABLE_NS_ASSERTIONS = NO; ENABLE_PREVIEWS = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -3700,7 +3718,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; + PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -3751,12 +3769,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_ENTITLEMENTS = another.im/another.im.entitlements; + CODE_SIGN_IDENTITY = "Apple Development: Egor Mitrofanov (PM89F56B43)"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = K78H7BT98L; + DEVELOPMENT_TEAM = U6CKGHL5VR; ENABLE_NS_ASSERTIONS = NO; ENABLE_PREVIEWS = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -3790,7 +3810,7 @@ MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios; + PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; diff --git a/Monal/another.im/AnotherIMApp.swift b/Monal/another.im/AnotherIMApp.swift index fa72b14..18d2bdb 100644 --- a/Monal/another.im/AnotherIMApp.swift +++ b/Monal/another.im/AnotherIMApp.swift @@ -1,18 +1,13 @@ -// -// another_imApp.swift -// another.im -// -// Created by Wo It on 18.11.24. -// Copyright © 2024 monal-im.org. All rights reserved. -// - import SwiftUI @main struct AnotherIMApp: App { + @StateObject var wrapper = MonalXmppWrapper() + var body: some Scene { WindowGroup { ContentView() + .environmentObject(wrapper) } } } diff --git a/Monal/another.im/ContentView.swift b/Monal/another.im/ContentView.swift index c17933b..9019dc6 100644 --- a/Monal/another.im/ContentView.swift +++ b/Monal/another.im/ContentView.swift @@ -1,14 +1,8 @@ -// -// ContentView.swift -// another.im -// -// Created by Wo It on 18.11.24. -// Copyright © 2024 monal-im.org. All rights reserved. -// - import SwiftUI struct ContentView: View { + @EnvironmentObject var wrapper: MonalXmppWrapper + var body: some View { VStack { Image(systemName: "globe") @@ -17,9 +11,8 @@ struct ContentView: View { Text("Hello, world!") } .padding() + .onAppear { + print("test") + } } } - -#Preview { - ContentView() -} diff --git a/Monal/another.im/MonalXmppWrapper.swift b/Monal/another.im/MonalXmppWrapper.swift new file mode 100644 index 0000000..86ba822 --- /dev/null +++ b/Monal/another.im/MonalXmppWrapper.swift @@ -0,0 +1,39 @@ +import Foundation +import monalxmpp + +enum AccountsAvailability { + case noAccounts + case allDisabled + case someEnabled +} + +final class MonalXmppWrapper: ObservableObject { + @Published var accountsAvailability: AccountsAvailability = .noAccounts + + let xmpp: MLXMPPManager + let db: DataLayer + + init() { + xmpp = MLXMPPManager.sharedInstance() + db = DataLayer.sharedInstance() + + checkAccountsOnLoad() + } +} + +// MARK: - Accounts +private extension MonalXmppWrapper { + // Check accounts state on launch + func checkAccountsOnLoad() { + let enabledAcocunts = db.enabledAccountList() + let allAccounts = db.accountList() + + if allAccounts.isEmpty { + accountsAvailability = .noAccounts + } else if !enabledAcocunts.isEmpty { + accountsAvailability = .someEnabled + } else { + accountsAvailability = .allDisabled + } + } +} diff --git a/Monal/another.im/another.im.entitlements b/Monal/another.im/another.im.entitlements index 0c67376..3163c75 100644 --- a/Monal/another.im/another.im.entitlements +++ b/Monal/another.im/another.im.entitlements @@ -1,5 +1,10 @@ - + + com.apple.security.application-groups + + group.another.im.test + +