Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Configuration/Common.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARCHS = $(ARCHS_STANDARD)
MACOSX_DEPLOYMENT_TARGET = 11.0
FRAMEWORK_SEARCH_PATHS = /Applications/Quicksilver.app/Contents/Frameworks
INFOPLIST_FILE = Info.plist
PRODUCT_NAME = Social Bookmarks Plugin
WRAPPER_EXTENSION = qsplugin
ALWAYS_SEARCH_USER_PATHS = NO
CLANG_ENABLE_OBJC_ARC = NO
GCC_PREFIX_HEADER = Configuration/Quicksilver.pch
GCC_PRECOMPILE_PREFIX_HEADER = YES
2 changes: 2 additions & 0 deletions Configuration/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "Common.xcconfig"
GCC_OPTIMIZATION_LEVEL = 0
1 change: 1 addition & 0 deletions Configuration/QSPlugIn.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "Common.xcconfig"
5 changes: 5 additions & 0 deletions Configuration/Quicksilver.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#import <QSFoundation/QSFoundation.h>
#import <QSCore/QSCore.h>
#endif
3 changes: 3 additions & 0 deletions Configuration/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "Common.xcconfig"
GCC_OPTIMIZATION_LEVEL = s
COPY_PHASE_STRIP = YES
20 changes: 17 additions & 3 deletions QSDeliciousPlugIn.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
E182BCD006FC8203007BF2C2 /* QSDeliciousPlugIn_Source.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = QSDeliciousPlugIn_Source.m; sourceTree = "<group>"; };
E182BE2206FC9AB5007BF2C2 /* QSDeliciousPrefPane.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = QSDeliciousPrefPane.h; sourceTree = "<group>"; };
E182BE2306FC9AB5007BF2C2 /* QSDeliciousPrefPane.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = QSDeliciousPrefPane.m; sourceTree = "<group>"; };
E182BE3B06FC9B13007BF2C2 /* en */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
E182BE3B06FC9B13007BF2C2 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
E182BE5A06FC9C46007BF2C2 /* PreferencePanes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PreferencePanes.framework; path = /System/Library/Frameworks/PreferencePanes.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -139,8 +139,8 @@
D475F9B418B2992D0012243C /* Release.xcconfig */,
);
name = Configuration;
path = /private/tmp/QS/Configuration;
sourceTree = "<absolute>";
path = Configuration;
sourceTree = "<group>";
};
/* End PBXGroup section */

