File: AppDelegate.m

package info (click to toggle)
zipper.app 1.5-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 644 kB
  • sloc: objc: 3,829; makefile: 11
file content (110 lines) | stat: -rw-r--r-- 2,895 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*

  AppDelegate.m
  Zipper

  Copyright (C) 2012 Free Software Foundation, Inc

  Authors: Dirk Olmes <dirk@xanthippe.ping.de>
           Riccardo Mottola <rm@gnu.org>

  This application 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 2 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

 */

#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "AppDelegate.h"
#import "ZipArchive.h"
#import "TarArchive.h"
#import "RarArchive.h"
#import "LhaArchive.h"
#import "LzxArchive.h"
#import "GzipArchive.h"
#import "SevenZipArchive.h"
#import "ZooArchive.h"
#import "ArjArchive.h"
#import "AceArchive.h"
#import "PreferencesController.h"
#import "ArchiveService.h"

@implementation AppDelegate : NSObject

/**
 * load all Archive subclasses so that they can register their supported file extensions
 */
+ (void)initialize
{
	[LhaArchive class];
	[RarArchive class];
	[TarArchive class];
	[ZipArchive class];
	[LzxArchive class];
	[GzipArchive class];
	[SevenZipArchive class];
	[ZooArchive class];
	[ArjArchive class];
	[AceArchive class];
}

//------------------------------------------------------------------------------
// NSApp delegate methods
//------------------------------------------------------------------------------

- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)theApplication
{
  return NO;
}

- (void)applicationDidFinishLaunching:(NSNotification *)note
{	
	[NSApp setServicesProvider:[[ArchiveService alloc] init]];
}

/**
 * do cleanup, especially remove temporary files that were created while we ran
 */
-(void)applicationWillTerminate:(NSNotification *)aNotification
{
	NSEnumerator *cursor;
	NSString *element;
	
	// clean up all temporary Zipper directories
	cursor = [[[NSFileManager defaultManager] directoryContentsAtPath:NSTemporaryDirectory()]
		objectEnumerator];
	while ((element = [cursor nextObject]) != nil)
	{
		if ([element hasPrefix:@"Zipper"])
		{
			NSString *path;
			
			path = [NSString pathWithComponents:[NSArray arrayWithObjects:NSTemporaryDirectory(),
				element, nil]];
			[[NSFileManager defaultManager] removeFileAtPath:path handler:nil];
		}
	}
}

//------------------------------------------------------------------------------
// action methods
//------------------------------------------------------------------------------
- (void)showPreferences:(id)sender
{
  PreferencesController *prefController;

  prefController = [[PreferencesController alloc] init];

  [prefController showPreferencesPanel];

  [prefController release];
}
	
@end