From: Po Lu Date: Fri, 18 Mar 2022 05:48:10 +0000 (+0000) Subject: Allow dragging messages with file names on Haiku X-Git-Tag: emacs-29.0.90~1931^2~1056 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a96f6de5447f296dbadc90de9a1157062e9ba491;p=emacs.git Allow dragging messages with file names on Haiku * src/haiku_select.cc (be_add_refs_data): New function. * src/haikuselect.c (haiku_lisp_to_message): Handle `ref' type correctly. * src/haikuselect.h: Update prototypes. --- diff --git a/src/haiku_select.cc b/src/haiku_select.cc index 4212f60a480..9012639d6af 100644 --- a/src/haiku_select.cc +++ b/src/haiku_select.cc @@ -337,3 +337,20 @@ be_add_message_data (void *message, const char *name, return msg->AddData (name, type_code, buf, buf_size) != B_OK; } + +int +be_add_refs_data (void *message, const char *name, + const char *filename) +{ + BEntry entry (filename); + entry_ref ref; + BMessage *msg = (BMessage *) message; + + if (entry.InitCheck () != B_OK) + return 1; + + if (entry.GetRef (&ref) != B_OK) + return 1; + + return msg->AddRef (name, &ref) != B_OK; +} diff --git a/src/haikuselect.c b/src/haikuselect.c index 7474ff12327..807cbc24939 100644 --- a/src/haikuselect.c +++ b/src/haikuselect.c @@ -378,7 +378,10 @@ haiku_lisp_to_message (Lisp_Object obj, void *message) switch (type_code) { case 'RREF': - signal_error ("Cannot deserialize data type", type_sym); + CHECK_STRING (data); + + if (be_add_refs_data (message, SSDATA (name), SSDATA (data))) + signal_error ("Invalid file name", data); break; case 'SHRT': diff --git a/src/haikuselect.h b/src/haikuselect.h index 366890d1a46..4869d9d33c2 100644 --- a/src/haikuselect.h +++ b/src/haikuselect.h @@ -91,6 +91,8 @@ extern "C" extern int be_add_message_data (void *message, const char *name, int32 type_code, const void *buf, ssize_t buf_size); + extern int be_add_refs_data (void *message, const char *name, + const char *filename); #ifdef __cplusplus }; #endif