app_delegate.mm 2.22 KB
Newer Older
1
/*
2
 * Copyright (C) 2014-2019 CZ.NIC
3 4 5 6 7 8 9 10 11 12 13 14
 *
 * This program 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.
 *
 * This program 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
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21 22 23
 *
 * In addition, as a special exception, the copyright holders give
 * permission to link the code of portions of this program with the
 * OpenSSL library under certain conditions as described in each
 * individual source file, and distribute linked combinations including
 * the two.
 */

24 25
#include <QtCore>

26 27 28
#include "ios/src/app_delegate.h"
#include "ios/src/qt_app_delegate.h"
#include "src/qml_interaction/interaction_zfo_file.h"
29 30 31

@implementation QtAppDelegate

32 33
/* Pointer to InteractionZfoFile object */
InteractionZfoFile *interactionZfoFilePtr;
34

35 36
+(QtAppDelegate *)sharedQtAppDelegate
{
37 38 39 40 41 42
	static dispatch_once_t pred;
	static QtAppDelegate *shared = nil;
	dispatch_once(&pred, ^{shared = [[super alloc] init];});
	return shared;
}

43 44
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
45 46 47 48 49 50 51
{
	Q_UNUSED(application);
	Q_UNUSED(sourceApplication);
	Q_UNUSED(annotation);

	if (url != nil && [url isFileURL]) {
		if ([[url pathExtension] isEqualToString:@"zfo"]) {
52
			//NSLog(@"URL:%@", [url absoluteString]);
53 54
			if (Q_NULLPTR != interactionZfoFilePtr) {
				interactionZfoFilePtr->openZfoFile(QString::fromNSString(url.path));
55 56 57 58 59 60
			}
		}
	}
	return YES;
}

61
void QtAppDelegateInitialize(InteractionZfoFile *interactionZfoFile)
62
{
63 64
	/* Pointer to InteractionZfoFile object */
	interactionZfoFilePtr = interactionZfoFile;
65
	/* Init share app delegate with iOS */
66
	[[UIApplication sharedApplication] setDelegate:[QtAppDelegate sharedQtAppDelegate]];
67
	//NSLog(@"Created a new appdelegate");
68 69 70
}

@end