Browse Source

Added new resize of images based on logic such as connected network or auto upload filter. Added default theme as white background. Added upload finish method with the ability to store some info in the history for a future delete option and possibly other features. Removed uploadLock due to issues it causes when an upload fails before it even goes to asynchronous tasks. Added unique ID to auto upload filters to allow unique identification in other locations such as resize logics. Fixed some panels I modified without modifying the language translations.

master
GRMrGecko 7 years ago
parent
commit
c91dc8bbf8
  1. 41
      Classes/CocoaShare/MGMController.h
  2. 379
      Classes/CocoaShare/MGMController.m
  3. 2
      Classes/CocoaShare/MGMPlugInProtocol.h
  4. 12
      Classes/CocoaShare/Preferences/MGMAutoUploadPane.m
  5. 57
      Classes/CocoaShare/Preferences/MGMResizePane.h
  6. 252
      Classes/CocoaShare/Preferences/MGMResizePane.m
  7. 2
      Classes/HTTP/MGMHTTPPlugIn.m
  8. 26
      CocoaShare.xcodeproj/project.pbxproj
  9. 2
      Resources/CocoaShare/Info.plist
  10. 1020
      Resources/CocoaShare/Preferences/English.lproj/AutoUploadPane.xib
  11. 869
      Resources/CocoaShare/Preferences/English.lproj/EventsPane.xib
  12. 38
      Resources/CocoaShare/Preferences/English.lproj/GeneralPane.xib
  13. 373
      Resources/CocoaShare/Preferences/Resize.ai
  14. BIN
      Resources/CocoaShare/Preferences/Resize.png
  15. 421
      Resources/CocoaShare/Preferences/en.lproj/ResizePane.xib
  16. 1024
      Resources/CocoaShare/Preferences/pt_PT.lproj/AutoUploadPane.xib
  17. 1161
      Resources/CocoaShare/Preferences/pt_PT.lproj/GeneralPane.xib
  18. 1023
      Resources/CocoaShare/Preferences/sv.lproj/AutoUploadPane.xib
  19. 1161
      Resources/CocoaShare/Preferences/sv.lproj/GeneralPane.xib

41
Classes/CocoaShare/MGMController.h

@ -9,6 +9,7 @@
#import <Cocoa/Cocoa.h>
#import "MGMPlugInProtocol.h"
#import "MGMLocalized.h"
#import <SystemConfiguration/SystemConfiguration.h>
extern NSString * const MGMDisplay;
extern NSString * const MGMStartup;
@ -17,6 +18,10 @@ extern NSString * const MGMHistoryCount;
extern NSString * const MGMGrowlErrors;
extern NSString * const MGMUploadLimit;
extern NSString * const MGMHURL;
extern NSString * const MGMHInfo;
extern NSString * const MGMHDate;
extern NSString * const MGMESound;
extern NSString * const MGMEPath;
extern NSString * const MGMEDelete;
@ -30,10 +35,18 @@ extern NSString * const MGMEvent;
extern NSString * const MGMEventPath;
extern NSString * const MGMEventURL;
extern NSString * const MGMFiltersPlist;
extern NSString * const MGMFID;
extern NSString * const MGMFPath;
extern NSString * const MGMFFilter;
extern NSString * const MGMRID;
extern NSString * const MGMRWidth;
extern NSString * const MGMRHeight;
extern NSString * const MGMRScale;
extern NSString * const MGMRFilters;
extern NSString * const MGMRNetworks;
extern NSString * const MGMRIPPrefix;
@class MGMURLConnectionManager, MGMPreferences, MGMAbout, MGMMenuItem, MGMPathSubscriber;
@interface MGMController : NSObject
@ -43,6 +56,12 @@ extern NSString * const MGMFFilter;
{
NSTimer *autoreleaseDrain;
CFRunLoopSourceRef runLoop;
SCDynamicStoreRef store;
NSDictionary *lastAirPortState;
NSArray *IPv4Addresses;
NSArray *IPv6Addresses;
MGMURLConnectionManager *connectionManager;
MGMPreferences *preferences;
MGMAbout *about;
@ -62,16 +81,16 @@ extern NSString * const MGMFFilter;
MGMPathSubscriber *filterWatcher;
BOOL filtersEnabled;
NSMutableArray *resizeLogic;
NSMutableArray *accountPlugIns;
NSMutableArray *plugIns;
id<MGMPlugInProtocol> currentPlugIn;
int currentPlugInIndex;
NSMutableArray *MUThemes;
int currentMUThemeIndex;
NSLock *uploadLock;
NSMutableArray *multiUploadLinks;
NSMutableArray *uploads;
}
@ -79,6 +98,11 @@ extern NSString * const MGMFFilter;
- (void)registerDefaults;
- (void)ipv4Changed:(NSDictionary *)theInfo;
- (void)ipv6Changed:(NSDictionary *)theInfo;
- (void)airportChanged:(NSDictionary *)theInfo;
- (MGMURLConnectionManager *)connectionManager;
- (MGMPreferences *)preferences;
@ -122,6 +146,12 @@ extern NSString * const MGMFFilter;
- (void)updateFilterWatcher;
- (void)subscribedPathChanged:(NSString *)thePath;
- (NSMutableArray *)resizeLogic;
- (void)resizeIfNeeded:(NSString *)thePath;
- (void)resizeIfNeeded:(NSString *)thePath filterID:(NSString *)theID;
- (void)resize:(NSString *)thePath toSize:(NSSize)theSize scale:(float)theScale;
- (void)saveResizeLogic;
- (void)removePassword;
- (void)setPassword:(NSString *)thePassword;
- (NSString *)password;
@ -131,10 +161,11 @@ extern NSString * const MGMFFilter;
- (NSMutableArray *)uploads;
- (NSDictionary *)uploadForPath:(NSString *)thePath;
- (void)addPathToUploads:(NSString *)thePath isAutomatic:(BOOL)isAutomatic;
- (void)addPathToUploads:(NSString *)thePath isAutomatic:(BOOL)isAutomatic multiUpload:(int)multiUploadState;
- (void)addPathToUploads:(NSString *)thePath automaticFilter:(NSString *)theFilter;
- (void)addPathToUploads:(NSString *)thePath automaticFilter:(NSString *)theFilter multiUpload:(int)multiUploadState;
- (void)processNextUpload;
- (void)upload:(NSString *)thePath receivedError:(NSError *)theError;
- (void)uploadFinished:(NSString *)thePath url:(NSURL *)theURL;
- (void)uploadFinished:(NSString *)thePath url:(NSURL *)theURL info:(id)theInfo;
- (void)multiUploadPageCreated:(NSURL *)theURL;
@end

379
Classes/CocoaShare/MGMController.m

