Permalink
Browse files

Implemented 'Current Web Page' proxy object for Firefox (by reading f…

…rom Firefox's sessionstore.js
  • Loading branch information...
1 parent 858a985 commit 5b9b349f88ac5e613a7687aaaeba5681b8cb491c @HenningJ HenningJ committed Nov 20, 2011
Showing with 72 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +22 −0 Info.plist
  3. +1 −0 JSONKit
  4. +1 −0 QSFirefoxPlugIn.h
  5. +27 −0 QSFirefoxPlugIn.m
  6. +18 −0 QSFirefoxPlugIn.xcodeproj/project.pbxproj
View
@@ -1,3 +1,6 @@
[submodule "sqlite-amalgamation"]
path = sqlite-amalgamation
url = https://github.com/mirek/sqlite-amalgamation.git
+[submodule "JSONKit"]
+ path = JSONKit
+ url = https://github.com/johnezang/JSONKit
View
@@ -116,6 +116,28 @@
</array>
<key>QSRegistration</key>
<dict>
+ <key>QSObjectHandlers</key>
+ <dict>
+ <key>QSFirefoxPlugIn</key>
+ <string>QSFirefoxPlugIn</string>
+ </dict>
+ <key>QSProxies</key>
+ <dict>
+ <key>QSFirefoxCurrentWebPageProxy</key>
+ <dict>
+ <key>icon</key>
+ <string>org.mozilla.firefox</string>
+ <key>name</key>
+ <string>Current Web Page (Firefox)</string>
+ <key>providerClass</key>
+ <string>QSFirefoxPlugIn</string>
+ <key>types</key>
+ <array>
+ <string>Apple URL pasteboard type</string>
+ <string>NSStringPboardType</string>
+ </array>
+ </dict>
+ </dict>
<key>QSFSParsers</key>
<dict>
<key>QSFirefoxHistoryParser</key>
Submodule JSONKit added at e3f901
View
@@ -8,6 +8,7 @@
#import <QSCore/QSParser.h>
#import "FMDatabase.h"
#import "FMResultSet.h"
+#import "JSONKit.h"
#define kQSFirefoxPlugInType @"QSFirefoxPlugInType"
View
@@ -16,6 +16,33 @@ - (void) performJavaScript:(NSString *)jScript{
if (errorDict) NSLog(@"Run Script: %@",[errorDict objectForKey:@"NSAppleScriptErrorMessage"]);
}
+- (id)resolveProxyObject:(id)proxy {
+ // reading Firefox's sessionsstore.js
+ NSString *path = [@"~/Library/Application Support/Firefox/Profiles/*/sessionstore.js" stringByResolvingWildcardsInPath];
+ NSError *err;
+ NSString *jsonString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
+ if (!jsonString) {
+ NSLog(@"Error when reading file: %@", err);
+ }
+
+ // parsing JSON
+ NSDictionary *sessionstore = [jsonString objectFromJSONString];
+
+ // traversing JSON path to current web page
+ NSArray *windows = [sessionstore objectForKey:@"windows"];
+ int selectedWindow =[[sessionstore objectForKey:@"selectedWindow"] intValue];
+ NSDictionary *window = [windows objectAtIndex:selectedWindow-1];
+ NSArray *tabs = [window objectForKey:@"tabs"];
+ int selectedTab =[[window objectForKey:@"selected"] intValue];
+ NSDictionary *tab = [tabs objectAtIndex:selectedTab-1];
+ NSArray *entries = [tab objectForKey:@"entries"];
+ NSDictionary *entry = [entries lastObject];
+ NSString *url = [entry objectForKey:@"url"];
+
+ return [QSObject URLObjectWithURL:url title:nil];
+}
+
+
@end
@implementation QSFirefoxBookmarksParser
@@ -16,6 +16,7 @@
2EE7043814795FF2006EBF76 /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EE7043414795FF2006EBF76 /* FMDatabaseAdditions.m */; };
2EE7043914795FF2006EBF76 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EE7043614795FF2006EBF76 /* FMResultSet.m */; };
2EE7047214796D4C006EBF76 /* QSParser.name.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2EE7047114796D4C006EBF76 /* QSParser.name.strings */; };
+ 2EE7058714797D3D006EBF76 /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EE7058314797D31006EBF76 /* JSONKit.m */; };
8D1AC9700486D14A00FE50C9 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD92D38A0106425D02CA0E72 /* Cocoa.framework */; };
E1EAB046068128A200774DFF /* QSFirefoxPlugIn.m in Sources */ = {isa = PBXBuildFile; fileRef = E1EAB045068128A200774DFF /* QSFirefoxPlugIn.m */; };
/* End PBXBuildFile section */
@@ -42,6 +43,10 @@
2EE7043514795FF2006EBF76 /* FMResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMResultSet.h; sourceTree = "<group>"; };
2EE7043614795FF2006EBF76 /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMResultSet.m; sourceTree = "<group>"; };
2EE7047114796D4C006EBF76 /* QSParser.name.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = QSParser.name.strings; sourceTree = "<group>"; };
+ 2EE7058114797D31006EBF76 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGELOG.md; sourceTree = "<group>"; };
+ 2EE7058214797D31006EBF76 /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = "<group>"; };
+ 2EE7058314797D31006EBF76 /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = "<group>"; };
+ 2EE7058414797D31006EBF76 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
8D1AC9730486D14A00FE50C9 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1AC9740486D14A00FE50C9 /* Firefox Module.qsplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Firefox Module.qsplugin"; sourceTree = BUILT_PRODUCTS_DIR; };
DD92D38A0106425D02CA0E72 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
@@ -144,10 +149,22 @@
path = FMDB;
sourceTree = "<group>";
};
+ 2EE7055B14797D30006EBF76 /* JSONKit */ = {
+ isa = PBXGroup;
+ children = (
+ 2EE7058114797D31006EBF76 /* CHANGELOG.md */,
+ 2EE7058214797D31006EBF76 /* JSONKit.h */,
+ 2EE7058314797D31006EBF76 /* JSONKit.m */,
+ 2EE7058414797D31006EBF76 /* README.md */,
+ );
+ path = JSONKit;
+ sourceTree = "<group>";
+ };
32DBCF9E0370C38000C91783 /* Classes */ = {
isa = PBXGroup;
children = (
2EE7043014795FF2006EBF76 /* FMDB */,
+ 2EE7055B14797D30006EBF76 /* JSONKit */,
2EE7040D14795AD7006EBF76 /* SQLite */,
E1EAB047068128A800774DFF /* QSFirefoxPlugIn.h */,
E1EAB045068128A200774DFF /* QSFirefoxPlugIn.m */,
@@ -233,6 +250,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 2EE7058714797D3D006EBF76 /* JSONKit.m in Sources */,
E1EAB046068128A200774DFF /* QSFirefoxPlugIn.m in Sources */,
2EE7040114795ACE006EBF76 /* sqlite3.c in Sources */,
2EE7043714795FF2006EBF76 /* FMDatabase.m in Sources */,

0 comments on commit 5b9b349

Please sign in to comment.