Expand Down Expand Up @@ -254,6 +254,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D475F9B218B2992D0012243C /* QSPlugIn.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ZERO_LINK = YES;
};
name = Debug;
Expand All @@ -262,6 +263,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D475F9B218B2992D0012243C /* QSPlugIn.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ZERO_LINK = NO;
};
name = Release;
Expand All @@ -270,13 +272,25 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D475F9B018B2992D0012243C /* Debug.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
FRAMEWORK_SEARCH_PATHS = /Applications/Quicksilver.app/Contents/Frameworks;
INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = "Social Bookmarks Plugin";
WRAPPER_EXTENSION = qsplugin;
MACOSX_DEPLOYMENT_TARGET = 11.0;
};
name = Debug;
};
7F07AFB0085E432E00E2AFC4 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = D475F9B418B2992D0012243C /* Release.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
FRAMEWORK_SEARCH_PATHS = /Applications/Quicksilver.app/Contents/Frameworks;
INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = "Social Bookmarks Plugin";
WRAPPER_EXTENSION = qsplugin;
MACOSX_DEPLOYMENT_TARGET = 11.0;
};
name = Release;
};
Expand Down
4 changes: 3 additions & 1 deletion QSDeliciousPlugIn_Source.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//


#import "QSDeliciousPlugIn_Source.h"
#import <Cocoa/Cocoa.h>
#import <QSFoundation/QSFoundation.h>
#import <QSCore/QSCore.h>

@interface QSDeliciousPlugIn_Source : QSObjectSource <NSXMLParserDelegate> {
NSMutableArray *posts;
Expand Down
100 changes: 86 additions & 14 deletions QSDeliciousPlugIn_Source.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,57 @@ - (NSString *) mainNibName {
}

- (void)populateFields {
NSLog(@"populating: %@/%@", [self.selectedEntry.sourceSettings objectForKey:@"username"], [self.selectedEntry.sourceSettings objectForKey:@"site"]);
NSMutableDictionary *settings = self.selectedEntry.sourceSettings;
NSLog(@"QSDelicious: populateFields, settings=%@", settings);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to log any sensitive information?


NSString *username = [settings objectForKey:@"username"];
if (username)
[userField setStringValue:username];
else
[userField setStringValue:@""];
[userField unbind:@"value"];
[userField setEditable:YES];
[userField setSelectable:YES];
[userField setTarget:self];
[userField setAction:@selector(saveUsername:)];

NSView *container = [self settingsView];
for (NSView *subview in [container subviews]) {
if ([subview isKindOfClass:[NSPopUpButton class]]) {
NSPopUpButton *popup = (NSPopUpButton *)subview;
[popup unbind:@"selectedTag"];
NSInteger siteIdx = [settings objectForKey:@"site"] != nil ? [[settings objectForKey:@"site"] integerValue] : 0;
[popup selectItemAtIndex:siteIdx];
[popup setTarget:self];
[popup setAction:@selector(saveSite:)];
} else if ([subview isKindOfClass:[NSButton class]] && [[subview cell] isKindOfClass:[NSButtonCell class]]) {
NSButton *button = (NSButton *)subview;
if ([[button title] containsString:@"tag"] || [[button title] containsString:@"Tag"]) {
[button unbind:@"value"];
BOOL includeTags = [[settings objectForKey:@"includeTags"] boolValue];
[button setState:includeTags ? NSControlStateValueOn : NSControlStateValueOff];
[button setTarget:self];
[button setAction:@selector(saveIncludeTags:)];
}
}
}
}

- (void)saveUsername:(id)sender {
[self.selectedEntry.sourceSettings setObject:[userField stringValue] forKey:@"username"];
[[NSNotificationCenter defaultCenter] postNotificationName:QSCatalogEntryChangedNotification object:self.selectedEntry];
}

- (void)saveSite:(id)sender {
NSPopUpButton *popup = (NSPopUpButton *)sender;
[self.selectedEntry.sourceSettings setObject:[NSNumber numberWithInteger:[popup indexOfSelectedItem]] forKey:@"site"];
[[NSNotificationCenter defaultCenter] postNotificationName:QSCatalogEntryChangedNotification object:self.selectedEntry];
}

- (void)saveIncludeTags:(id)sender {
NSButton *button = (NSButton *)sender;
[self.selectedEntry.sourceSettings setObject:[NSNumber numberWithBool:([button state] == NSControlStateValueOn)] forKey:@"includeTags"];
[[NSNotificationCenter defaultCenter] postNotificationName:QSCatalogEntryChangedNotification object:self.selectedEntry];
}

- (NSView *) settingsView {
Expand Down Expand Up @@ -220,24 +270,46 @@ - (NSData *)cachedBookmarkData {
}

- (NSData *)bookmarkData {
if (![self currentUsername] || ![self currentPassword]) return nil;

NSString *urlString = [NSString stringWithFormat:@"https://%@:%@@%@/posts/all?", [self currentUsername], [self currentPassword], [self currentAPIURL]];
NSLog(@"QSDelicious: siteIndex=%ld apiURL=%@ username=%@", (long)[self siteIndex], [self currentAPIURL], [self currentUsername]);
if (![self currentUsername] || ![self currentPassword]) {
NSLog(@"QSDelicious: missing username or password");
return nil;
}

NSString *urlString = [NSString stringWithFormat:@"https://%@/posts/all", [self currentAPIURL]];
NSURL *requestURL = [NSURL URLWithString:urlString];

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:requestURL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
[theRequest setValue:@"Quicksilver (Blacktree,MacOSX)" forHTTPHeaderField:@"User-Agent"];

NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:&error];

[theRequest setHTTPMethod:@"GET"];

NSString *credentials = [NSString stringWithFormat:@"%@:%@", [self currentUsername], [self currentPassword]];
NSData *credData = [credentials dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64 = [credData base64EncodedStringWithOptions:0];
[theRequest setValue:[NSString stringWithFormat:@"Basic %@", base64] forHTTPHeaderField:@"Authorization"];
[theRequest setValue:@"Quicksilver (Blacktree,MacOSX)" forHTTPHeaderField:@"User-Agent"];

NSURLResponse *response = nil;
NSError *error = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];

if (error) {
NSLog(@"QSDelicious: fetch error: %@", error);
return nil;
}

NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSLog(@"QSDelicious: HTTP %ld, received %lu bytes", (long)[httpResponse statusCode], (unsigned long)[data length]);

if ([httpResponse statusCode] != 200) {
NSLog(@"QSDelicious: response body: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
return nil;
}

NSString *cachePath = [QSApplicationSupportSubPath([NSString stringWithFormat:@"Caches/%@/", [self currentSiteURL]], YES) stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.xml", [self currentUsername]]];
[data writeToFile:cachePath atomically:NO];
[data writeToFile:cachePath atomically:NO];

return data;
}

Expand Down