@ -30,6 +30,7 @@ NSString * const MGMUploadLimit = @"MGMUploadLimit";
NSString * const MGMHistoryPlist = @"history.plist";
NSString * const MGMHURL = @"url";
NSString * const MGMHInfo = @"info";
NSString * const MGMHDate = @"date";
NSString * const MGMESound = @"MGME%dSound";
@ -46,9 +47,19 @@ NSString * const MGMEventPath = @"path";
NSString * const MGMEventURL = @"URL";
NSString * const MGMFiltersPlist = @"filters.plist";
NSString * const MGMFID = @"id";
NSString * const MGMFPath = @"path";
NSString * const MGMFFilter = @"filter";
NSString * const MGMResizePlist = @"resize.plist";
NSString * const MGMRID = @"id";
NSString * const MGMRWidth = @"width";
NSString * const MGMRHeight = @"height";
NSString * const MGMRScale = @"scale";
NSString * const MGMRFilters = @"filters";
NSString * const MGMRNetworks = @"networks";
NSString * const MGMRIPPrefix = @"IPPrefix";
NSString * const MGMPluginFolder = @"PlugIns";
NSString * const MGMCurrentPlugIn = @"MGMCurrentPlugIn";
@ -78,6 +89,34 @@ OSStatus frontAppChanged(EventHandlerCallRef nextHandler, EventRef theEvent, voi
static MGMController *MGMSharedController;
NSString * const MGMPrimaryInterface = @"PrimaryInterface";
NSString * const MGMAddresses = @"Addresses";
NSString * const MGMIPv4Info = @"State:/Network/Interface/%@/IPv4";
NSString * const MGMIPv6Info = @"State:/Network/Interface/%@/IPv6";
NSString * const MGMIPv4State = @"State:/Network/Global/IPv4";
NSString * const MGMIPv6State = @"State:/Network/Global/IPv6";
NSString * const MGMAirPortInfo = @"State:/Network/Interface/%@/AirPort";
static void systemNotification(SCDynamicStoreRef store, NSArray *changedKeys, void *info) {
for (int i=0; i<[changedKeys count]; ++i) {
NSString *key = [changedKeys objectAtIndex:i];
if ([key isEqual:MGMIPv4State]) {
NSDictionary *value = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)key);
[(MGMController *)info ipv4Changed:value];
[value release];
} else if ([key isEqual:MGMIPv6State]) {
NSDictionary *value = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)key);
[(MGMController *)info ipv6Changed:value];
[value release];
} else if ([key hasSuffix:@"AirPort"]) {
NSDictionary *value = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)key);
[(MGMController *)info airportChanged:value];
[value release];
}
}
}
@implementation MGMController
+ (id)sharedController {
if (MGMSharedController==nil) {
@ -104,6 +143,53 @@ static MGMController *MGMSharedController;
[GrowlApplicationBridge setGrowlDelegate:nil];
NSString *AirPortBSDName = nil;
CFArrayRef interfaces = SCNetworkInterfaceCopyAll();
for (int i=0; i<CFArrayGetCount(interfaces); i++) {
SCNetworkInterfaceRef interface = CFArrayGetValueAtIndex(interfaces, i);
if ([(NSString *)SCNetworkInterfaceGetInterfaceType(interface) isEqual:@"IEEE80211"]) {
AirPortBSDName = (NSString *)SCNetworkInterfaceGetBSDName(interface);
}
}
CFRelease(interfaces);
SCDynamicStoreContext context = {0, self, NULL, NULL, NULL};
store = SCDynamicStoreCreate(kCFAllocatorDefault, CFBundleGetIdentifier(CFBundleGetMainBundle()), (SCDynamicStoreCallBack)systemNotification, &context);
if (!store) {
NSLog(@"Unable to create store for system configuration %s", SCErrorString(SCError()));
} else {
NSMutableArray *keys = [NSMutableArray arrayWithObjects:MGMIPv4State, MGMIPv6State, nil];
if (AirPortBSDName!=nil) {
[keys addObject:[NSString stringWithFormat:MGMAirPortInfo, AirPortBSDName]];
}
if (!SCDynamicStoreSetNotificationKeys(store, (CFArrayRef)keys, NULL)) {
NSLog(@"faild to set the store for notifications %s", SCErrorString(SCError()));
CFRelease(store);
store = NULL;
} else {
runLoop = SCDynamicStoreCreateRunLoopSource(kCFAllocatorDefault, store, 0);
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoop, kCFRunLoopDefaultMode);
NSDictionary *IPv4State = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)MGMIPv4State);
NSDictionary *IPv4Info = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)[NSString stringWithFormat:MGMIPv4Info, [IPv4State objectForKey:MGMPrimaryInterface]]);
IPv4Addresses = [[IPv4Info objectForKey:MGMAddresses] retain];
[IPv4Info release];
[IPv4State release];
NSDictionary *IPv6State = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)MGMIPv6State);
NSDictionary *IPv6Info = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)[NSString stringWithFormat:MGMIPv6Info, [IPv6State objectForKey:MGMPrimaryInterface]]);
IPv6Addresses = [[IPv6Info objectForKey:MGMAddresses] retain];
[IPv6Info release];
[IPv6State release];
if (AirPortBSDName!=nil) {
lastAirPortState = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)[NSString stringWithFormat:MGMAirPortInfo, AirPortBSDName]);
}
}
}
connectionManager = [[MGMURLConnectionManager managerWithCookieStorage:[MGMUser cookieStorage]] retain];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@ -147,13 +233,26 @@ static MGMController *MGMSharedController;
}
filtersEnabled = YES;
if ([manager fileExistsAtPath:[[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMResizePlist]]) {
NSData *plistData = [NSData dataWithContentsOfFile:[[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMResizePlist]];
NSString *error = nil;
resizeLogic = [[NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListMutableContainersAndLeaves format:NULL errorDescription:&error] retain];
if (error!=nil) {
NSLog(@"Error processing resize.plist: %@", error);
}
} else {
resizeLogic = [NSMutableArray new];
[self saveResizeLogic];
}
if ([defaults integerForKey:MGMDisplay]>0)
[self addMenu];
preferences = [MGMPreferences new];
[preferences addPreferencesPaneClassName:@"MGMGeneralPane"];
[preferences addPreferencesPaneClassName:@"MGMAccountPane"];
[preferences addPreferencesPaneClassName:@"MGMAutoUploadPane"];
[preferences addPreferencesPaneClassName:@"MGMAutoUploadPane"];
[preferences addPreferencesPaneClassName:@"MGMResizePane"];
[preferences addPreferencesPaneClassName:@"MGMEventsPane"];
EventTypeSpec eventType;
@ -167,15 +266,37 @@ static MGMController *MGMSharedController;
about = [MGMAbout new];
uploadLock = [NSLock new];
uploads = [NSMutableArray new];
if ([defaults objectForKey:MGMVersion]==nil || [[defaults objectForKey:MGMVersion] doubleValue]<=0.3) {
for (int i=0; i<[filters count]; i++) {
if ([[filters objectAtIndex:i] objectForKey:MGMFID]==nil) {
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidString = [(NSString *)CFUUIDCreateString(NULL, uuid) autorelease];
CFRelease(uuid);
NSDictionary *filter = [[filters objectAtIndex:i] mutableCopy];
[filter setValue:uuidString forKey:MGMFID];
[filters replaceObjectAtIndex:i withObject:filter];
[filter release];
}
}
[self saveFilters];
}
[defaults setObject:[[MGMSystemInfo info] applicationVersion] forKey:MGMVersion];
[self loadMUThemes];
[self loadPlugIns];
}
- (void)dealloc {
[autoreleaseDrain invalidate];
[autoreleaseDrain release];
if (store!=NULL) {
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoop, kCFRunLoopDefaultMode);
CFRelease(store);
}
[IPv4Addresses release];
[IPv6Addresses release];
[lastAirPortState release];
[connectionManager release];
[preferences release];
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
@ -187,14 +308,12 @@ static MGMController *MGMSharedController;
[filterWatcher release];
[accountPlugIns release];
[plugIns release];
[uploadLock release];
[uploads release];
[super dealloc];
}
- (void)registerDefaults {
NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
[defaults setObject:[[MGMSystemInfo info] applicationVersion] forKey:MGMVersion];
[defaults setObject:[NSNumber numberWithInt:1] forKey:MGMLaunchCount];
[defaults setObject:[NSNumber numberWithInt:([[MGMSystemInfo info] isUIElement] ? 2 : 0)] forKey:MGMDisplay];
@ -204,6 +323,8 @@ static MGMController *MGMSharedController;
[defaults setObject:[NSNumber numberWithInt:5] forKey:MGMUploadLimit];
[defaults setObject:[NSNumber numberWithInt:2] forKey:[NSString stringWithFormat:MGMEDelete, MGMEUploadedAutomatic]];
[defaults setObject:[[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:MGMMUThemesFolder] stringByAppendingPathComponent:@"White Background"] forKey:MGMCurrentMUTheme];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
}
@ -212,6 +333,26 @@ static MGMController *MGMSharedController;
[[NSApplication sharedApplication] postEvent:event atStart:NO];
}
- (void)ipv4Changed:(NSDictionary *)theInfo {
NSDictionary *info = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)[NSString stringWithFormat:MGMIPv4Info, [theInfo objectForKey:MGMPrimaryInterface]]);
[IPv4Addresses autorelease];
IPv4Addresses = [[info objectForKey:MGMAddresses] retain];
[info release];
}
- (void)ipv6Changed:(NSDictionary *)theInfo {
NSDictionary *info = (NSDictionary *)SCDynamicStoreCopyValue(store, (CFStringRef)[NSString stringWithFormat:MGMIPv6Info, [theInfo objectForKey:MGMPrimaryInterface]]);
[IPv6Addresses autorelease];
IPv6Addresses = [[info objectForKey:MGMAddresses] retain];
[info release];
}
- (void)airportChanged:(NSDictionary *)theInfo {
[lastAirPortState autorelease];
lastAirPortState = [theInfo retain];
}
- (MGMURLConnectionManager *)connectionManager {
return connectionManager;
}
@ -445,7 +586,7 @@ static MGMController *MGMSharedController;
[alert runModal];
continue;
}
[self addPathToUploads:[files objectAtIndex:i] isAutomatic:NO multiUpload:([files count]==1 ? 0 : (i==0 ? 1 : (i==[files count]-1 ? 3 : 2)))];
[self addPathToUploads:[files objectAtIndex:i] automaticFilter:nil multiUpload:([files count]==1 ? 0 : (i==0 ? 1 : (i==[files count]-1 ? 3 : 2)))];
}
}
}
@ -504,6 +645,18 @@ static MGMController *MGMSharedController;
[history writeToFile:[[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMHistoryPlist] atomically:YES];
[self updateMenu];
}
- (void)uploadFinished:(NSString *)thePath url:(NSURL *)theURL info:(id)theInfo {
[history addObject:[NSDictionary dictionaryWithObjectsAndKeys:[theURL absoluteString], MGMHURL, theInfo, MGMHInfo, [NSDate date], MGMHDate, nil]];
int maxHistoryItems = [[NSUserDefaults standardUserDefaults] integerForKey:MGMHistoryCount];
int itemsToDelete = [history count]-maxHistoryItems;
if (itemsToDelete>0) {
for (int i=0; i<itemsToDelete; i++) {
[history removeObjectAtIndex:0];
}
}
[history writeToFile:[[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMHistoryPlist] atomically:YES];
[self updateMenu];
}
- (IBAction)uploadFile:(id)sender {
NSOpenPanel *panel = [NSOpenPanel openPanel];
@ -517,7 +670,7 @@ static MGMController *MGMSharedController;
int returnCode = [panel runModal];
if (returnCode==NSOKButton) {
for (int i=0; i<[[panel URLs] count]; i++) {
[self addPathToUploads:[[[panel URLs] objectAtIndex:i] path] isAutomatic:NO multiUpload:([[panel URLs] count]==1 ? 0 : (i==0 ? 1 : (i==[[panel URLs] count]-1 ? 3 : 2)))];
[self addPathToUploads:[[[panel URLs] objectAtIndex:i] path] automaticFilter:nil multiUpload:([[panel URLs] count]==1 ? 0 : (i==0 ? 1 : (i==[[panel URLs] count]-1 ? 3 : 2)))];
}
}
[self resignFront];
@ -530,7 +683,7 @@ static MGMController *MGMSharedController;
}
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)theFiles {
for (int i=0; i<[theFiles count]; i++) {
[self addPathToUploads:[theFiles objectAtIndex:i] isAutomatic:NO multiUpload:([theFiles count]==1 ? 0 : (i==0 ? 1 : (i==[theFiles count]-1 ? 3 : 2)))];
[self addPathToUploads:[theFiles objectAtIndex:i] automaticFilter:nil multiUpload:([theFiles count]==1 ? 0 : (i==0 ? 1 : (i==[theFiles count]-1 ? 3 : 2)))];
}
}
@ -592,6 +745,7 @@ static MGMController *MGMSharedController;
}
}
}
- (void)subscribedPathChanged:(NSString *)thePath {
NSLog(@"Changed: %@", thePath);
if (filtersEnabled) {
@ -621,10 +775,11 @@ static MGMController *MGMSharedController;
NSArray *items = (NSArray *)MDItemCopyAttributeNames(metadata);
for (int m=0; m<[items count]; m++) {
id item = (id)MDItemCopyAttribute(metadata, (CFStringRef)[items objectAtIndex:m]);
if ([[items objectAtIndex:m] isMatchedByRegex:filter])
[self addPathToUploads:fullPath isAutomatic:YES];
else if ([item isKindOfClass:[NSString class]] && [item isMatchedByRegex:filter])
[self addPathToUploads:fullPath isAutomatic:YES];
if ([[items objectAtIndex:m] isMatchedByRegex:filter]) {
[self addPathToUploads:fullPath automaticFilter:[[filtersFound objectAtIndex:f] objectForKey:MGMFID]];
} else if ([item isKindOfClass:[NSString class]] && [item isMatchedByRegex:filter]) {
[self addPathToUploads:fullPath automaticFilter:[[filtersFound objectAtIndex:f] objectForKey:MGMFID]];
}
if (item!=nil)
CFRelease((CFTypeRef)item);
}
@ -642,14 +797,16 @@ static MGMController *MGMSharedController;
extendedAttributes = [[manager fileSystemAttributesAtPath:fullPath] objectForKey:@"NSFileExtendedAttributes"];
}
for (int a=0; a<[[extendedAttributes allKeys] count]; a++) {
if ([[[extendedAttributes allKeys] objectAtIndex:a] isMatchedByRegex:filter])
[self addPathToUploads:fullPath isAutomatic:YES];
else if ([[extendedAttributes objectForKey:[[extendedAttributes allKeys] objectAtIndex:a]] isKindOfClass:[NSString class]] && [[extendedAttributes objectForKey:[[extendedAttributes allKeys] objectAtIndex:a]] isMatchedByRegex:filter])
[self addPathToUploads:fullPath isAutomatic:YES];
if ([[[extendedAttributes allKeys] objectAtIndex:a] isMatchedByRegex:filter]) {
[self addPathToUploads:fullPath automaticFilter:[[filtersFound objectAtIndex:f] objectForKey:MGMFID]];
} else if ([[extendedAttributes objectForKey:[[extendedAttributes allKeys] objectAtIndex:a]] isKindOfClass:[NSString class]] && [[extendedAttributes objectForKey:[[extendedAttributes allKeys] objectAtIndex:a]] isMatchedByRegex:filter]) {
[self addPathToUploads:fullPath automaticFilter:[[filtersFound objectAtIndex:f] objectForKey:MGMFID]];
}
}
} else {
if ([file isMatchedByRegex:filter])
[self addPathToUploads:fullPath isAutomatic:YES];
if ([file isMatchedByRegex:filter]) {
[self addPathToUploads:fullPath automaticFilter:[[filtersFound objectAtIndex:f] objectForKey:MGMFID]];
}
}
}
}
@ -657,6 +814,173 @@ static MGMController *MGMSharedController;
}
}
- (NSMutableArray *)resizeLogic {
return resizeLogic;
}
- (void)resizeIfNeeded:(NSString *)thePath {
[self resizeIfNeeded:thePath filterID:nil];
}
- (void)resizeIfNeeded:(NSString *)thePath filterID:(NSString *)theID {
NSArray *extensions = [NSArray arrayWithObjects:@"jpg", @"jpeg", @"png", @"tif", @"tiff", @"bmp", nil];
if (![extensions containsObject:[[thePath pathExtension] lowercaseString]])
return;
NSDictionary *lastMatch = nil;
BOOL matchedOnFilter = NO;
BOOL matchedOnNetwork = NO;
BOOL matchedOnPrefix = NO;
for (int i=0; i<[resizeLogic count]; i++) {
NSDictionary *logic = [resizeLogic objectAtIndex:i];
BOOL prefixMatch = NO;
if (![[logic objectForKey:MGMRIPPrefix] isEqual:@""]) {
NSString *prefix = [logic objectForKey:MGMRIPPrefix];
for (int ip=0; ip<[IPv4Addresses count]; ip++) {
if ([[IPv4Addresses objectAtIndex:ip] hasPrefix:prefix]) {
prefixMatch = YES;
}
}
for (int ip=0; ip<[IPv6Addresses count]; ip++) {
if ([[IPv6Addresses objectAtIndex:ip] hasPrefix:prefix]) {
prefixMatch = YES;
}
}
}
BOOL networkMatch = (lastAirPortState!=nil && [lastAirPortState objectForKey:@"SSID"]!=nil && [[logic objectForKey:MGMRNetworks] containsObject:[[[NSString alloc] initWithData:[lastAirPortState objectForKey:@"SSID"] encoding:NSUTF8StringEncoding] autorelease]]);
BOOL filterMatch = (theID!=nil && [[logic objectForKey:MGMRFilters] containsObject:theID]);
NSLog(@"%d %d %d", prefixMatch, networkMatch, filterMatch);
if ([[logic objectForKey:MGMRFilters] count]==0 && (networkMatch || prefixMatch)) {//No filters and network or prefix match.
if (lastMatch!=nil && matchedOnFilter) {//If this is a network match and previous was a filter match, do not match.
continue;
}
if (lastMatch!=nil && matchedOnNetwork && !networkMatch) {//If this isn't a network match, yet the previous was, do not match.
continue;
}
} else if ([[logic objectForKey:MGMRFilters] count]==0) {//No filters and not network or prefix.
if (lastMatch!=nil && (matchedOnNetwork || matchedOnPrefix || matchedOnFilter)) {//If previous matches on network, prefix, or filter, do not match.
continue;
}
} else if ([[logic objectForKey:MGMRFilters] count]!=0 && !filterMatch) {//Cannot match if filteres exist, but not matched.
continue;
} else if (filterMatch) {//If filtere match.
if (networkMatch || prefixMatch) {//Network or prefix match.
if (lastMatch!=nil && matchedOnFilter && matchedOnNetwork && !networkMatch) {//Previous matched on network and this isn't a network match, do not match.
continue;
}
} else {//Not network or prefix match.
if (lastMatch!=nil && matchedOnFilter && (matchedOnNetwork || matchedOnFilter)) {//If was a network match, do not match.
continue;
}
}
}
if (([[logic objectForKey:MGMRWidth] intValue]==0 || [[logic objectForKey:MGMRHeight] intValue]==0) && [[logic objectForKey:MGMRScale] intValue]==0) {//Incorrect resize logic.
continue;
}
lastMatch = logic;
matchedOnFilter = filterMatch;
matchedOnNetwork = networkMatch;
matchedOnPrefix = prefixMatch;
}
if (lastMatch!=nil) {
int scale = [[lastMatch objectForKey:MGMRScale] intValue];
if (scale!=0) {
[self resize:thePath toSize:NSZeroSize scale:1-(((float)scale)/100)];
} else {
[self resize:thePath toSize:NSMakeSize([[lastMatch objectForKey:MGMRWidth] floatValue], [[lastMatch objectForKey:MGMRHeight] floatValue]) scale:0.0];
}
}
}
- (void)resize:(NSString *)thePath toSize:(NSSize)theSize scale:(float)theScale {
NSString *extension = [[thePath pathExtension] lowercaseString];
CFStringRef type = kUTTypeImage;
if ([extension isEqual:@"jpg"] || [extension isEqual:@"jpeg"]) {
type = kUTTypeJPEG;
} else if ([extension isEqual:@"png"]) {
type = kUTTypePNG;
} else if ([extension isEqual:@"bmp"]) {
type = kUTTypeBMP;
} else if ([extension isEqual:@"tif"] || [extension isEqual:@"tiff"]) {
type = kUTTypeTIFF;
} else {
return;
}
CFURLRef fileURL = (__bridge CFURLRef)[NSURL fileURLWithPath:[thePath stringByExpandingTildeInPath]];
CGImageSourceRef source = CGImageSourceCreateWithURL(fileURL, NULL);
if (source==NULL) {
NSLog(@"Unable to create image source: %@", thePath);
return;
}
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease(source);
if (imageRef==NULL) {
NSLog(@"Unable to create image: %@", thePath);
return;
}
NSSize size = NSMakeSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
float scaleFactor = 0.0;
float scaledWidth = 0.0;
float scaledHeight = 0.0;
if (NSEqualSizes(theSize, NSZeroSize)) {
scaleFactor = theScale;
} else {
float widthFactor = theSize.width / size.width;
float heightFactor = theSize.height / size.height;
if (widthFactor < heightFactor)
scaleFactor = widthFactor;
else
scaleFactor = heightFactor;
}
scaledWidth = size.width * scaleFactor;
scaledHeight = size.height * scaleFactor;
if (size.width<=scaledWidth && size.height<=scaledHeight) {
CGImageRelease(imageRef);
return;//Output larger or equal to input.
}
NSLog(@"Resizing: %@", thePath);
NSLog(@"Width: %f Height: %f", size.width, size.height);
NSLog(@"Width: %f Height: %f", scaledWidth, scaledHeight);
NSSize newSize = NSMakeSize(scaledWidth, scaledHeight);
if (!NSEqualSizes(newSize, NSZeroSize)) {
CGContextRef bitmap = CGBitmapContextCreate(NULL, newSize.width, newSize.height, CGImageGetBitsPerComponent(imageRef), 0, CGImageGetColorSpace(imageRef), (CGBitmapInfo)((type==kUTTypePNG || type==kUTTypeTIFF) ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast));
CGContextSetInterpolationQuality(bitmap, kCGInterpolationHigh);
CGContextDrawImage(bitmap, NSMakeRect(0, 0, newSize.width, newSize.height), imageRef);
CGImageRef newImage = CGBitmapContextCreateImage(bitmap);
CGContextRelease(bitmap);
CGImageDestinationRef destination = CGImageDestinationCreateWithURL(fileURL, type, 1, NULL);
if (!destination) {
NSLog(@"Failed to create CGImageDestination for %@", thePath);
CGImageRelease(newImage);
CGImageRelease(imageRef);
return;
}
CGImageDestinationAddImage(destination, newImage, nil);
if (!CGImageDestinationFinalize(destination)) {
NSLog(@"Failed to write image to %@", thePath);
}
CFRelease(destination);
CGImageRelease(newImage);
}
CGImageRelease(imageRef);
}
- (void)saveResizeLogic {
if (saveCount==2)
return;
saveCount++;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[saveLock lock];
[resizeLogic writeToFile:[[MGMUser applicationSupportPath] stringByAppendingPathComponent:MGMResizePlist] atomically:YES];
saveCount--;
[pool drain];
[saveLock unlock];
}
- (void)removePassword {
NSArray *items = [MGMKeychain items:MGMKCType withName:MGMKCName service:MGMKCName account:MGMKCName];
if ([items count]>0)
@ -755,8 +1079,8 @@ static MGMController *MGMSharedController;
return nil;
}
- (void)addPathToUploads:(NSString *)thePath isAutomatic:(BOOL)isAutomatic {
[self addPathToUploads:thePath isAutomatic:isAutomatic multiUpload:0];
- (void)addPathToUploads:(NSString *)thePath automaticFilter:(NSString *)theFilter {
[self addPathToUploads:thePath automaticFilter:theFilter multiUpload:0];
}
/*
@ -766,8 +1090,7 @@ static MGMController *MGMSharedController;
3 - Last upload in the queue.
4 - The multi upload page.
*/
- (void)addPathToUploads:(NSString *)thePath isAutomatic:(BOOL)isAutomatic multiUpload:(int)multiUploadState {
[uploadLock lock];
- (void)addPathToUploads:(NSString *)thePath automaticFilter:(NSString *)theFilter multiUpload:(int)multiUploadState {
if ([self uploadForPath:thePath]==nil) {
if ([currentPlugIn respondsToSelector:@selector(allowedExtensions)]) {
if (![[currentPlugIn allowedExtensions] containsObject:[[thePath pathExtension] lowercaseString]]) {
@ -778,11 +1101,12 @@ static MGMController *MGMSharedController;
return;
}
}
[uploads addObject:[NSDictionary dictionaryWithObjectsAndKeys:thePath, MGMUPath, [NSNumber numberWithBool:isAutomatic], MGMUAutomatic, [NSNumber numberWithInt:multiUploadState], MGMUMultiUpload, nil]];
[self resizeIfNeeded:thePath filterID:theFilter];
[uploads addObject:[NSDictionary dictionaryWithObjectsAndKeys:thePath, MGMUPath, [NSNumber numberWithBool:(theFilter!=nil)], MGMUAutomatic, [NSNumber numberWithInt:multiUploadState], MGMUMultiUpload, nil]];
if ([uploads count]==1)
[self processNextUpload];
}
[uploadLock unlock];
}
- (void)processNextUpload {
if ([uploads count]>0) {
@ -838,6 +1162,7 @@ static MGMController *MGMSharedController;
- (void)upload:(NSString *)thePath receivedError:(NSError *)theError {
NSDictionary *upload = [self uploadForPath:thePath];
if (upload!=nil) {
NSLog(@"Error: %@", theError);
if ([[NSUserDefaults standardUserDefaults] boolForKey:MGMGrowlErrors]) {
[GrowlApplicationBridge notifyWithTitle:[@"Unable to upload" localized] description:[NSString stringWithFormat:@"%@: %@", [[upload objectForKey:MGMUPath] lastPathComponent], [theError localizedDescription]] notificationName:@"UploadError" iconData:[[[NSApplication sharedApplication] applicationIconImage] TIFFRepresentation] priority:1 isSticky:NO clickContext:nil];
} else {
@ -846,10 +1171,8 @@ static MGMController *MGMSharedController;
[alert setInformativeText:[NSString stringWithFormat:[@"Unable to upload %@: %@" localized], [[upload objectForKey:MGMUPath] lastPathComponent], [theError localizedDescription]]];
[alert runModal];
}
[uploadLock lock];
[uploads removeObject:upload];
[self processNextUpload];
[uploadLock unlock];
}
}
- (void)uploadFinished:(NSString *)thePath url:(NSURL *)theURL {
@ -878,10 +1201,8 @@ static MGMController *MGMSharedController;
NSString *imageHTML = [NSString stringWithContentsOfFile:[[self currentMUTheme] stringByAppendingPathComponent:@"image.html"] encoding:NSUTF8StringEncoding error:nil];
if (imageHTML==nil) {
[uploadLock lock];
[uploads removeObject:upload];
[self processNextUpload];
[uploadLock unlock];
return;
}
NSString *fileHTML = [NSString stringWithContentsOfFile:[[self currentMUTheme] stringByAppendingPathComponent:@"file.html"] encoding:NSUTF8StringEncoding error:nil];
@ -901,17 +1222,15 @@ static MGMController *MGMSharedController;
}
[multiUploadHtml writeData:[NSData dataWithContentsOfFile:[[self currentMUTheme] stringByAppendingPathComponent:@"footer.html"]]];
[multiUploadHtml closeFile];
[self addPathToUploads:htmlPath isAutomatic:YES multiUpload:4];
[self addPathToUploads:htmlPath automaticFilter:nil multiUpload:4];
}
}
if (multiUpload==4) {
[[NSFileManager defaultManager] removeItemAtPath:[upload objectForKey:MGMUPath]];
}
[uploadLock lock];
[uploads removeObject:upload];
[self processNextUpload];
[uploadLock unlock];
}
}
- (void)multiUploadPageCreated:(NSURL *)theURL {

2
Classes/CocoaShare/MGMPlugInProtocol.h

@ -29,7 +29,7 @@
/*
If the plugin is responsible for creating the multi upload page, use this method to be called instead of having CocoaShare itself create a page.
If you have this method, you must ether:
1. Tell CocoaShare to upload the page to go through the usual file sending with [self addPathToUploads:filePath isAutomatic:YES multiUpload:4];
1. Tell CocoaShare to upload the page to go through the usual file sending with [self addPathToUploads:filePath automaticFilter:nil multiUpload:4];
2. Call multiUploadPageCreated: with the URL of the multi upload page.
*/
@end

12
Classes/CocoaShare/Preferences/MGMAutoUploadPane.m

@ -41,7 +41,7 @@
return view;
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
- (NSInteger)numberOfRowsInTableView:(NSTableView *)theTableView {
return [[controller filters] count];
}
- (id)tableView:(NSTableView *)theTableView objectValueForTableColumn:(NSTableColumn *)theTableColumn row:(NSInteger)rowIndex {
@ -80,7 +80,10 @@
[NSMenu popUpContextMenu:addMenu withEvent:event forView:addButton];
}
- (IBAction)addNewFilter:(id)sender {
[[controller filters] addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"", MGMFPath, @"", MGMFFilter, nil]];
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidString = [(NSString *)CFUUIDCreateString(NULL, uuid) autorelease];
CFRelease(uuid);
[[controller filters] addObject:[NSDictionary dictionaryWithObjectsAndKeys:uuidString, MGMFID, @"", MGMFPath, @"", MGMFFilter, nil]];
[filtersTable reloadData];
int index = [[controller filters] count]-1;
[filtersTable selectRowIndexes:[NSIndexSet indexSetWithIndex:index] byExtendingSelection:NO];
@ -92,7 +95,10 @@
filter = @"MD:(?i)isScreenCapture\\z";
else
filter = [@"(?i)Picture [0-9]+\\.(?:bmp|gif|jpg|pdf|pict|png|sgi|tga|tif|tiff)\\z" localized];
[[controller filters] addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"~/Desktop", MGMFPath, filter, MGMFFilter, nil]];
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidString = [(NSString *)CFUUIDCreateString(NULL, uuid) autorelease];
CFRelease(uuid);
[[controller filters] addObject:[NSDictionary dictionaryWithObjectsAndKeys:uuidString, MGMFID, @"~/Desktop", MGMFPath, filter, MGMFFilter, nil]];
[filtersTable reloadData];
int index = [[controller filters] count]-1;
[filtersTable selectRowIndexes:[NSIndexSet indexSetWithIndex:index] byExtendingSelection:NO];

