[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a96f6de544: Allow dragging messages with file names on Haiku
From: |
Po Lu |
Subject: |
master a96f6de544: Allow dragging messages with file names on Haiku |
Date: |
Fri, 18 Mar 2022 01:52:19 -0400 (EDT) |
branch: master
commit a96f6de5447f296dbadc90de9a1157062e9ba491
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
src/haiku_select.cc | 17 +++++++++++++++++
src/haikuselect.c | 5 ++++-
src/haikuselect.h | 2 ++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/haiku_select.cc b/src/haiku_select.cc
index 4212f60a48..9012639d6a 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 7474ff1232..807cbc2493 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 366890d1a4..4869d9d33c 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a96f6de544: Allow dragging messages with file names on Haiku,
Po Lu <=