Skip to content

Commit

Permalink
Merge b963519 into ab22ca2
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster authored Nov 20, 2020
2 parents ab22ca2 + b963519 commit 441c824
Show file tree
Hide file tree
Showing 60 changed files with 2,218 additions and 97 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
[submodule "lib/statsd-cpp"]
path = lib/statsd-cpp
url = git@github.com:voiceip/statsd-cpp.git
[submodule "tinyphone-osx/vendor/boost"]
path = tinyphone-osx/vendor/boost
url = git@github.com:faithfracture/Apple-Boost-BuildScript.git
27 changes: 27 additions & 0 deletions tinyphone-osx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Gcc Patch
/*.gcno
*.dmg
796 changes: 796 additions & 0 deletions tinyphone-osx/Tinyphone.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
@@ -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>PreviewsEnabled</key>
<false/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1110"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B3DDA55825515DF700D269C9"
BuildableName = "Tinyphone.app"
BlueprintName = "Tinyphone"
ReferencedContainer = "container:Tinyphone.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B3DDA55825515DF700D269C9"
BuildableName = "Tinyphone.app"
BlueprintName = "Tinyphone"
ReferencedContainer = "container:Tinyphone.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B3DDA55825515DF700D269C9"
BuildableName = "Tinyphone.app"
BlueprintName = "Tinyphone"
ReferencedContainer = "container:Tinyphone.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
9 changes: 9 additions & 0 deletions tinyphone-osx/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Install appdmg
# npm install -g appdmg


# Run program
rm -f tinyphone.dmg
appdmg release-spec.json tinyphone.dmg
10 changes: 10 additions & 0 deletions tinyphone-osx/release-spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"title": "Tinyphone",
"background": "",
"background-color" : "#d6c8c8",
"icon-size": 80,
"contents": [
{ "x": 192, "y": 200, "type": "file", "path": "release/Tinyphone.app" },
{ "x": 448, "y": 200, "type": "link", "path": "/Applications" }
]
}
5 changes: 5 additions & 0 deletions tinyphone-osx/src/Tinyphone-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#include "app.h"
23 changes: 23 additions & 0 deletions tinyphone-osx/src/Tinyphone-C-Interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Tinyphone-C-Interface.h
// Tinyphone
//
// Created by Kinshuk Bairagi on 04/11/20.
// Copyright © 2020 Kinshuk Bairagi. All rights reserved.
//

#ifndef Tinyphone_C_Interface_h
#define Tinyphone_C_Interface_h

// This is the C "ShowOSXAlert" function that will be used
// to invoke a specific Objective-C method FROM C++
void ShowOSXAlert (const char *message, bool blocking);

const char* GetAppSupportDirectory();

const char* GetOSXProductVersion();

const char* GetResourceFilePath(const char * name);


#endif /* Tinyphone_C_Interface_h */
26 changes: 26 additions & 0 deletions tinyphone-osx/src/Tinyphone-OC.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NSRunAlertPanel.hpp
// Tinyphone
//
// Created by Kinshuk Bairagi on 04/11/20.
// Copyright © 2020 Kinshuk Bairagi. All rights reserved.
//
#import "Tinyphone-C-Interface.h"
#include <string>

//// An Objective-C class that needs to be accessed from C++
@interface TinyphoneOC : NSObject
{

}

// The Objective-C member function you want to call from C++
- (void) ShowAlert:(NSString *) message;

- (const char *) GetAppSupportDirectory;

- (const char *) GetProductVersion;

@end


75 changes: 75 additions & 0 deletions tinyphone-osx/src/Tinyphone-OC.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// NSRunAlertPanel.mmm
// Tinyphone
//
// Created by Kinshuk Bairagi on 04/11/20.
// Copyright © 2020 Kinshuk Bairagi. All rights reserved.
//


#include <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <AppKit/AppKit.h>
#include "Tinyphone-OC.hpp"
#include "Tinyphone-C-Interface.h"

@implementation TinyphoneOC

- (void)ShowAlert: (NSString *) dataPayload {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText: @"Error"];
[alert addButtonWithTitle:@"OK"];
[alert setInformativeText:dataPayload];
[alert setAlertStyle:NSAlertStyleCritical];
[alert runModal];
}

- (const char *) GetAppSupportDirectory {
NSError *error;
NSFileManager *manager = [NSFileManager defaultManager];
NSURL *applicationSupport = [manager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:false error:&error];
NSString *identifier = [[NSBundle mainBundle] bundleIdentifier];
// NSString *identifier = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
NSURL *folder = [applicationSupport URLByAppendingPathComponent:identifier];
[manager createDirectoryAtURL:folder withIntermediateDirectories:true attributes:nil error:&error];
NSString *myString = folder.path;
return myString.UTF8String;
}

- (const char *) GetProductVersion {
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"];
return version.UTF8String;
}

@end

void ShowOSXAlert(const char *dataPayload, bool blocking) {
NSString *convertedString = [[NSString alloc] initWithCString: dataPayload encoding:NSUTF8StringEncoding];
TinyphoneOC *myInstance = [[TinyphoneOC alloc] init];
// [myInstance ShowAlert: convertedString];
[myInstance performSelectorOnMainThread:@selector(ShowAlert:) withObject:convertedString waitUntilDone: blocking ? YES : NO];
}


const char* GetAppSupportDirectory(){
TinyphoneOC *myInstance = [[TinyphoneOC alloc] init];
return [myInstance GetAppSupportDirectory];
}

const char* GetOSXProductVersion(){
TinyphoneOC *myInstance = [[TinyphoneOC alloc] init];
return [myInstance GetProductVersion];
}

const char* GetResourceFilePath(const char * name){
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("config.json"), NULL, NULL);
if (appUrlRef != nullptr){
CFStringRef filePathRef = CFURLCopyPath(appUrlRef);
const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8);
CFRelease(filePathRef);
CFRelease(appUrlRef);
return filePath;
}
return NULL;
}
26 changes: 26 additions & 0 deletions tinyphone-osx/src/app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#ifdef __cplusplus
#include <string>
extern "C" {
#endif

struct UIAccountInfo{
char * name;
char * status;
int active;
int primary;
};
typedef struct UIAccountInfo UIAccountInfo;

struct UIAccountInfoArray {
int count;
UIAccountInfo accounts[10];
};

void Start();
void Stop();
struct UIAccountInfoArray Accounts();

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 441c824

Please sign in to comment.