//
//  TeXDistLoad.m
//  TeXDist
//
//  Created by itexmac2 on 20/06/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TeXDistLoad.h"
#import "TeXDistCommon.h"


@implementation TeXDistLoad
+ (void)setup;
{
    BOOL mute = NO;
    for (NSString * argument in [[NSProcessInfo processInfo]arguments]) {
        if ([argument isEqual:TeXDistUtilitySubTask]) {
            mute = YES;
            break;
        }
    }
    if (NOT mute) {
        NSLog(@"===========================================");
        NSLog(@"TeXDist Preference Pane, Utility and Tools:");
        NSLog(@"-------------------------------------------");
    }
    NSString * N = (NSString *)CFPreferencesCopyValue ((CFStringRef)TeXDistLogLevelPreferenceKey,(CFStringRef)TeXDistPreferenceID,kCFPreferencesCurrentUser,kCFPreferencesAnyHost);
    if ([N respondsToSelector:@selector(integerValue)] && (TeXDistLogLevel = N.integerValue)) {
            if (NOT mute) {
            NSLog(@"-> Starting displaying informations up to (and including) level %lu", (long)(TeXDistLogLevel-1));
            NSLog(@"-> To deactivate the verbose mode, issue in the terminal the command below\n"
            @"   defaults delete \"%@\" \"%@\"\n"
            @"-> To change the verbosity level, issue in the terminal the command below\n"
            @"   defaults write \"%@\" \"%@\" LEVEL\n"
            @"where LEVEL is a nonnegative integer",
            TeXDistPreferenceID,
            TeXDistLogLevelPreferenceKey,
            TeXDistPreferenceID,
            TeXDistLogLevelPreferenceKey);
        }
    } else if (NOT mute) {
        NSLog(@"-> To activate a verbose mode, issue in the terminal the command below\n"
        @"   defaults write \"%@\" \"%@\" LEVEL\n"
        @"where LEVEL is a nonnegative integer",
        TeXDistPreferenceID,
        TeXDistLogLevelPreferenceKey);
    }

    if (N) {
        CFRelease((CFPropertyListRef)N);
    }
    return;
}
@end


