Bah did last commit wrong. Only added the password view.
Added support for handling archives with passwords.
This commit is contained in:
parent
9452ac9c87
commit
e9ad5c518c
|
@ -12,7 +12,8 @@
|
|||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
D488BC6810AF437B00B3451C /* libunrar.so in Frameworks */ = {isa = PBXBuildFile; fileRef = D488BC6710AF437B00B3451C /* libunrar.so */; };
|
||||
D488BCC110AF49C700B3451C /* libunrar.so in CopyFiles */ = {isa = PBXBuildFile; fileRef = D488BC6710AF437B00B3451C /* libunrar.so */; };
|
||||
D488BDB710B0160300B3451C /* OverwriteFilesDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = D488BDB610B0160300B3451C /* OverwriteFilesDialog.xib */; };
|
||||
D488BDB710B0160300B3451C /* PasswordDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = D488BDB610B0160300B3451C /* PasswordDialog.xib */; };
|
||||
D488BE5510B05F3800B3451C /* PasswordView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D488BE5410B05F3800B3451C /* PasswordView.xib */; };
|
||||
D4A49691105435BE00BE38AE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||
D4A49692105435C100BE38AE /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
|
||||
D4A96E2110545E9A0091ECB4 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4A96E2010545E9A0091ECB4 /* Carbon.framework */; };
|
||||
|
@ -55,7 +56,8 @@
|
|||
8D1107310486CEB800E47090 /* QuietUnrar-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "QuietUnrar-Info.plist"; sourceTree = "<group>"; };
|
||||
8D1107320486CEB800E47090 /* QuietUnrar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuietUnrar.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D488BC6710AF437B00B3451C /* libunrar.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libunrar.so; path = libunrar/libunrar.so; sourceTree = "<group>"; };
|
||||
D488BDB610B0160300B3451C /* OverwriteFilesDialog.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = OverwriteFilesDialog.xib; sourceTree = "<group>"; };
|
||||
D488BDB610B0160300B3451C /* PasswordDialog.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PasswordDialog.xib; sourceTree = "<group>"; };
|
||||
D488BE5410B05F3800B3451C /* PasswordView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PasswordView.xib; sourceTree = "<group>"; };
|
||||
D4A495741054177300BE38AE /* arccmt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arccmt.cpp; path = libunrar/arccmt.cpp; sourceTree = "<group>"; };
|
||||
D4A495751054177300BE38AE /* archive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = archive.cpp; path = libunrar/archive.cpp; sourceTree = "<group>"; };
|
||||
D4A495761054177300BE38AE /* archive.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = archive.hpp; path = libunrar/archive.hpp; sourceTree = "<group>"; };
|
||||
|
@ -248,10 +250,11 @@
|
|||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D488BE5410B05F3800B3451C /* PasswordView.xib */,
|
||||
8D1107310486CEB800E47090 /* QuietUnrar-Info.plist */,
|
||||
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
|
||||
1DDD58140DA1D0A300B32029 /* MainMenu.xib */,
|
||||
D488BDB610B0160300B3451C /* OverwriteFilesDialog.xib */,
|
||||
D488BDB610B0160300B3451C /* PasswordDialog.xib */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
|
@ -453,7 +456,8 @@
|
|||
files = (
|
||||
D4A49692105435C100BE38AE /* MainMenu.xib in Resources */,
|
||||
D4A49691105435BE00BE38AE /* InfoPlist.strings in Resources */,
|
||||
D488BDB710B0160300B3451C /* OverwriteFilesDialog.xib in Resources */,
|
||||
D488BDB710B0160300B3451C /* PasswordDialog.xib in Resources */,
|
||||
D488BE5510B05F3800B3451C /* PasswordView.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -264,6 +264,7 @@
|
|||
<key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
|
||||
<array>
|
||||
<string>29B97314FDCFA39411CA2CEA</string>
|
||||
<string>080E96DDFE201D6D7F000001</string>
|
||||
<string>29B97317FDCFA39411CA2CEA</string>
|
||||
<string>1C37FBAC04509CD000000102</string>
|
||||
<string>1C37FAAC04509CD000000102</string>
|
||||
|
@ -272,6 +273,7 @@
|
|||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>3</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
|
@ -326,7 +328,7 @@
|
|||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>D488BE3510B04D8D00B3451C</string>
|
||||
<string>D488BEE510B0769000B3451C</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>D4A4963610541A1C00BE38AE</string>
|
||||
|
@ -344,8 +346,8 @@
|
|||
<string>D488BD8E10AF7F6900B3451C</string>
|
||||
<string>D488BD8F10AF7F6900B3451C</string>
|
||||
<string>D488BD9010AF7F6900B3451C</string>
|
||||
<string>D488BE2510B03F8900B3451C</string>
|
||||
<string>D488BE2610B03F8900B3451C</string>
|
||||
<string>D488BEE010B075CA00B3451C</string>
|
||||
<string>D488BEE110B075CA00B3451C</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,12 +25,18 @@ enum
|
|||
|
||||
@interface QuietUnrarAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
NSWindow *window;
|
||||
NSView *passwordView;
|
||||
|
||||
NSSecureTextField * passwordField;
|
||||
}
|
||||
|
||||
@property (assign) IBOutlet NSWindow *window;
|
||||
@property (assign) IBOutlet NSView *passwordView;
|
||||
@property (assign) IBOutlet NSSecureTextField * passwordField;
|
||||
|
||||
- (BOOL) extractRarWith:(NSString *) filename;
|
||||
- (BOOL) shouldFileBeReplaced:(NSString *) filename;
|
||||
- (void) alertUserOfMissing:(const char *) volume;
|
||||
- (NSString *) requestArchivePassword:(id) archive;
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
#import "QuietUnrarAppDelegate.h"
|
||||
#import "libunrar/dll.hpp"
|
||||
|
||||
QuietUnrarAppDelegate * quietUnrar;
|
||||
QuietUnrarAppDelegate * quietUnrar;
|
||||
|
||||
int changeVolume(char * volumeName, int mode);
|
||||
int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM parameterTwo);
|
||||
|
||||
int changeVolume(char * volumeName, int mode) {
|
||||
NSLog(@"Volume Name: %s and mode %d", volumeName, mode);
|
||||
//NSLog(@"Volume Name: %s and mode %d", volumeName, mode);
|
||||
|
||||
if (mode == RAR_VOL_ASK)
|
||||
{
|
||||
|
@ -26,18 +26,23 @@ int changeVolume(char * volumeName, int mode) {
|
|||
}
|
||||
|
||||
int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM parameterTwo) {
|
||||
NSLog(@"Callback Function, args: %d, %D, %D, %D", message, userData, parameterOne, parameterTwo);
|
||||
if (message == UCM_NEEDPASSWORD) {
|
||||
//NSLog(@"Archive password required");
|
||||
[(QuietUnrarAppDelegate *) quietUnrar requestArchivePassword: (id) userData];
|
||||
|
||||
}
|
||||
//NSLog(@"Callback Function, args: %d, %D, %D, %D", message, userData, parameterOne, parameterTwo);
|
||||
}
|
||||
|
||||
|
||||
@implementation QuietUnrarAppDelegate
|
||||
|
||||
@synthesize window;
|
||||
@synthesize window, passwordView, passwordField;
|
||||
|
||||
- (void) applicationWillFinishLaunching:(NSNotification *)notification {
|
||||
KeyMap map;
|
||||
GetKeys(map);
|
||||
NSLog(@"Shift or Right Shift: %d", KEYMAP_GET(map, kVKC_Shift) || KEYMAP_GET(map, kVKC_rShift));
|
||||
//NSLog(@"Shift or Right Shift: %d", KEYMAP_GET(map, kVKC_Shift) || KEYMAP_GET(map, kVKC_rShift));
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
|
@ -51,7 +56,7 @@ int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM
|
|||
//}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename {
|
||||
NSLog(@"openFile: %@", filename);
|
||||
//NSLog(@"openFile: %@", filename);
|
||||
|
||||
[self extractRarWith:filename];
|
||||
|
||||
|
@ -83,11 +88,11 @@ int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM
|
|||
// Open the Archive for extraction, we set the open result to 3 so we can see it has changed
|
||||
struct RAROpenArchiveData arcData = { filenameCString, RAR_OM_EXTRACT, 3, &commentBuffer[0], BUF_LEN, 0, 0};
|
||||
HANDLE archive = RAROpenArchive(&arcData);
|
||||
NSLog(@"Opening Archive %s with result %d", filenameCString, arcData.OpenResult);
|
||||
//NSLog(@"Opening Archive %s with result %d", filenameCString, arcData.OpenResult);
|
||||
|
||||
// set call backs for if password needed or need to change volume
|
||||
RARSetChangeVolProc(archive, &changeVolume);
|
||||
//RARSetCallback(archive, &callbackFunction, 0);
|
||||
RARSetCallback(archive, &callbackFunction, (LPARAM)archive);
|
||||
|
||||
//
|
||||
struct RARHeaderData headerData;
|
||||
|
@ -95,7 +100,7 @@ int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM
|
|||
NSString * currentFilename;
|
||||
|
||||
while (RARReadHeader(archive, &headerData) != ERAR_END_ARCHIVE) {
|
||||
NSLog(@"Attempting to extract %s to %@", headerData.FileName, defaultFolderToExtractTo);
|
||||
//NSLog(@"Attempting to extract %s to %@", headerData.FileName, defaultFolderToExtractTo);
|
||||
|
||||
int processResult = 0;
|
||||
BOOL extractFile = YES;
|
||||
|
@ -115,10 +120,10 @@ int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM
|
|||
// NSLog(@"Last filename %@, currentFilename %@, equality %d", lastExtractedFilename, currentFilename, [lastExtractedFilename isEqualToString:currentFilename]);
|
||||
|
||||
if (extractFile) {
|
||||
NSLog(@"...Extracting");
|
||||
//NSLog(@"...Extracting");
|
||||
processResult = RARProcessFile(archive, RAR_EXTRACT, (char *) [defaultFolderToExtractTo cStringUsingEncoding:NSISOLatin1StringEncoding], NULL);
|
||||
} else {
|
||||
NSLog(@"...Skipping as already exists");
|
||||
//NSLog(@"...Skipping as already exists");
|
||||
processResult = RARProcessFile(archive, RAR_SKIP, NULL, NULL);
|
||||
// Curious behavior by the lib, you have SKIP a file number of times (4 in my test example) before
|
||||
// it is skipped. However if you extract it is only processed once.
|
||||
|
@ -136,7 +141,7 @@ int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM
|
|||
}
|
||||
|
||||
int closeResult = RARCloseArchive(archive);
|
||||
NSLog(@"Closing Archive %s with result %d", filenameCString, closeResult);
|
||||
//NSLog(@"Closing Archive %s with result %d", filenameCString, closeResult);
|
||||
|
||||
return extractionSuccessful;
|
||||
}
|
||||
|
@ -162,7 +167,7 @@ int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM
|
|||
}
|
||||
|
||||
- (void) alertUserOfMissing:(const char *) volume {
|
||||
NSLog(@"Alerting user of missing volume");
|
||||
//NSLog(@"Alerting user of missing volume");
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert setMessageText:[NSString stringWithFormat:@"Archive part %s is missing.", volume]];
|
||||
|
@ -174,4 +179,26 @@ int callbackFunction(UINT message, LPARAM userData, LPARAM parameterOne, LPARAM
|
|||
[alert release];
|
||||
}
|
||||
|
||||
- (NSString *) requestArchivePassword:(id) archive {
|
||||
if (!passwordView) {
|
||||
[NSBundle loadNibNamed:@"PasswordView" owner:self];
|
||||
}
|
||||
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert addButtonWithTitle:@"Cancel"];
|
||||
[alert setMessageText:@"Archive Requires a password"];
|
||||
[alert setInformativeText:@"To extract the contents of this archive a password is required."];
|
||||
[alert setAccessoryView:passwordView];
|
||||
[alert setAlertStyle:NSWarningAlertStyle];
|
||||
|
||||
if ([alert runModal] == NSAlertFirstButtonReturn) {
|
||||
NSString * password = [passwordField stringValue];
|
||||
RARSetPassword((HANDLE)archive, (char *) [password cStringUsingEncoding:NSISOLatin1StringEncoding]);
|
||||
//NSLog(@"Password is: %@", password);
|
||||
}
|
||||
|
||||
[alert release];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue