summaryrefslogtreecommitdiff
path: root/src/haiku_support.cc
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-09-14 06:24:49 +0000
committerPo Lu <luangruo@yahoo.com>2022-09-14 06:25:11 +0000
commitb9ca1a8e4fbd3f8ef0d384d402ec5721ddcad28c (patch)
treeb7ed77f1c3091a68229779e9edef3a7b14ea70b7 /src/haiku_support.cc
parentf0798ac13dcb4c01a883f165e03c3cd7f208667c (diff)
downloademacs-b9ca1a8e4fbd3f8ef0d384d402ec5721ddcad28c.tar.gz
Implement wallpaper.el support for Haiku
* lisp/image/wallpaper.el (haiku-set-wallpaper, wallpaper-set): Use `haiku-set-wallpaper' on Haiku. * lisp/term/haiku-win.el (haiku-write-node-attribute) (haiku-send-message, haiku-set-wallpaper): New function. * src/haiku_support.cc (be_write_node_message, be_send_message): New functions. * src/haiku_support.h: Update prototypes. * src/haikuselect.c (haiku_message_to_lisp) (haiku_lisp_to_message): Fix CSTR type handling to include NULL byte. (haiku_report_system_error, Fhaiku_write_node_attribute) (Fhaiku_send_message): New functions. (syms_of_haikuselect): Add defsubrs.
Diffstat (limited to 'src/haiku_support.cc')
-rw-r--r--src/haiku_support.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 983928442a1..0f8e26d0db4 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -54,12 +54,14 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <game/WindowScreen.h>
#include <game/DirectWindow.h>
+#include <storage/FindDirectory.h>
#include <storage/Entry.h>
#include <storage/Path.h>
#include <storage/FilePanel.h>
#include <storage/AppFileInfo.h>
#include <storage/Path.h>
#include <storage/PathFinder.h>
+#include <storage/Node.h>
#include <support/Beep.h>
#include <support/DataIO.h>
@@ -5501,3 +5503,54 @@ be_set_use_frame_synchronization (void *view, bool sync)
vw = (EmacsView *) view;
vw->SetFrameSynchronization (sync);
}
+
+status_t
+be_write_node_message (const char *path, const char *name, void *message)
+{
+ BNode node (path);
+ status_t rc;
+ ssize_t flat, result;
+ char *buffer;
+ BMessage *msg;
+
+ rc = node.InitCheck ();
+ msg = (BMessage *) message;
+
+ if (rc < B_OK)
+ return rc;
+
+ flat = msg->FlattenedSize ();
+ if (flat < B_OK)
+ return flat;
+
+ buffer = new (std::nothrow) char[flat];
+ if (!buffer)
+ return B_NO_MEMORY;
+
+ rc = msg->Flatten (buffer, flat);
+ if (rc < B_OK)
+ {
+ delete[] buffer;
+ return rc;
+ }
+
+ result = node.WriteAttr (name, B_MIME_TYPE, 0,
+ buffer, flat);
+ delete[] buffer;
+
+ if (result < B_OK)
+ return result;
+
+ if (result != flat)
+ return B_ERROR;
+
+ return B_OK;
+}
+
+void
+be_send_message (const char *app_id, void *message)
+{
+ BMessenger messenger (app_id);
+
+ messenger.SendMessage ((BMessage *) message);
+}