57
Classes/CocoaShare/Preferences/MGMResizePane.h

@ -0,0 +1,57 @@
//
// MGMResizePane.h
// CocoaShare
//
// Created by Mr. Gecko on 12/30/15.
// Copyright (c) 2015 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
//
//
#import <Cocoa/Cocoa.h>
#import <MGMUsers/MGMUsers.h>
@class MGMController;
@interface MGMResizePane : MGMPreferencesPane {
MGMController *controller;
IBOutlet NSView *view;
IBOutlet NSTableView *logicTable;
IBOutlet NSButton *addButton;
IBOutlet NSButton *removeButton;
IBOutlet NSTextField *widthField;
IBOutlet NSTextField *heightField;
IBOutlet NSTextField *scaleField;
IBOutlet NSButton *filtersButton;
IBOutlet NSWindow *filtersWindow;
IBOutlet NSTableView *filtersTable;
IBOutlet NSButton *networksButton;
IBOutlet NSWindow *networksWindow;
IBOutlet NSTableView *networksTable;
IBOutlet NSTextField *IPPrefixField;
NSMutableArray *AirPortNetworks;
int currentLogic;
}
- (id)initWithPreferences:(MGMPreferences *)thePreferences;
+ (void)setUpToolbarItem:(NSToolbarItem *)theItem;
+ (NSString *)title;
- (NSView *)preferencesView;
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification;
- (IBAction)addLogic:(id)sender;
- (IBAction)removeLogic:(id)sender;
- (IBAction)selectFilters:(id)sender;
- (IBAction)saveFilters:(id)sender;
- (IBAction)selectNetworks:(id)sender;
- (IBAction)saveNetworks:(id)sender;
- (IBAction)fieldsChanged:(id)sender;
@end

