Permalink
Browse files

Updated for ARC, Xcode 5, 64-bit. Other small fixes.

  • Loading branch information...
1 parent 3b7e1f7 commit 400b8061ff6c0247842b20a81e1fe21500da2cb2 @tjw tjw committed Sep 18, 2013
View
2 Source/English.lproj/Localized.strings
@@ -1,4 +1,4 @@
-"_EditPattern" = "%@ in %@" ;
+"_EditPattern" = "%1$@ in %2$@" ;
"_EditMultiple" = "Edit LinkBack Items" ;
"_EditNone" = "Edit LinkBack Item" ;
"_Edit" = "Edit" ;
View
10 Source/LinkBack.h
@@ -33,8 +33,10 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
+#import <Foundation/NSDictionary.h>
+#import <Foundation/NSDate.h>
-#import <Cocoa/Cocoa.h>
+@class NSPasteboard;
// Use this pasteboard type to put LinkBack data to the pasteboard. Use MakeLinkBackData() to create the data.
extern NSString* LinkBackPboardType ;
@@ -46,9 +48,9 @@ extern NSString* LinkBackRefreshActionName ;
//
// Support Functions
//
-NSString* LinkBackUniqueItemKey() ;
-NSString* LinkBackEditMultipleMenuTitle() ;
-NSString* LinkBackEditNoneMenuTitle() ;
+extern NSString* LinkBackUniqueItemKey(void);
+extern NSString* LinkBackEditMultipleMenuTitle(void);
+extern NSString* LinkBackEditNoneMenuTitle(void);
//
// Deprecated Support Functions -- use LinkBack Data Category instead
View
20 Source/LinkBack.m
@@ -65,7 +65,7 @@ id LinkBackGetAppData(id LinkBackData)
return [LinkBackData linkBackAppData] ;
}
-NSString* LinkBackUniqueItemKey()
+NSString* LinkBackUniqueItemKey(void)
{
static int counter = 0 ;
@@ -79,14 +79,14 @@ BOOL LinkBackDataBelongsToActiveApplication(id data)
return [data linkBackDataBelongsToActiveApplication] ;
}
-NSString* LinkBackEditMultipleMenuTitle()
+NSString* LinkBackEditMultipleMenuTitle(void)
{
NSBundle* bundle = [NSBundle bundleForClass: [LinkBack class]] ;
NSString* ret = [bundle localizedStringForKey: @"_EditMultiple" value: @"Edit LinkBack Items" table: @"Localized"] ;
return ret ;
}
-NSString* LinkBackEditNoneMenuTitle()
+NSString* LinkBackEditNoneMenuTitle(void)
{
NSBundle* bundle = [NSBundle bundleForClass: [LinkBack class]] ;
NSString* ret = [bundle localizedStringForKey: @"_EditNone" value: @"Edit LinkBack Item" table: @"Localized"] ;
@@ -233,11 +233,9 @@ - (id)initServerWithClient: (LinkBack*)aLinkBack delegate: (id<LinkBackServerDel
isServer = YES ;
delegate = aDel ;
[keyedLinkBacks setObject: self forKey: key] ;
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(connectionDidDie:)
- name:NSConnectionDidDieNotification
- object:[(NSDistantObject *)peer connectionForProxy]];
+ if ([peer isKindOfClass:[NSDistantObject class]])
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(connectionDidDie:) name:NSConnectionDidDieNotification object:[(NSDistantObject *)peer connectionForProxy]];
+
return self ;
}
@@ -316,21 +314,19 @@ - (void)closeLink
// note we can get an incoming -remoteCloseLink while we're calling the other side's closeLink
peer = nil ;
delegate = nil ;
- [self release] ;
[keyedLinkBacks removeObjectForKey: [self itemKey]];
[closingPeer remoteCloseLink] ;
[closingPeer release] ;
}
}
// this method is called whenever the link is about to be or has been closed by the other side.
-- (void)remoteCloseLink
+- (oneway void)remoteCloseLink
{
if (peer) {
[peer release] ;
peer = nil ;
- [self release] ;
- [keyedLinkBacks removeObjectForKey: [self itemKey]];
+ [keyedLinkBacks removeObjectForKey: [self itemKey]];
}
if (delegate) [delegate linkBackDidClose: self] ;
View
17 Source/LinkBack.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 42;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -204,8 +204,11 @@
/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0500;
+ };
buildConfigurationList = 4A8BBBD608AB123000C5998B /* Build configuration list for PBXProject "LinkBack" */;
- compatibilityVersion = "Xcode 2.4";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -272,10 +275,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 4A8BBBEB08AB131E00C5998B /* Omni-Framework-Debug.xcconfig */;
buildSettings = {
- GCC_PREPROCESSOR_DEFINITIONS = (
- DEBUG,
- "DEBUG_$(USER)",
- );
+ INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = LinkBack;
};
name = Debug;
@@ -284,6 +284,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 4A8BBBEC08AB131E00C5998B /* Omni-Framework-Release.xcconfig */;
buildSettings = {
+ INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = LinkBack;
};
name = Release;
@@ -292,6 +293,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 4A8BBBEA08AB131E00C5998B /* Omni-Framework-Coverage.xcconfig */;
buildSettings = {
+ INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = LinkBack;
};
name = Coverage;
@@ -302,6 +304,7 @@
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = NO;
GCC_PREFIX_HEADER = "";
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
};
name = Debug;
};
@@ -311,6 +314,7 @@
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = NO;
GCC_PREFIX_HEADER = "";
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
};
name = Release;
};
@@ -320,6 +324,7 @@
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = NO;
GCC_PREFIX_HEADER = "";
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
};
name = Coverage;
};
View
27 Source/LinkBackServer.m
@@ -84,7 +84,7 @@ + (BOOL)publishServerWithName:(NSString*)aName bundleIdentifier:(NSString *)bund
return ret ;
}
-BOOL LinkBackServerIsSupported(NSString* name, id supportedServers)
+static BOOL LinkBackServerIsSupported(NSString* name, id supportedServers)
{
BOOL ret = NO ;
NSUInteger idx ;
@@ -104,7 +104,7 @@ BOOL LinkBackServerIsSupported(NSString* name, id supportedServers)
return ret ;
}
-NSString* FindLinkBackServer(NSString* bundleIdentifier, NSString* serverName, NSString* dir, int level, NSString **altServerPathPtr)
+static NSString* FindLinkBackServer(NSString* bundleIdentifier, NSString* serverName, NSString* dir, int level, NSString **altServerPathPtr)
{
NSString* ret = nil ;
@@ -171,7 +171,7 @@ BOOL LinkBackServerIsSupported(NSString* name, id supportedServers)
return ret ;
}
-void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
+static void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
{
NSInteger result ;
@@ -199,14 +199,18 @@ void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
+ (LinkBackServer*)LinkBackServerWithName:(NSString*)aName inApplication:(NSString*)bundleIdentifier launchIfNeeded:(BOOL)flag fallbackURL:(NSURL*)url appName:(NSString*)appName ;
{
- BOOL connect = YES ;
NSString* serverName = MakeLinkBackServerName(bundleIdentifier, aName) ;
id ret = nil ;
- NSTimeInterval tryMark ;
-
+
+ // Is this our own server?
+ ret = [LinkBackServers objectForKey:serverName];
+ if (ret != nil)
+ return ret;
+
// Try to connect
ret = [NSConnection rootProxyForConnectionWithRegisteredName: serverName host: nil] ;
-
+ BOOL connect = YES ;
+
// if launchIfNeeded, and the connection was not available, try to launch.
if((!ret) && (flag)) {
NSString* appPath ;
@@ -245,7 +249,7 @@ + (LinkBackServer*)LinkBackServerWithName:(NSString*)aName inApplication:(NSStri
// if needed, try to connect.
// retry connection for a while if we did not succeed at first. This gives the app time to launch.
if (connect && (nil==ret)) {
- tryMark = [NSDate timeIntervalSinceReferenceDate] ;
+ NSTimeInterval tryMark = [NSDate timeIntervalSinceReferenceDate] ;
do {
ret = [NSConnection rootProxyForConnectionWithRegisteredName: serverName host: nil] ;
} while ((!ret) && (([NSDate timeIntervalSinceReferenceDate]-tryMark)<10)) ;
@@ -293,9 +297,9 @@ - (BOOL)publish
// if successful, retain connection and add self to list of servers.
if (ret) {
[listener retain] ;
- [LinkBackServers setObject: self forKey: serverName] ;
- } else listener = nil ; // listener will dealloc on its own.
+ } else listener = nil ; // listener will dealloc on its own.
+ [LinkBackServers setObject: self forKey: serverName] ; // Always keep track of our published servers
return ret ;
}
@@ -317,7 +321,8 @@ - (LinkBack*)initiateLinkBackFromClient:(LinkBack*)clientLinkBack
// NOTE: we do not release because LinkBack will release itself when it the link closes. (caj)
// But we need to pretend to release to hack around clang:
- objc_msgSend(ret, @selector(retain));
+ void (*imp)(id, SEL) = (typeof(imp))objc_msgSend;
+ imp(ret, @selector(retain));
[ret autorelease];
return ret ;

0 comments on commit 400b806

Please sign in to comment.