Sha256: be7a96314554ab86bfd7229d852ab697a3d3f82fce1f2a4eed9f707bc10e8644

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

#include "stdafx.h"

#if defined(_WIN32_WCE)
#include <soundfile.h>
#endif

#include <common/RhodesApp.h>

#include "Alert.h"
#include "MainWindow.h"
#include "Vibrate.h"

extern "C" HWND getMainWnd();

IMPLEMENT_LOGCLASS(CAlert, "Alert");

void CAlert::showPopup(String message)
{
    HWND main_wnd = getMainWnd();
	::PostMessage(main_wnd, WM_ALERT_SHOWPOPUP, 0,
                  (LPARAM )strdup(message.c_str()));
}

#if defined(_WIN32_WCE)
void CAlert::vibrate()
{
    CVibrate::getCVibrate().toggle();
}

void CAlert::playFile(String fileName)
{
    rho::String path = RHODESAPP().getRhoRootPath() + "apps" + fileName;
    HSOUND hSound;
    
    rho::String::size_type pos = 0;
    while ( (pos = path.find('/', pos)) != rho::String::npos ) {
        path.replace( pos, 1, "\\");
        pos++;
    }

    USES_CONVERSION;
    //SndPlaySync(A2T(path.c_str()),  SND_PLAY_IGNOREUSERSETTINGS);
    HRESULT hr = SndOpen(A2T(path.c_str()), &hSound);
    hr = SndPlayAsync (hSound, 0);
      
    if (hr != S_OK) {
        LOG(WARNING) + "OnAlertPlayFile: failed to play file"; 
    }
    
    WaitForSingleObject(hSound, INFINITE);
                        
    hr = SndClose(hSound);
    SndStop(SND_SCOPE_PROCESS, NULL);
}

#endif //_WIN32_WCE

extern "C" void alert_show_popup(char* message) {
    CAlert::showPopup(message);
}

extern "C" void alert_vibrate(void*) {
#if defined(_WIN32_WCE)
    CAlert::vibrate();
#endif
}

extern "C" void alert_play_file(char* file_name, ...) {
#if defined(_WIN32_WCE)
    CAlert::playFile(file_name);
#endif
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rhodes-1.5.5 platform/wm/rhodes/Alert.cpp
rhodes-1.5.4 platform/wm/rhodes/Alert.cpp
rhodes-1.5.3 platform/wm/rhodes/Alert.cpp
rhodes-1.5.2 platform/wm/rhodes/Alert.cpp
rhodes-1.5.1 platform/wm/rhodes/Alert.cpp
rhodes-1.5.0 platform/wm/rhodes/Alert.cpp