252
Classes/CocoaShare/Preferences/MGMResizePane.m

@ -0,0 +1,252 @@
//
// MGMResizePane.m
// CocoaShare
//
// Created by Mr. Gecko on 12/30/15.
// Copyright (c) 2015 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
//
//
#import "MGMResizePane.h"
#import "MGMController.h"
@implementation MGMResizePane
- (id)initWithPreferences:(MGMPreferences *)thePreferences {
if ((self = [super initWithPreferences:thePreferences])) {
if (![NSBundle loadNibNamed:@"ResizePane" owner:self]) {
NSLog(@"Error loading Events pane");
} else {
controller = [MGMController sharedController];
[logicTable reloadData];
[filtersTable reloadData];
[self tableViewSelectionDidChange:nil];
AirPortNetworks = [NSMutableArray new];
NSDictionary *AirPortPreferences = [NSDictionary dictionaryWithContentsOfFile:@"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist"];
if ([AirPortPreferences objectForKey:@"KnownNetworks"]!=nil) {// Leopard and above.
NSDictionary *knownNetworks = [AirPortPreferences objectForKey:@"KnownNetworks"];
NSArray *networkKeys = [knownNetworks allKeys];
for (int i=0; i<[networkKeys count]; i++) {
NSDictionary *network = [knownNetworks objectForKey:[networkKeys objectAtIndex:i]];
NSString *SSID = [network objectForKey:@"SSIDString"];
if (SSID==nil) {
SSID = [network objectForKey:@"SSID_STR"];//Leopard
}
[AirPortNetworks addObject:SSID];
}
} else if ([AirPortPreferences objectForKey:@"List of known networks"]!=nil) {// Tiger.
NSArray *knownNetworks = [AirPortPreferences objectForKey:@"List of known networks"];
for (int i=0; i<[knownNetworks count]; i++) {
NSDictionary *network = [knownNetworks objectAtIndex:i];
NSString *SSID = [[[NSString alloc] initWithData:[network objectForKey:@"SSID"] encoding:NSUTF8StringEncoding] autorelease];
[AirPortNetworks addObject:SSID];
}
}
[networksTable reloadData];
}
}
return self;
}
- (void)dealloc {
[view release];
[filtersWindow release];
[networksWindow release];
[AirPortNetworks release];
[super dealloc];
}
+ (void)setUpToolbarItem:(NSToolbarItem *)theItem {
[theItem setLabel:[self title]];
[theItem setPaletteLabel:[theItem label]];
[theItem setImage:[NSImage imageNamed:@"Resize"]];
}
+ (NSString *)title {
return [@"Resize" localized];
}
- (NSView *)preferencesView {
return view;
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)theTableView {
if (theTableView==logicTable) {
return [[controller resizeLogic] count];
} else if (theTableView==filtersTable) {
return [[controller filters] count];
} else if (theTableView==networksTable) {
return [AirPortNetworks count];
}
return 0;
}
- (id)tableView:(NSTableView *)theTableView objectValueForTableColumn:(NSTableColumn *)theTableColumn row:(NSInteger)rowIndex {
if (theTableView==logicTable) {
if ([[theTableColumn identifier] isEqual:@"size"]) {
NSDictionary *resizeLogic = [[controller resizeLogic] objectAtIndex:rowIndex];
if ([[resizeLogic objectForKey:MGMRScale] intValue]!=0) {
return [NSString stringWithFormat:@"%d%%", [[resizeLogic objectForKey:MGMRScale] intValue]];
} else {
return [NSString stringWithFormat:@"%dx%d", [[resizeLogic objectForKey:MGMRWidth] intValue], [[resizeLogic objectForKey:MGMRHeight] intValue]];
}
} else if ([[theTableColumn identifier] isEqual:@"logic"]) {
NSMutableString *result = [NSMutableString string];
NSDictionary *resizeLogic = [[controller resizeLogic] objectAtIndex:rowIndex];
if ([[resizeLogic objectForKey:MGMRFilters] count]!=0 && [[resizeLogic objectForKey:MGMRNetworks] count]!=0) {
[result appendString:@"Some networks and filters"];
} else if ([[resizeLogic objectForKey:MGMRFilters] count]>=1) {
[result appendString:@"Some filters"];
} else if ([[resizeLogic objectForKey:MGMRNetworks] count]>=1) {
if ([[resizeLogic objectForKey:MGMRNetworks] count]==1) {
[result appendFormat:@"Network %@", [[resizeLogic objectForKey:MGMRNetworks] objectAtIndex:0]];
} else {
[result appendFormat:@"Networks including %@", [[resizeLogic objectForKey:MGMRNetworks] objectAtIndex:0]];
}
}
if (![[resizeLogic objectForKey:MGMRIPPrefix] isEqual:@""]) {
if ([result isEqual:@""]) {
[result appendFormat:@"IP Prefix equals %@", [resizeLogic objectForKey:MGMRIPPrefix]];
} else {
[result appendString:@" and an IP Prefix"];
}
}
if ([result isEqual:@""]) {
return @"Anything";
}
return result;
}
} else if (theTableView==filtersTable) {
if ([[theTableColumn identifier] isEqual:@"filter"]) {
return [[[controller filters] objectAtIndex:rowIndex] objectForKey:MGMFFilter];
} else if ([[theTableColumn identifier] isEqual:@"path"]) {
return [[[controller filters] objectAtIndex:rowIndex] objectForKey:MGMFPath];
}
} else if (theTableView==networksTable) {
return [AirPortNetworks objectAtIndex:rowIndex];
}
return @"";
}
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification {
if (aNotification==nil || [aNotification object]==logicTable) {
if ([logicTable selectedRow]>=0) {
currentLogic = [logicTable selectedRow];
NSMutableDictionary *logic = [[controller resizeLogic] objectAtIndex:currentLogic];
[removeButton setEnabled:YES];
[widthField setEditable:YES];
[widthField setIntValue:[[logic objectForKey:MGMRWidth] intValue]];
[heightField setEditable:YES];
[heightField setIntValue:[[logic objectForKey:MGMRHeight] intValue]];
[scaleField setEditable:YES];
[scaleField setIntValue:[[logic objectForKey:MGMRScale] intValue]];
[filtersButton setEnabled:YES];
NSMutableIndexSet *filtersIndexSet = [NSMutableIndexSet indexSet];
for (int i=0; i<[[controller filters] count]; i++) {
if ([[logic objectForKey:MGMRFilters] containsObject:[[[controller filters] objectAtIndex:i] objectForKey:MGMFID]]) {
[filtersIndexSet addIndex:i];
}
}
[filtersTable selectRowIndexes:filtersIndexSet byExtendingSelection:NO];
[networksButton setEnabled:YES];
NSMutableIndexSet *networksIndexSet = [NSMutableIndexSet indexSet];
for (int i=0; i<[AirPortNetworks count]; i++) {
if ([[logic objectForKey:MGMRNetworks] containsObject:[AirPortNetworks objectAtIndex:i]]) {
[networksIndexSet addIndex:i];
}
}
[networksTable selectRowIndexes:networksIndexSet byExtendingSelection:NO];
[IPPrefixField setEditable:YES];
[IPPrefixField setStringValue:[logic objectForKey:MGMRIPPrefix]];
} else {
[removeButton setEnabled:NO];
[widthField setEditable:NO];
[widthField setStringValue:@""];
[heightField setEditable:NO];
[heightField setStringValue:@""];
[scaleField setEditable:NO];
[scaleField setStringValue:@""];
[filtersButton setEnabled:NO];
[networksButton setEnabled:NO];
[IPPrefixField setEditable:NO];
[IPPrefixField setStringValue:@""];
[logicTable reloadData];
}
}
}
- (IBAction)addLogic:(id)sender {
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidString = [(NSString *)CFUUIDCreateString(NULL, uuid) autorelease];
CFRelease(uuid);
[[controller resizeLogic] addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:uuidString, MGMRID, [NSNumber numberWithInt:0], MGMRWidth, [NSNumber numberWithInt:0], MGMRHeight, [NSNumber numberWithInt:0], MGMRScale, [NSMutableArray array], MGMRFilters, [NSMutableArray array], MGMRNetworks, @"", MGMRIPPrefix, nil]];
[logicTable reloadData];
int index = [[controller resizeLogic] count]-1;
[logicTable selectRowIndexes:[NSIndexSet indexSetWithIndex:index] byExtendingSelection:NO];
[NSThread detachNewThreadSelector:@selector(saveResizeLogic) toTarget:controller withObject:nil];
}
- (IBAction)removeLogic:(id)sender {
if ([logicTable selectedRow]>=0) {
int row = [logicTable selectedRow];
[logicTable deselectAll:self];
[[controller resizeLogic] removeObjectAtIndex:row];
[logicTable reloadData];
[NSThread detachNewThreadSelector:@selector(saveResizeLogic) toTarget:controller withObject:nil];
}
}
- (IBAction)selectFilters:(id)sender {
[NSApp beginSheet:filtersWindow modalForWindow:[preferences preferencesWindow] modalDelegate:self didEndSelector:nil contextInfo:nil];
}
- (IBAction)saveFilters:(id)sender {
[NSApp endSheet:filtersWindow];
[filtersWindow orderOut:sender];
NSMutableDictionary *logic = [[controller resizeLogic] objectAtIndex:currentLogic];
NSMutableArray *filters = [logic objectForKey:MGMRFilters];
[filters removeAllObjects];
NSIndexSet *indexSet = [filtersTable selectedRowIndexes];
NSUInteger currentIndex = [indexSet firstIndex];
while (currentIndex!=NSNotFound) {
[filters addObject:[[[controller filters] objectAtIndex:currentIndex] objectForKey:MGMFID]];
currentIndex = [indexSet indexGreaterThanIndex:currentIndex];
}
[NSThread detachNewThreadSelector:@selector(saveResizeLogic) toTarget:controller withObject:nil];
}
- (IBAction)selectNetworks:(id)sender {
[NSApp beginSheet:networksWindow modalForWindow:[preferences preferencesWindow] modalDelegate:self didEndSelector:nil contextInfo:nil];
}
- (IBAction)saveNetworks:(id)sender {
[NSApp endSheet:networksWindow];
[networksWindow orderOut:sender];
NSMutableDictionary *logic = [[controller resizeLogic] objectAtIndex:currentLogic];
NSMutableArray *networks = [logic objectForKey:MGMRNetworks];
[networks removeAllObjects];
NSIndexSet *indexSet = [networksTable selectedRowIndexes];
NSUInteger currentIndex = [indexSet firstIndex];
while (currentIndex!=NSNotFound) {
[networks addObject:[AirPortNetworks objectAtIndex:currentIndex]];
currentIndex = [indexSet indexGreaterThanIndex:currentIndex];
}
[NSThread detachNewThreadSelector:@selector(saveResizeLogic) toTarget:controller withObject:nil];
}
- (IBAction)fieldsChanged:(id)sender {
NSMutableDictionary *logic = [[controller resizeLogic] objectAtIndex:currentLogic];
int width = [widthField intValue];
if (width<0)
width = 0;
[logic setObject:[NSNumber numberWithInt:width] forKey:MGMRWidth];
[widthField setIntValue:width];
int height = [heightField intValue];
if (height<0)
height = 0;
[logic setObject:[NSNumber numberWithInt:height] forKey:MGMRHeight];
[heightField setIntValue:height];
int scale = [scaleField intValue];
if (scale<0)
scale = 0;
if (scale>100)
scale = 100;
[logic setObject:[NSNumber numberWithInt:scale] forKey:MGMRScale];
[scaleField setIntValue:scale];
[logic setObject:[IPPrefixField stringValue] forKey:MGMRIPPrefix];
[NSThread detachNewThreadSelector:@selector(saveResizeLogic) toTarget:controller withObject:nil];
}
@end

