xref: /haiku/src/kits/support/Beep.cpp (revision 33c487a43ef76dc033ad943df4d5bdbbe9298d83)
1 /*
2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
4 */
5 
6 
7 #include <Beep.h>
8 #include <stdio.h>
9 
10 #include "DataExchange.h"
11 
12 
13 status_t
14 system_beep(const char *eventName)
15 {
16 	BMessenger messenger("application/x-vnd.Be.media-server");
17 	if (!messenger.IsValid())
18 		return B_ERROR;
19 	BMessage msg(MEDIA_SERVER_SYSTEM_BEEP_EVENT), reply;
20 	msg.AddInt32("action", SYSTEM_BEEP_EVENT_INVOKE);
21 	msg.AddString("event", eventName);
22 
23 	status_t err = messenger.SendMessage(&msg, &reply);
24 	if ((err != B_OK)
25 		|| (reply.FindInt32("error", &err) != B_OK))
26 		err = B_BAD_REPLY;
27 	return err;
28 }
29 
30 
31 status_t
32 beep()
33 {
34 	return system_beep(NULL);
35 }
36 
37 
38 status_t
39 add_system_beep_event(const char *eventName, uint32 flags)
40 {
41 	BMessenger messenger("application/x-vnd.Be.media-server");
42 	if (!messenger.IsValid())
43 		return B_ERROR;
44 	BMessage msg(MEDIA_SERVER_SYSTEM_BEEP_EVENT), reply;
45 	msg.AddInt32("action", SYSTEM_BEEP_EVENT_ADD);
46 	msg.AddString("event", eventName);
47 	msg.AddInt32("flags", flags);
48 
49 	status_t err = messenger.SendMessage(&msg, &reply);
50 	if ((err != B_OK)
51 		|| (reply.FindInt32("error", &err) != B_OK))
52 		err = B_BAD_REPLY;
53 	return err;
54 }
55 
56