2004-06-10 22:03:32 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "DialogDriver_Cocoa.h"
|
|
|
|
|
#include "RageThreads.h"
|
2005-11-08 06:04:09 +00:00
|
|
|
#include "ProductInfo.h"
|
2004-06-10 22:03:32 +00:00
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
|
|
2005-11-08 06:04:09 +00:00
|
|
|
static CFOptionFlags ShowAlert( CFOptionFlags flags, CFStringRef message,
|
|
|
|
|
CFStringRef OK, CFStringRef cancel = NULL )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
2005-11-08 06:04:09 +00:00
|
|
|
CFOptionFlags result;
|
|
|
|
|
|
|
|
|
|
CFUserNotificationDisplayAlert( 0.0, flags, NULL, NULL, NULL, CFSTR(PRODUCT_NAME_VER),
|
|
|
|
|
message, OK, cancel, NULL, &result );
|
|
|
|
|
return result;
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
2005-06-03 23:45:58 +00:00
|
|
|
void DialogDriver_Cocoa::OK( CString sMessage, CString sID )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
2005-06-03 23:47:56 +00:00
|
|
|
CFStringRef message = CFStringCreateWithCString( NULL, sMessage, kCFStringEncodingASCII );
|
2005-11-08 06:04:09 +00:00
|
|
|
CFOptionFlags result = ShowAlert( kCFUserNotificationNoteAlertLevel, message,
|
|
|
|
|
CFSTR("OK"), CFSTR("Don't show again") );
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:47:56 +00:00
|
|
|
CFRelease( message );
|
2005-11-08 06:04:09 +00:00
|
|
|
if( result == kCFUserNotificationAlternateResponse )
|
2005-06-03 23:45:58 +00:00
|
|
|
Dialog::IgnoreMessage( sID );
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
2005-06-03 23:45:58 +00:00
|
|
|
void DialogDriver_Cocoa::Error( CString sError, CString sID )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
|
|
|
|
CFStringRef error = CFStringCreateWithCString( NULL, sError, kCFStringEncodingASCII );
|
2005-11-08 06:04:09 +00:00
|
|
|
ShowAlert( kCFUserNotificationStopAlertLevel, error, CFSTR("OK") );
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:47:56 +00:00
|
|
|
CFRelease( error );
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
2005-06-03 23:45:58 +00:00
|
|
|
Dialog::Result DialogDriver_Cocoa::AbortRetryIgnore( CString sMessage, CString sID )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
|
|
|
|
CFStringRef error = CFStringCreateWithCString( NULL, sMessage, kCFStringEncodingASCII );
|
2005-11-08 06:04:09 +00:00
|
|
|
CFOptionFlags result = ShowAlert( kCFUserNotificationNoteAlertLevel, error, CFSTR("Retry"), CFSTR("Ignore") );
|
2004-06-11 05:31:35 +00:00
|
|
|
Dialog::Result ret;
|
2004-06-10 22:03:32 +00:00
|
|
|
|
2005-06-03 23:49:30 +00:00
|
|
|
CFRelease( error );
|
2005-11-08 06:04:09 +00:00
|
|
|
switch( result )
|
2004-06-10 22:03:32 +00:00
|
|
|
{
|
2005-11-08 06:04:09 +00:00
|
|
|
case kCFUserNotificationDefaultResponse:
|
2004-06-11 05:31:35 +00:00
|
|
|
ret = Dialog::retry;
|
2004-06-10 22:03:32 +00:00
|
|
|
break;
|
2005-11-08 06:04:09 +00:00
|
|
|
case kCFUserNotificationAlternateResponse:
|
|
|
|
|
case kCFUserNotificationCancelResponse:
|
2004-06-11 05:31:35 +00:00
|
|
|
ret = Dialog::ignore;
|
2004-06-10 22:03:32 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
2004-06-11 05:31:35 +00:00
|
|
|
ret = Dialog::ignore;
|
2004-06-10 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2005-11-08 06:04:09 +00:00
|
|
|
* (c) 2003-2005 Steve Checkoway
|
2004-06-10 22:03:32 +00:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|