HaikuDepot: notify work status from main window
[haiku.git] / src / kits / support / Beep.cpp
blobb4519b7006d740da8e7577f6008a166f510db4c3
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 Haiku License.
5 */
8 #include <Beep.h>
10 #include <stdio.h>
12 #include <DataExchange.h>
13 #include <MediaSounds.h>
16 status_t
17 system_beep(const char* eventName)
19 BMessenger messenger("application/x-vnd.Be.addon-host");
20 if (!messenger.IsValid())
21 return B_ERROR;
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);
27 status_t status = messenger.SendMessage(&msg, &reply);
28 if (status != B_OK || reply.FindInt32("error", &status) != B_OK)
29 status = B_BAD_REPLY;
31 return status;
35 status_t
36 beep()
38 return system_beep(NULL);
42 status_t
43 add_system_beep_event(const char* name, uint32 flags)
45 BMessenger messenger("application/x-vnd.Be.media-server");
46 if (!messenger.IsValid())
47 return B_ERROR;
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);
54 status_t status = messenger.SendMessage(&msg, &reply);
55 if (status != B_OK || reply.FindInt32("error", &status) != B_OK)
56 status = B_BAD_REPLY;
58 return status;