1/*
2 * Copyright 2004-2009, Axel D��rfler, axeld@pinc-software.de.
3 * Copyright 2007, J��r��me Duval. All rights reserved.
4 * Distributed under the terms of the MIT License.
5 */
6
7
8#include <Beep.h>
9
10#include <stdio.h>
11
12#include <DataExchange.h>
13#include <MediaSounds.h>
14
15
16status_t
17system_beep(const char* eventName)
18{
19	BMessenger messenger("application/x-vnd.Be.addon-host");
20	if (!messenger.IsValid())
21		return B_ERROR;
22
23	BMessage msg(MEDIA_ADD_ON_SERVER_PLAY_MEDIA), reply;
24	msg.AddString(MEDIA_NAME_KEY, eventName ? eventName : MEDIA_SOUNDS_BEEP);
25	msg.AddString(MEDIA_TYPE_KEY, MEDIA_TYPE_SOUNDS);
26
27	status_t status = messenger.SendMessage(&msg, &reply);
28	if (status != B_OK || reply.FindInt32("error", &status) != B_OK)
29		status = B_BAD_REPLY;
30
31	return status;
32}
33
34
35status_t
36beep()
37{
38	return system_beep(NULL);
39}
40
41
42status_t
43add_system_beep_event(const char* name, uint32 flags)
44{
45	BMessenger messenger("application/x-vnd.Be.media-server");
46	if (!messenger.IsValid())
47		return B_ERROR;
48
49	BMessage msg(MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT), reply;
50	msg.AddString(MEDIA_NAME_KEY, name);
51	msg.AddString(MEDIA_TYPE_KEY, MEDIA_TYPE_SOUNDS);
52	msg.AddInt32(MEDIA_FLAGS_KEY, flags);
53
54	status_t status = messenger.SendMessage(&msg, &reply);
55	if (status != B_OK || reply.FindInt32("error", &status) != B_OK)
56		status = B_BAD_REPLY;
57
58	return status;
59}
60