Skip to content

Commit

Permalink
Implement product version reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Zensey committed Oct 1, 2021
1 parent 84d8a84 commit 5717e86
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
git clone https://github.com/mysteriumnetwork/myst-launcher
pushd myst-launcher
git fetch --all --tags
git checkout tags/1.0.13
git checkout tags/1.0.14
popd
popd
Expand Down
43 changes: 17 additions & 26 deletions gobridge/gobridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

var (
manager *myst.Manager
cfg model.Config
//cfg model.Config
mon *myst.DockerMonitor
mod *model.UIModel

Expand Down Expand Up @@ -49,21 +49,21 @@ func copyFile(sourceFile, destinationFile string) {
}

//export GoInit
func GoInit(res_path *C.char) {
cfg.ResourcePath = C.GoString(res_path)
func GoInit(resPath *C.char, prodVer *C.char) {
mod = model.NewUIModel()
mod.Config.ProductVersion = C.GoString(prodVer)

targetDir := os.Getenv("HOME") + "/Library/LaunchAgents/"
os.MkdirAll(targetDir, 0755)

fileName := "com.mysterium.launcher.plist"
copyFile(cfg.ResourcePath+"/"+fileName, targetDir+fileName)
resourcePath := C.GoString(resPath)
copyFile(resourcePath+"/"+fileName, targetDir+fileName)
}

//export GoStart
func GoStart() {
fmt.Println("GoStart >")
ap = app.NewApp()
mod = model.NewUIModel()
sendConfig()

mod.UIBus.Subscribe("state-change", func() {
Expand Down Expand Up @@ -141,19 +141,12 @@ func GoTriggerUpgrade() {
ap.TriggerAction("upgrade")
}

//export GoTriggerRefresh
func GoTriggerRefresh() {
ap.TriggerAction("refresh")
}

//export GoSetStateAndConfig
func GoSetStateAndConfig(s *C.SetStateArgs) {
fmt.Println("SetState >", s)
saveConf := false
//export GoSetState
func GoSetState(s *C.SetStateArgs) {

if mod.Config.AutoUpgrade != bool(s.autoUpgrade) {
mod.Config.AutoUpgrade = bool(s.autoUpgrade)
saveConf = true
mod.Config.Save()
}

if mod.Config.Enabled != bool(s.enabled) {
Expand All @@ -163,20 +156,18 @@ func GoSetStateAndConfig(s *C.SetStateArgs) {
ap.TriggerAction("disable")
}
}
}

if mod.Config.EnablePortForwarding != bool(s.enablePortForwarding) || mod.Config.PortRangeBegin != int(s.portRangeBegin) || mod.Config.PortRangeEnd != int(s.portRangeEnd) {
mod.Config.EnablePortForwarding = bool(s.enablePortForwarding)
mod.Config.PortRangeBegin = int(s.portRangeBegin)
mod.Config.PortRangeEnd = int(s.portRangeEnd)
//export GoSetNetworkConfig
func GoSetNetworkConfig(s *C.SetStateArgs) {

ap.TriggerAction("upgrade")
saveConf = true
}
mod.Config.EnablePortForwarding = bool(s.enablePortForwarding)
mod.Config.PortRangeBegin = int(s.portRangeBegin)
mod.Config.PortRangeEnd = int(s.portRangeEnd)

if saveConf {
mod.Config.Save()
}
ap.TriggerAction("restart")
}


// required by runtime
func main() {}
6 changes: 3 additions & 3 deletions gobridge/gobridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
extern "C" {
#endif

extern void GoInit(char* res_path);
extern void GoInit(char* resPath, char* prodVer);
extern void GoStart();
extern void GoSetModalResult(int rc);
extern void GoDialogueComplete();
extern void GoOnAppExit();
extern void GoTriggerUpgrade();
extern void GoTriggerRefresh();
extern void GoSetStateAndConfig(SetStateArgs* s);
extern void GoSetState(SetStateArgs* s);
extern void GoSetNetworkConfig(SetStateArgs* s);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions launcher.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@
"$(PROJECT_DIR)/gobridge",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 1.0.12;
MARKETING_VERSION = 1.0.14;
PRODUCT_BUNDLE_IDENTIFIER = com.mysterium.launcher;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -566,7 +566,7 @@
"$(PROJECT_DIR)/gobridge",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 1.0.12;
MARKETING_VERSION = 1.0.14;
PRODUCT_BUNDLE_IDENTIFIER = com.mysterium.launcher;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
4 changes: 3 additions & 1 deletion launcher/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ - (void) applicationWillTerminate:(NSNotification *)aNotification {

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
GoInit((char*)[resourcePath UTF8String]);
id productVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

GoInit((char*)[resourcePath UTF8String], (char*)[productVersion UTF8String]);
GoStart();

mod = [[LauncherState alloc] init];
Expand Down
2 changes: 1 addition & 1 deletion launcher/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@


- (void)setState;

- (void)setNetworkConfig;
@end

#endif /* model_h */
16 changes: 12 additions & 4 deletions launcher/Model.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ - (id) init
}

- (void)notificationHandlerState:(NSNotification *) notification{
// NSLog(@"notificationHandlerState > %@", notification.userInfo);

self.imageName = notification.userInfo[@"imageName"];
self.hasUpdate = notification.userInfo[@"hasUpdate"];
self.currentVersion = notification.userInfo[@"currentVersion"];
Expand All @@ -54,7 +56,6 @@ - (void)notificationHandlerState:(NSNotification *) notification{
self.downloadFiles = notification.userInfo[@"downloadFiles"];
self.installDocker = notification.userInfo[@"installDocker"];


[[NSNotificationCenter defaultCenter] postNotificationName:@"new_state" object:nil];
}

Expand Down Expand Up @@ -104,13 +105,20 @@ - (void)notificationHandlerModal:(NSNotification *) notification{
- (void)setState {
SetStateArgs s;

s.autoUpgrade = [self.autoUpgrade boolValue];
s.enabled = [self.enabled boolValue];

GoSetState(&s);
}

- (void)setNetworkConfig {
SetStateArgs s;

s.enablePortForwarding = [self.enablePortForwarding boolValue];
s.portRangeBegin = [self.portBegin intValue];
s.portRangeEnd = [self.portEnd intValue];
s.autoUpgrade = [self.autoUpgrade boolValue];
s.enabled = [self.enabled boolValue];

GoSetStateAndConfig(&s);
GoSetNetworkConfig(&s);
}

@end
2 changes: 1 addition & 1 deletion launcher/NetworkingModalDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (IBAction)okPressed:(id)sender
mod.portBegin = @(portBegin);
mod.portEnd = @(portEnd);
mod.enablePortForwarding = [NSNumber numberWithBool:[self.checkBox integerValue]];
[mod setState];
[mod setNetworkConfig];

[self close];
[NSApp stopModalWithCode:NSModalResponseOK];
Expand Down

0 comments on commit 5717e86

Please sign in to comment.