2
Classes/HTTP/MGMHTTPPlugIn.m

@ -186,7 +186,7 @@ const BOOL MGMHTTPResponseInvisible = YES;
- (void)sendFileAtPath:(NSString *)thePath withName:(NSString *)theName {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:MGMHTTPURL]==nil) {
if ([defaults objectForKey:MGMHTTPURL]==nil || [[defaults objectForKey:MGMHTTPURL] isEqual:@""]) {
NSError *error = [NSError errorWithDomain:[[NSBundle bundleForClass:[self class]] bundleIdentifier] code:5 userInfo:[NSDictionary dictionaryWithObject:[@"Account is not logged in." localizedFor:self] forKey:NSLocalizedDescriptionKey]];
[[MGMController sharedController] upload:thePath receivedError:error];
return;

26
CocoaShare.xcodeproj/project.pbxproj

@ -43,6 +43,7 @@
2A28115012EBCE4A00435C36 /* AutoUpload.png in Resources */ = {isa = PBXBuildFile; fileRef = 2A28113E12EBCDFC00435C36 /* AutoUpload.png */; };
2A28115112EBCE4A00435C36 /* Events.png in Resources */ = {isa = PBXBuildFile; fileRef = 2A28113F12EBCDFC00435C36 /* Events.png */; };
2A28115212EBCE4A00435C36 /* General.png in Resources */ = {isa = PBXBuildFile; fileRef = 2A28114012EBCDFC00435C36 /* General.png */; };
2A2B36DA1C3C587400D00446 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A2B36D91C3C587400D00446 /* SystemConfiguration.framework */; };
2A2F97A212F05C720069B37E /* FTP.bundle in PlugIns */ = {isa = PBXBuildFile; fileRef = 2A0C8C9412EF844F00A75AB7 /* FTP.bundle */; };
2A2F995412F094F10069B37E /* SFTP.bundle in PlugIns */ = {isa = PBXBuildFile; fileRef = 2A2F994512F094710069B37E /* SFTP.bundle */; };
2A2F996E12F095DA0069B37E /* MGMSFTPPlugIn.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A2F996D12F095DA0069B37E /* MGMSFTPPlugIn.m */; };
@ -70,6 +71,9 @@
2A55259D12F05BA700F97FE6 /* MGMFTPPlugIn.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A0C8CB412EF854D00A75AB7 /* MGMFTPPlugIn.m */; };
2A5C1B0812F2FB5D005153FA /* MGMWebDavPlugIn.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A5C1B0712F2FB5D005153FA /* MGMWebDavPlugIn.m */; };
2A5C1B4912F32EE3005153FA /* WebDav.bundle in PlugIns */ = {isa = PBXBuildFile; fileRef = 2A5C1AF312F2FA6F005153FA /* WebDav.bundle */; };
2A63D4991C346D040048B9FF /* ResizePane.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2A63D49B1C346D040048B9FF /* ResizePane.xib */; };
2A63D49E1C346D4A0048B9FF /* MGMResizePane.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A63D49D1C346D4A0048B9FF /* MGMResizePane.m */; };
2A63D4A01C346FB10048B9FF /* Resize.png in Resources */ = {isa = PBXBuildFile; fileRef = 2A63D49F1C346FB10048B9FF /* Resize.png */; };
2ACA5CD8160E76C700F294C2 /* MGMTinyGrabPlugIn.m in Sources */ = {isa = PBXBuildFile; fileRef = 2ACA5CD7160E76C700F294C2 /* MGMTinyGrabPlugIn.m */; };
2ACA5CF1160E782700F294C2 /* TinyGrabAccountPane.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2ACA5CEB160E782700F294C2 /* TinyGrabAccountPane.xib */; };
2ACA5CF3160E782700F294C2 /* tinygrab.png in Resources */ = {isa = PBXBuildFile; fileRef = 2ACA5CF0160E782700F294C2 /* tinygrab.png */; };
@ -264,6 +268,7 @@
2A28114012EBCDFC00435C36 /* General.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = General.png; sourceTree = "<group>"; };
2A28148112ECD20C00435C36 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
2A28153D12ECE24300435C36 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = usr/lib/libcrypto.dylib; sourceTree = SDKROOT; };
2A2B36D91C3C587400D00446 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
2A2F994512F094710069B37E /* SFTP.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SFTP.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
2A2F996112F095320069B37E /* prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = prefix.pch; path = Classes/SFTP/prefix.pch; sourceTree = "<group>"; };
2A2F996712F0955B0069B37E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -311,6 +316,10 @@
2A5C1B0312F2FB3F005153FA /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/WebDavAccountPane.xib; sourceTree = "<group>"; };
2A5C1B0612F2FB5D005153FA /* MGMWebDavPlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMWebDavPlugIn.h; sourceTree = "<group>"; };
2A5C1B0712F2FB5D005153FA /* MGMWebDavPlugIn.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMWebDavPlugIn.m; sourceTree = "<group>"; };
2A63D49A1C346D040048B9FF /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ResizePane.xib; sourceTree = "<group>"; };
2A63D49C1C346D4A0048B9FF /* MGMResizePane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGMResizePane.h; sourceTree = "<group>"; };
2A63D49D1C346D4A0048B9FF /* MGMResizePane.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGMResizePane.m; sourceTree = "<group>"; };
2A63D49F1C346FB10048B9FF /* Resize.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Resize.png; sourceTree = "<group>"; };
2ACA5CC7160E763A00F294C2 /* TinyGrab.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TinyGrab.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
2ACA5CC8160E763A00F294C2 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
2ACA5CD5160E76B300F294C2 /* prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = prefix.pch; path = Classes/TinyGrab/prefix.pch; sourceTree = "<group>"; };
@ -412,6 +421,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2A2B36DA1C3C587400D00446 /* SystemConfiguration.framework in Frameworks */,
2ACA5CF6160E796B00F294C2 /* Carbon.framework in Frameworks */,
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
2AEAB3F312E2A57400552BAA /* GeckoReporter.framework in Frameworks */,
@ -496,6 +506,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
2A2B36D91C3C587400D00446 /* SystemConfiguration.framework */,
2A48833312E52E9B001618B5 /* Linked Libraries */,
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
2ACA5CC8160E763A00F294C2 /* CoreFoundation.framework */,
@ -789,6 +800,8 @@
2AEAB4BA12E2AF9800552BAA /* MGMAccountPane.m */,
2AEAB4BF12E2AFB100552BAA /* MGMAutoUploadPane.h */,
2AEAB4C012E2AFB100552BAA /* MGMAutoUploadPane.m */,
2A63D49C1C346D4A0048B9FF /* MGMResizePane.h */,
2A63D49D1C346D4A0048B9FF /* MGMResizePane.m */,
2AEAB4C412E2AFC800552BAA /* MGMEventsPane.h */,
2AEAB4C512E2AFC800552BAA /* MGMEventsPane.m */,
);
@ -841,6 +854,8 @@
2A28113D12EBCDFC00435C36 /* Account.png */,
2AEAB4F212E2B2FF00552BAA /* AutoUploadPane.xib */,
2A28113E12EBCDFC00435C36 /* AutoUpload.png */,
2A63D49B1C346D040048B9FF /* ResizePane.xib */,
2A63D49F1C346FB10048B9FF /* Resize.png */,
2AEAB4F412E2B30500552BAA /* EventsPane.xib */,
2A28113F12EBCDFC00435C36 /* Events.png */,
);
@ -1100,6 +1115,7 @@
buildActionMask = 2147483647;
files = (
2A28114F12EBCE4A00435C36 /* Account.png in Resources */,
2A63D4A01C346FB10048B9FF /* Resize.png in Resources */,
2A28115012EBCE4A00435C36 /* AutoUpload.png in Resources */,
2A28115112EBCE4A00435C36 /* Events.png in Resources */,
2A28115212EBCE4A00435C36 /* General.png in Resources */,
@ -1108,6 +1124,7 @@
2AEAB4EF12E2B2F600552BAA /* GeneralPane.xib in Resources */,
2AEAB4F112E2B2FB00552BAA /* AccountPane.xib in Resources */,
2AEAB4F312E2B2FF00552BAA /* AutoUploadPane.xib in Resources */,
2A63D4991C346D040048B9FF /* ResizePane.xib in Resources */,
2A3954E71C3194A700DE02CC /* Multi Upload Themes in Resources */,
2AEAB4F512E2B30500552BAA /* EventsPane.xib in Resources */,
2AEAB53712E2B68300552BAA /* dsa_pub.pem in Resources */,
@ -1218,6 +1235,7 @@
2A0501D512F49A7B000F74EA /* MGMWebDav.m in Sources */,
2A0501D612F49A7B000F74EA /* MGMWebDavAddons.m in Sources */,
2A0501D712F49A7B000F74EA /* MGMWebDavDelete.m in Sources */,
2A63D49E1C346D4A0048B9FF /* MGMResizePane.m in Sources */,
2A0501D812F49A7B000F74EA /* MGMWebDavGet.m in Sources */,
2A0501D912F49A7B000F74EA /* MGMWebDavMkCol.m in Sources */,
2A0501DA12F49A7B000F74EA /* MGMWebDavOptions.m in Sources */,
@ -1354,6 +1372,14 @@
name = twitpicPostWindow.xib;
sourceTree = "<group>";
};
2A63D49B1C346D040048B9FF /* ResizePane.xib */ = {
isa = PBXVariantGroup;
children = (
2A63D49A1C346D040048B9FF /* en */,
);
name = ResizePane.xib;
sourceTree = "<group>";
};
2ACA5CEB160E782700F294C2 /* TinyGrabAccountPane.xib */ = {
isa = PBXVariantGroup;
children = (

2
Resources/CocoaShare/Info.plist

@ -34,7 +34,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.2</string>
<string>0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

1020
Resources/CocoaShare/Preferences/English.lproj/AutoUploadPane.xib
File diff suppressed because it is too large
View File

869
Resources/CocoaShare/Preferences/English.lproj/EventsPane.xib
File diff suppressed because it is too large
View File

38
Resources/CocoaShare/Preferences/English.lproj/GeneralPane.xib

@ -44,7 +44,7 @@
<object class="NSPopUpButton" id="29600608">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{154, 13}, {162, 26}}</string>
<string key="NSFrame">{{154, 17}, {162, 26}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
@ -105,7 +105,7 @@
<object class="NSTextField" id="814224989">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 20}, {133, 17}}</string>
<string key="NSFrame">{{17, 24}, {133, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:526</string>
@ -147,7 +147,7 @@
<object class="NSTextField" id="635325817">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{230, 45}, {60, 17}}</string>
<string key="NSFrame">{{230, 49}, {60, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="814224989"/>
@ -172,7 +172,7 @@
<object class="NSTextField" id="959576106">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{179, 42}, {46, 22}}</string>
<string key="NSFrame">{{179, 46}, {46, 22}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="635325817"/>
@ -206,7 +206,7 @@
<object class="NSTextField" id="399381236">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 45}, {157, 17}}</string>
<string key="NSFrame">{{17, 49}, {157, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="959576106"/>
@ -226,7 +226,7 @@
<object class="NSButton" id="163629106">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{260, 68}, {18, 18}}</string>
<string key="NSFrame">{{260, 72}, {18, 18}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="399381236"/>
@ -256,7 +256,7 @@
<object class="NSTextField" id="820442859">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 70}, {240, 17}}</string>
<string key="NSFrame">{{17, 74}, {240, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="163629106"/>
@ -276,7 +276,7 @@
<object class="NSTextField" id="531055139">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{109, 95}, {122, 17}}</string>
<string key="NSFrame">{{109, 99}, {122, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="820442859"/>
@ -296,7 +296,7 @@
<object class="NSTextField" id="212615851">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{58, 92}, {46, 22}}</string>
<string key="NSFrame">{{58, 96}, {46, 22}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="531055139"/>
@ -317,7 +317,7 @@
<object class="NSTextField" id="275901671">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 95}, {36, 17}}</string>
<string key="NSFrame">{{17, 99}, {36, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="212615851"/>
@ -337,7 +337,7 @@
<object class="NSMatrix" id="493367521">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 122}, {293, 38}}</string>
<string key="NSFrame">{{20, 126}, {293, 38}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="275901671"/>
@ -585,7 +585,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2
<object class="NSTextField" id="201989994">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 165}, {130, 17}}</string>
<string key="NSFrame">{{17, 169}, {130, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="493367521"/>
@ -605,7 +605,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2
<object class="NSButton" id="289845884">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{110, 189}, {18, 18}}</string>
<string key="NSFrame">{{110, 193}, {18, 18}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="201989994"/>
@ -630,7 +630,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2
<object class="NSTextField" id="573272302">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 190}, {90, 17}}</string>
<string key="NSFrame">{{17, 194}, {90, 17}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="289845884"/>