<commit_before>#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "SettingsManager.h"
#import "Preferences.h"
#import "LocationManager.h"

#include <sys/xattr.h>

#include "Framework.h"
#include "../../../platform/settings.hpp"

@implementation MapsAppDelegate

@synthesize m_mapViewController;
@synthesize m_locationManager;

#define V2_0_TAG "2.0"
#define FIRST_LAUNCH_KEY "FirstLaunchOnVersion"

+ (MapsAppDelegate *) theApp
{
  return [[UIApplication sharedApplication] delegate];
}

/// @todo Check is it still necessary?
- (void) onFirstLaunchCheck
{
  // Called only for V1.0.1 -> V2.0 upgrade
  string v;
  if (!Settings::Get(FIRST_LAUNCH_KEY, v))
  {
    // Scan all files in the Documents directory and do necessary actions with them
    NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString * documentsDirectoryPath = [paths objectAtIndex:0];
    NSFileManager * fileManager = [NSFileManager defaultManager];

    // Delete old travel guide temporary files
    [fileManager removeItemAtPath:[documentsDirectoryPath stringByAppendingPathComponent:@"index.stamp"] error:nil];
    [fileManager removeItemAtPath:[documentsDirectoryPath stringByAppendingPathComponent:@"index.idx"] error:nil];

    // Disable iCloud backup for downloaded ".mwm" maps.
    char const * attrName = "com.apple.MobileBackup";
    NSArray * files = [fileManager contentsOfDirectoryAtPath:documentsDirectoryPath error:nil];
    for (NSUInteger i = 0; i < [files count]; ++i)
    {
      NSString * fileName = [files objectAtIndex:i];

      if ([fileName rangeOfString:@DATA_FILE_EXTENSION].location != NSNotFound)
      {
        // Disable iCloud backup
        u_int8_t attrValue = 1;
        int result = setxattr([[documentsDirectoryPath stringByAppendingPathComponent:fileName] UTF8String], attrName, &attrValue, sizeof(attrValue), 0, 0);

        if (result == 0)
          NSLog(@"Disabled iCloud backup for %@", fileName);
        else
          NSLog(@"Error %d while disabling iCloud backup for %@", errno, fileName);
      }
    }

    Settings::Set(FIRST_LAUNCH_KEY, string(V2_0_TAG));
  }
}

- (void) applicationWillTerminate: (UIApplication *) application
{
	[m_mapViewController OnTerminate];
}

- (void) applicationDidEnterBackground: (UIApplication *) application
{
	[m_mapViewController OnEnterBackground];
}

- (void) applicationWillEnterForeground: (UIApplication *) application
{
  [m_mapViewController OnEnterForeground];
}

- (SettingsManager *)settingsManager
{
  if (!m_settingsManager)
    m_settingsManager = [[SettingsManager alloc] init];
  return m_settingsManager;
}

- (void) dealloc
{
  [m_locationManager release];
  [m_settingsManager release];
  self.m_mapViewController = nil;
  [m_navController release];
  [m_window release];
  [super dealloc];

  // Global cleanup
  DeleteFramework();
}

- (void) disableStandby
{
  ++m_standbyCounter;
  [UIApplication sharedApplication].idleTimerDisabled = YES;
}

- (void) enableStandby
{
  --m_standbyCounter;
  if (m_standbyCounter <= 0)
  {
    [UIApplication sharedApplication].idleTimerDisabled = NO;
    m_standbyCounter = 0;
  }
}

- (void) disableDownloadIndicator
{
  --m_activeDownloadsCounter;
  if (m_activeDownloadsCounter <= 0)
  {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    m_activeDownloadsCounter = 0;
  }
}

