Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re-implement listing archives again

This now works for both password-protected and non-passworded keyfiles
  • Loading branch information...
commit 26b02459fbd9f6850bfe06a3c12943d4343b58fe 1 parent 6d89b5f
Pieter de Bie authored
5 Tarsnap GUI/TSGBackup.m
View
@@ -37,4 +37,9 @@ - (void)dealloc
[super dealloc];
}
+- (NSString *)description;
+{
+ return [NSString stringWithFormat:@"<%@: %p, name: %@, dateCreated: %@>", [self class], self, self.name, self.dateCreated];
+}
+
@end
10 Tarsnap GUI/TSGDocument.m
View
@@ -109,4 +109,14 @@ - (void)tarsnapKey:(TSGTarsnapKey *)theKey acceptedPassword:(BOOL)theAcceptedPas
}
}
+- (void)tarsnapKey:(TSGTarsnapKey *)theKey foundArchive:(TSGBackup *)theArchive;
+{
+ self.backups = [self.backups arrayByAddingObject:theArchive];
+}
+
+- (void)tarsnapKeyFinishedListingArchives:(TSGTarsnapKey *)theKey;
+{
+ self.loading = NO;
+}
+
@end
11 Tarsnap GUI/TSGListArchivesCommand.m
View
@@ -49,11 +49,6 @@ - (void)tarsnapDidSendError:(NSNotification *)theNotification;
NSString *errorString = [[[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding] autorelease]; // Chose latin1 because it supports all data
if (errorString && [errorString length] > 0) {
NSLog(@"Received an error: %@", errorString);
- if ([errorString hasPrefix:@"Please enter passphrase for keyfile"]) {
- NSLog(@"The warning asks for a password! Handle: %@", self.task.standardInput);
-// [[(NSPipe *)self.task.standardInput fileHandleForWriting] writeData:outData];
-
- }
}
}
@@ -61,7 +56,7 @@ - (void)tarsnapDidSendError:(NSNotification *)theNotification;
- (void)tarsnapDidFinish:(NSNotification *)theNotification;
{
NSData *theData = [[theNotification userInfo] objectForKey:NSFileHandleNotificationDataItem];
- NSString *dataAsString = [[[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding] autorelease];
+ NSString *dataAsString = [[[NSString alloc] initWithData:theData encoding:NSISOLatin1StringEncoding] autorelease];
// FIXME: handle potential errors here, such as not conforming to NSUTF8StringEncoding
NSArray *items = [dataAsString componentsSeparatedByString:@"\n"];
@@ -75,9 +70,9 @@ - (void)tarsnapDidFinish:(NSNotification *)theNotification;
NSString *dateStr = [components objectAtIndex:1];
NSDate *date = [NSDate dateWithNaturalLanguageString:dateStr];
TSGBackup *backupItem = [TSGBackup backupWithName:name date:date];
-
- NSLog(@"Found archive: %@", backupItem);
+ [self.key command:self foundArchive:backupItem];
}
+ [self.key commandFinishedListingArchives:self];
}
@end
6 Tarsnap GUI/TSGTarsnapKey.h
View
@@ -10,6 +10,7 @@
@protocol TSGTarsnapKeyDelegate;
@class TSGTarsnapCommand;
+@class TSGBackup;
@interface TSGTarsnapKey : NSObject
@@ -29,9 +30,14 @@
- (void)tarsnapKey:(TSGTarsnapKey *)theKey requiresPassword:(BOOL)theRequiresPassword;
- (void)tarsnapKey:(TSGTarsnapKey *)theKey acceptedPassword:(BOOL)theAcceptedPassword;
+- (void)tarsnapKey:(TSGTarsnapKey *)theKey foundArchive:(TSGBackup *)theArchive;
+- (void)tarsnapKeyFinishedListingArchives:(TSGTarsnapKey *)theKey;
@end
@interface TSGTarsnapKey (InternalCallbacks)
- (void)command:(TSGTarsnapCommand *)theCommand determinedPasswordRequired:(BOOL)thePasswordRequired;
- (void)command:(TSGTarsnapCommand *)theCommand determinedPasswordValid:(BOOL)thePasswordValid;
+
+- (void)command:(TSGTarsnapCommand *)theCommand foundArchive:(TSGBackup *)theArchive;
+- (void)commandFinishedListingArchives:(TSGTarsnapCommand *)theCommand;
@end
10 Tarsnap GUI/TSGTarsnapKey.m
View
@@ -61,4 +61,14 @@ - (void)command:(TSGTarsnapCommand *)theCommand determinedPasswordValid:(BOOL)th
{
[self.delegate tarsnapKey:self acceptedPassword:thePasswordValid];
}
+
+- (void)command:(TSGTarsnapCommand *)theCommand foundArchive:(TSGBackup *)theArchive;
+{
+ [self.delegate tarsnapKey:self foundArchive:theArchive];
+}
+- (void)commandFinishedListingArchives:(TSGTarsnapCommand *)theCommand;
+{
+ [self.delegate tarsnapKeyFinishedListingArchives:self];
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.