Skip to content

Commit

Permalink
Skeleton for file encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
the-kenny committed Mar 18, 2011
1 parent 45de3e5 commit 3a0f548
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
15 changes: 12 additions & 3 deletions GPGServices.h
Expand Up @@ -9,7 +9,16 @@
#import <Cocoa/Cocoa.h>
#import <MacGPGME/MacGPGME.h>

typedef enum {SignService, EncryptService, DecryptService, VerifyService, MyKeyService, MyFingerprintService, ImportKeyService} ServiceModeEnum;
typedef enum {
SignService,
EncryptService,
DecryptService,
VerifyService,
MyKeyService,
MyFingerprintService,
ImportKeyService,
EncryptFileService
} ServiceModeEnum;

@interface GPGServices : NSObject
{
Expand All @@ -33,7 +42,7 @@ typedef enum {SignService, EncryptService, DecryptService, VerifyService, MyKeyS
-(NSString *)encryptTextString:(NSString *)inputString;
-(NSString *)decryptTextString:(NSString *)inputString;
-(void)verifyTextString:(NSString *)inputString;

- (void)encryptFiles:(NSArray*)files;

-(void)dealWithPasteboard:(NSPasteboard *)pboard userData:(NSString *)userData mode:(ServiceModeEnum)mode error:(NSString **)error;
-(void)exitServiceRequest;
Expand All @@ -44,7 +53,7 @@ typedef enum {SignService, EncryptService, DecryptService, VerifyService, MyKeyS
-(void)myKey:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error;
-(void)myFingerprint:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error;
-(void)importKey:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error;

-(void)encryptFile:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error;

-(void)displayMessageWindowWithTitleText:(NSString *)title bodyText:(NSString *)body;
-(NSString *)context:(GPGContext *)context passphraseForKey:(GPGKey *)key again:(BOOL)again;
Expand Down
20 changes: 19 additions & 1 deletion GPGServices.m
Expand Up @@ -360,6 +360,9 @@ -(void)verifyTextString:(NSString *)inputString
[aContext release];
}

- (void)encryptFiles:(NSArray*)files {
NSLog(@"encrypting files: %@...", files);
}

//
//Services handling routines
Expand All @@ -376,7 +379,12 @@ -(void)dealWithPasteboard:(NSPasteboard *)pboard userData:(NSString *)userData m

if(mode!=MyKeyService && mode!=MyFingerprintService)
{
type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSHTMLPboardType, NSStringPboardType, NSRTFPboardType, nil]];
type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:
NSHTMLPboardType,
NSStringPboardType,
NSRTFPboardType,
NSFilenamesPboardType,
nil]];

if([type isEqualToString:NSHTMLPboardType])
{
Expand Down Expand Up @@ -436,6 +444,8 @@ -(void)dealWithPasteboard:(NSPasteboard *)pboard userData:(NSString *)userData m
case ImportKeyService:
[self importKey:pboardString];
break;
default:
break;
}

if(newString!=nil)
Expand Down Expand Up @@ -474,6 +484,14 @@ -(void)myFingerprint:(NSPasteboard *)pboard userData:(NSString *)userData error:
-(void)importKey:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error
{[self dealWithPasteboard:pboard userData:userData mode:ImportKeyService error:error];}

-(void)encryptFile:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error {
NSArray* files = [NSArray array];

//Todo: Get all files from request

[self encryptFiles:files];
}

//
//Gui routines
//
Expand Down
21 changes: 21 additions & 0 deletions Info.plist
Expand Up @@ -203,6 +203,27 @@
<string>NSRTFPboardType</string>
</array>
</dict>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>OpenPGP: Encrypt file</string>
</dict>
<key>NSMessage</key>
<string>encryptFile</string>
<key>NSPortName</key>
<string>GPGServices</string>
<key>NSRequiredContext</key>
<dict>
<key>NSTextContent</key>
<string>FilePath</string>
</dict>
<key>NSSendTypes</key>
<array>
<string>public.plain-text</string>
<string>NSFilenamesPboardType</string>
</array>
</dict>
</array>
<key>NSUIElement</key>
<string>1</string>
Expand Down

0 comments on commit 3a0f548

Please sign in to comment.