- (void) enableDownloadIndicator
{
  ++m_activeDownloadsCounter;
  [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

// We process memory warnings in MapsViewController
//- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
//{
//  NSLog(@"applicationDidReceiveMemoryWarning");
//}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [m_mapViewController OnEnterForeground];

  [self onFirstLaunchCheck];

  [Preferences setup:m_mapViewController];
  m_locationManager = [[LocationManager alloc] init];

  m_navController = [[UINavigationController alloc] initWithRootViewController:m_mapViewController];
  m_navController.navigationBarHidden = YES;
  m_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  m_window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  m_window.clearsContextBeforeDrawing = NO;
  m_window.multipleTouchEnabled = YES;
  [m_window setRootViewController:m_navController];
  [m_window makeKeyAndVisible];

  return [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey] != nil;
}

// handleOpenURL is deprecaed now.
// http://stackoverflow.com/questions/3612460/lauching-app-with-url-via-uiapplicationdelegates-handleopenurl-working-under
/*
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
  NSString * text = [[url absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  return [m_mapViewController OnProcessURL:text];
}
*/

@end
<commit_msg>[iOS] Remove dummy code (migrating from 1.0 to 2.0).<commit_after>#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "SettingsManager.h"
#import "Preferences.h"
#import "LocationManager.h"

#include <sys/xattr.h>

#include "Framework.h"
#include "../../../platform/settings.hpp"

@implementation MapsAppDelegate

@synthesize m_mapViewController;
@synthesize m_locationManager;


+ (MapsAppDelegate *) theApp
{
  return [[UIApplication sharedApplication] delegate];
}

- (void) applicationWillTerminate: (UIApplication *) application
{
	[m_mapViewController OnTerminate];
}

- (void) applicationDidEnterBackground: (UIApplication *) application
{
	[m_mapViewController OnEnterBackground];
}

- (void) applicationWillEnterForeground: (UIApplication *) application
{
  [m_mapViewController OnEnterForeground];
}

- (SettingsManager *)settingsManager
{
  if (!m_settingsManager)
    m_settingsManager = [[SettingsManager alloc] init];
  return m_settingsManager;
}

- (void) dealloc
{
  [m_locationManager release];
  [m_settingsManager release];
  self.m_mapViewController = nil;
  [m_navController release];
  [m_window release];
  [super dealloc];

  // Global cleanup
  DeleteFramework();
}

- (void) disableStandby
{
  ++m_standbyCounter;
  [UIApplication sharedApplication].idleTimerDisabled = YES;
}

- (void) enableStandby
{
  --m_standbyCounter;
  if (m_standbyCounter <= 0)
  {
    [UIApplication sharedApplication].idleTimerDisabled = NO;
    m_standbyCounter = 0;
  }
}

- (void) disableDownloadIndicator
{
  --m_activeDownloadsCounter;
  if (m_activeDownloadsCounter <= 0)
  {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    m_activeDownloadsCounter = 0;
  }
}

- (void) enableDownloadIndicator
{
  ++m_activeDownloadsCounter;
  [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

// We process memory warnings in MapsViewController
//- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
//{
//  NSLog(@"applicationDidReceiveMemoryWarning");
//}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [m_mapViewController OnEnterForeground];

  [Preferences setup:m_mapViewController];
  m_locationManager = [[LocationManager alloc] init];

  m_navController = [[UINavigationController alloc] initWithRootViewController:m_mapViewController];
  m_navController.navigationBarHidden = YES;
  m_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  m_window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  m_window.clearsContextBeforeDrawing = NO;
  m_window.multipleTouchEnabled = YES;
  [m_window setRootViewController:m_navController];
  [m_window makeKeyAndVisible];

  return [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey] != nil;
}

// handleOpenURL is deprecaed now.
// http://stackoverflow.com/questions/3612460/lauching-app-with-url-via-uiapplicationdelegates-handleopenurl-working-under
/*
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
  NSString * text = [[url absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  return [m_mapViewController OnProcessURL:text];
}
*/

@end

{'fraction_non_alphanumeric': 0.10881642512077294, 'fraction_numerical': 0.005676328502415459, 'mean_word_length': 5.561806656101426, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2123540', 'n_tokens_mistral': 2589, 'n_tokens_neox': 2456, 'n_words': 487}