Revision: 13794
          http://sourceforge.net/p/skim-app/code/13794
Author:   hofman
Date:     2023-11-24 14:48:12 +0000 (Fri, 24 Nov 2023)
Log Message:
-----------
change XPC agent protocol, pass URL and may return NSString

Modified Paths:
--------------
    trunk/SkimNotes/SKNAgentListener.m
    trunk/SkimNotes/SKNXPCAgentListenerProtocol.h
    trunk/SkimNotes/skimnotes.m

Modified: trunk/SkimNotes/SKNAgentListener.m
===================================================================
--- trunk/SkimNotes/SKNAgentListener.m  2023-11-24 10:14:04 UTC (rev 13793)
+++ trunk/SkimNotes/SKNAgentListener.m  2023-11-24 14:48:12 UTC (rev 13794)
@@ -37,6 +37,7 @@
 
 #import "SKNAgentListener.h"
 #import "SKNAgentListenerProtocol.h"
+#import "SKNXPCAgentListenerProtocol.h"
 #import "NSFileManager_SKNToolExtensions.h"
 
 
@@ -242,7 +243,7 @@
 
 #pragma mark SKNXPCAgentListenerProtocol
 
-- (void)SkimNotesAtPath:(NSString *)aFile reply:(void (^)(NSData *))reply
+- (void)readSkimNotesAtPath:(NSString *)aFile reply:(void (^)(NSData *))reply
 {
     NSError *error = nil;
     NSData *data = [[NSFileManager defaultManager] SkimNotesAtPath:aFile 
error:&error];
@@ -251,7 +252,7 @@
     reply(data);
 }
 
-- (void)RTFNotesAtPath:(NSString *)aFile reply:(void (^)(NSData *))reply
+- (void)readRTFNotesAtPath:(NSString *)aFile reply:(void (^)(NSData *))reply
 {
     NSError *error = nil;
     NSData *data = [[NSFileManager defaultManager] SkimRTFNotesAtPath:aFile 
error:&error];
@@ -260,14 +261,13 @@
     reply(data);
 }
 
-- (void)textNotesAtPath:(NSString *)aFile encoding:(NSStringEncoding)encoding 
reply:(void (^)(NSData *))reply
+- (void)readTextNotesAtPath:(NSString *)aFile reply:(void (^)(NSString *))reply
 {
     NSError *error = nil;
     NSString *string = [[NSFileManager defaultManager] 
SkimTextNotesAtPath:aFile error:&error];
     if (nil == string)
         fprintf(stderr, "skimnotes agent pid %d: error getting text notes 
(%s)\n", getpid(), [[error description] UTF8String]);
-    // Returning the string directly can fail under some conditions.  For some 
strings with corrupt copy-paste characters (typical for notes), -[NSString 
canBeConvertedToEncoding:NSUTF8StringEncoding] returns YES but the actual 
conversion fails.  A result seems to be that encoding the string also fails, 
which causes the DO client to get a timeout.  Returning NSUnicodeStringEncoding 
data seems to work in those cases (and is safe since we're not going over the 
wire between big/little-endian systems).
-    reply([string dataUsingEncoding:encoding]);
+    reply(string);
 }
 
 @end

Modified: trunk/SkimNotes/SKNXPCAgentListenerProtocol.h
===================================================================
--- trunk/SkimNotes/SKNXPCAgentListenerProtocol.h       2023-11-24 10:14:04 UTC 
(rev 13793)
+++ trunk/SkimNotes/SKNXPCAgentListenerProtocol.h       2023-11-24 14:48:12 UTC 
(rev 13794)
@@ -38,8 +38,8 @@
 
 @protocol SKNXPCAgentListenerProtocol
 
-- (void)SkimNotesAtPath:(NSString *)aFile reply:(void (^)(NSData *))reply;
-- (void)RTFNotesAtPath:(NSString *)aFile reply:(void (^)(NSData *))reply;
-- (void)textNotesAtPath:(NSString *)aFile encoding:(NSStringEncoding)encoding 
reply:(void (^)(NSData *))reply;
+- (void)readSkimNotesAtURL:(NSURL *)aURL reply:(void (^)(NSData *))reply;
+- (void)readRTFNotesAtURL:(NSURL *)aURL reply:(void (^)(NSData *))reply;
+- (void)readTextNotesAtURL:(NSURL *)aFaURLile reply:(void (^)(NSString 
*))reply;
 
 @end

Modified: trunk/SkimNotes/skimnotes.m
===================================================================
--- trunk/SkimNotes/skimnotes.m 2023-11-24 10:14:04 UTC (rev 13793)
+++ trunk/SkimNotes/skimnotes.m 2023-11-24 14:48:12 UTC (rev 13794)
@@ -111,9 +111,9 @@
                            "@end";
 
 static char *xpcProtocolStr = "@protocol SKNAgentListenerProtocol\n"
-                              "- (void)SkimNotesAtPath:(NSString *)aFile 
reply:(void (^)(NSData *))reply;\n"
-                              "- (void)RTFNotesAtPath:(NSString *)aFile 
reply:(void (^)(NSData *))reply;\n"
-                              "- (void)textNotesAtPath:(NSString *)aFile 
encoding:(NSStringEncoding)encoding reply:(void (^)(NSData *))reply;\n"
+                              "- (void)readSkimNotesAttURL:(NSURL *)aURL 
reply:(void (^)(NSData *))reply;\n"
+                              "- (void)readRTFNotesAtURL:(NSURL *)aURL 
reply:(void (^)(NSData *))reply;\n"
+                              "- (void)readTextNotesAtURL:(NSURL *)aURL 
reply:(void (^)(NSString *))reply;\n"
                              "@end";
 
 #define ACTION_GET_STRING       @"get"

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to