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 */ 6 7 8 #include <Beep.h> 9 10 #include <stdio.h> 11 12 #include <DataExchange.h> 13 #include <MediaSounds.h> 14 15 16 status_t 17 system_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 35 status_t 36 beep() 37 { 38 return system_beep(NULL); 39 } 40 41 42 status_t 43 add_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