1 /* 2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 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 #include <stdio.h> 10 11 #include "DataExchange.h" 12 #include "MediaSounds.h" 13 14 15 status_t 16 system_beep(const char *eventName) 17 { 18 // TODO: Axel, fix me! 19 static const uint32 MEDIA_ADDON_SERVER_PLAY_MEDIA = 0; 20 BMessenger messenger("application/x-vnd.Be.addon-host"); 21 if (!messenger.IsValid()) 22 return B_ERROR; 23 BMessage msg(MEDIA_ADDON_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 err = messenger.SendMessage(&msg, &reply); 28 if ((err != B_OK) 29 || (reply.FindInt32("error", &err) != B_OK)) 30 err = B_BAD_REPLY; 31 return err; 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 BMessage msg(MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT), reply; 49 msg.AddString(MEDIA_NAME_KEY, name); 50 msg.AddString(MEDIA_TYPE_KEY, MEDIA_TYPE_SOUNDS); 51 msg.AddInt32(MEDIA_FLAGS_KEY, flags); 52 53 status_t err = messenger.SendMessage(&msg, &reply); 54 if ((err != B_OK) 55 || (reply.FindInt32("error", &err) != B_OK)) 56 err = B_BAD_REPLY; 57 return err; 58 } 59 60