//
//  PWLicenseManager.h
//
//  Created by Andreas Känner on 06.07.06.
//  Copyright 2006 __MyCompanyName__. All rights reserved.
//
//	Der PWLicenseManager dient nur zur Verwaltung der Lizenzen.
//	Die Validierung passiert an anderer Stelle.
//

#import <Cocoa/Cocoa.h>
#import "PWLicenseKit-Obfuscating.h"

@class PWLicenseAttributesView;
@class PWLicenseCenter;
@class PWLicenseManagerSettingsView;

@interface PWLicenseManager : NSObject
{
	NSArray					*topLevelNibObjects;
	NSURL					*storeURL;
	NSURL					*registrationURL;
	NSURL					*lostLicenseURL;
    NSString				*subtitle;
	BOOL					addLicensePanelSizeChanged;
	BOOL					registrationPanelSizeChanged;
	NSURLConnection			*connection;
	NSMutableData			*responseData;
	NSString				*hash;
	NSArray					*requiredFeatures;
	NSString				*product;
	NSString				*appName;
	NSSearchPathDomainMask	supportDirectoryDomain;
	BOOL					disabled;
	id						delegate;
	BOOL					isUsedInSheet;
	PWLicenseCenter			*licenseCenter;

	IBOutlet PWLicenseManagerSettingsView	*view;
	IBOutlet NSTableColumn					*expiresColumn;
	IBOutlet NSArrayController				*licensesArrayController;
	IBOutlet NSArrayController				*featuresArrayController;
	IBOutlet NSTabView						*tabView;
	IBOutlet NSPanel						*addLicensePanel;
	IBOutlet NSPanel						*registrationPanel;
	IBOutlet NSView							*attributesPlaceholder;
	IBOutlet NSView							*attributesPlaceholderInRegistrationPanel;
	IBOutlet PWLicenseAttributesView		*attributesView;
	IBOutlet NSProgressIndicator			*registrationProgressIndicator;
	IBOutlet NSTextField					*company;
	IBOutlet NSTextField					*street;
	IBOutlet NSTextField					*zip;
	IBOutlet NSTextField					*city;
	IBOutlet NSTextField					*state;		
	IBOutlet NSTextField					*country;	
	IBOutlet NSTextField					*email;
	IBOutlet NSTextField					*phone;
	IBOutlet NSTextField					*fax;
	IBOutlet NSTextView						*questions;
	IBOutlet NSTextField					*registrationDialogTitle;
	IBOutlet NSTextField					*dialogTitle;
	IBOutlet NSTextField					*dialogSubtitle;	
	IBOutlet NSTextField					*companyIdentifier;
	IBOutlet NSTextField					*ownerIdentifier;
	IBOutlet NSTextField					*emailIdentifier;
	IBOutlet NSImageView					*imageView;	
	IBOutlet NSButton						*closeButton;
	IBOutlet NSButton						*buyButton;
	IBOutlet NSButton						*registerButton;	
	IBOutlet NSButton						*closeButton2;
	IBOutlet NSButton						*buyButton2;
	IBOutlet NSButton						*registerButton2;		
	IBOutlet NSButton						*lostLicenseButton;		
	IBOutlet NSButton						*lostLicenseButton2;		
	IBOutlet NSTableView					*licensesTableView;
	IBOutlet NSTableView					*featuresTableView;
}

- (void)dispose;

- (id) initWithLicenseCenter:(PWLicenseCenter*)aLicenseCenter
					storeURL:(NSURL*)aStoreURL 
			 registrationURL:(NSURL*)aRegistrationURL
              lostLicenseURL:(NSURL*)aLostLicenseURL
					subtitle:(NSString*)subtitle
					 product:(NSString*)theProduct
			requiredFeatures:(NSArray*)theRequiredFeatures;

// Setter

- (void)setStoreURL:(NSURL*)url;
- (void)setRegistrationURL:(NSURL*)url;
- (void)setAppName:(NSString*)appName;
- (void)setIsUsedInSheet:(BOOL)flag;
- (void)setIcon:(NSImage*)icon;
- (void)setPreferredApplicationSupportDirectoryDomain:(NSSearchPathDomainMask)domain;
- (void)setEnabled:(BOOL)enabled;
- (void)setDelegate:(id)object;
- (void)setSupportDirectoryDomain:(int)domain;

// Getter

- (NSURL*)storeURL;
- (NSURL*)registrationURL;
- (NSString*)appName;
- (PWLicenseAttributesView*)attributesView;
- (NSView*)settingsView;
- (id)delegate;

// Actions

- (IBAction)deleteLicense:(id)sender;
- (IBAction)addLicense:(id)sender;
- (IBAction)buyLicense:(id)sender;
- (IBAction)registerLicense:(id)sender;
- (IBAction)loadLicense:(id)sender;
- (IBAction)okAddLicenseDialog:(id)sender;
- (IBAction)cancelAddLicenseDialog:(id)sender;
- (IBAction)cancelRegisterDialog:(id)sender;
- (IBAction)startRegistration:(id)sender;
- (IBAction)closeSheet:(id)sender;
- (IBAction)lostLicense:(id)sender;

// Other

- (void) checkLicenses;
- (BOOL) addLicenseFileAtPath:(NSString*)path;
- (void) makeFirstResponder;

@end

@protocol PWLicenseManagerDelegate
	
- (BOOL)createDirectoriesAtPath:(NSString*)path forLicenseManager:(PWLicenseManager*)licenseManager;
- (BOOL)copyPath:(NSString*)sourcePath toPath:(NSString*)destinationPath forLicenseManager:(PWLicenseManager*)licenseManager;
- (BOOL)removeFileAtPath:(NSString*)path forLicenseManager:(PWLicenseManager*)licenseManager;
- (BOOL)canDeleteFileAtPath:(NSString*)path forLicenseManager:(PWLicenseManager*)licenseManager;

@end
