#import "wizard.h"
#import "extended.h"
#import "bookmarks.h"
-#import "interaction.h"
+#import "coredialogs.h"
#import "embeddedwindow.h"
#import "update.h"
#import "AppleRemote.h"
#import "simple_prefs.h"
#import "vlm.h"
-#import <AddressBook/AddressBook.h>
+#import <AddressBook/AddressBook.h> /* for crashlog send mechanism */
+#import <IOKit/hidsystem/ev_keymap.h> /* for the media key support */
/*****************************************************************************
* Local prototypes.
/* Install a jmpbuffer to where we can go back before the NSApp exit
* see applicationWillTerminate: */
- [NSApplication sharedApplication];
+ [VLCApplication sharedApplication];
[[VLCMain sharedInstance] setIntf: p_intf];
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
{
int canc = vlc_savecancel();
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
-
- NSDictionary *o_dict = [NSDictionary dictionaryWithObjects:
- [NSArray arrayWithObjects:
- [NSString stringWithUTF8String: item->psz_module],
- [NSString stringWithUTF8String: item->psz_msg],
- [NSNumber numberWithInt: item->i_type], nil]
- forKeys:
- [NSArray arrayWithObjects: @"Module", @"Message", @"Type", nil]];
-
+
+ /* this may happen from time to time, let's bail out as info would be useless anyway */
+ if( !item->psz_module || !item->psz_msg )
+ return;
+
+ NSDictionary *o_dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSString stringWithUTF8String: item->psz_module], @"Module",
+ [NSString stringWithUTF8String: item->psz_msg], @"Message",
+ [NSNumber numberWithInt: item->i_type], @"Type", nil];
+
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreMessageReceived"
object: nil
userInfo: o_dict];
-
+
[o_pool release];
vlc_restorecancel( canc );
}
const dialog_fatal_t *p_dialog = (const dialog_fatal_t *)value.p_address;
- NSLog( @"dialog callback triggered; type of dialogue is '%s'", type );
-
NSValue *o_value = [NSValue valueWithPointer:p_dialog];
- [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCNewCoreDialogEventNotification" object:[interface getInteractionList] userInfo:[NSDictionary dictionaryWithObjectsAndKeys: o_value, @"VLCDialogPointer", [NSString stringWithUTF8String: type], @"VLCDialogType", nil]];
+ [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCNewCoreDialogEventNotification" object:[interface getCoreDialogProvider] userInfo:[NSDictionary dictionaryWithObjectsAndKeys: o_value, @"VLCDialogPointer", [NSString stringWithUTF8String: type], @"VLCDialogType", nil]];
[o_pool release];
return VLC_SUCCESS;
o_extended = nil;
o_bookmarks = [[VLCBookmarks alloc] init];
o_embedded_list = [[VLCEmbeddedList alloc] init];
- o_interaction_list = [[VLCCoreDialogSupport alloc] init];
+ o_coredialogs = [[VLCCoreDialogProvider alloc] init];
o_info = [[VLCInfo alloc] init];
#ifdef UPDATE_CHECK
o_update = [[VLCUpdate alloc] init];
i_lastShownVolume = -1;
+#ifndef __x86_64__
o_remote = [[AppleRemote alloc] init];
[o_remote setClickCountEnabledButtons: kRemoteButtonPlay];
[o_remote setDelegate: _o_sharedMainInstance];
+#endif
o_eyetv = [[VLCEyeTVController alloc] init];
pl_Release( p_intf );
+ /* load our Core Dialogs nib */
+ nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp];
+
/* subscribe to various interactive dialogues */
var_Create( p_intf, "dialog-fatal", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "dialog-fatal", DialogCallback, self );
[crashLogURLConnection release];
[o_embedded_list release];
- [o_interaction_list release];
+ [o_coredialogs release];
[o_eyetv release];
[o_img_pause_pressed release];
application */
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
{
+#ifndef __x86_64__
[o_remote startListening: self];
+#endif
}
- (void)applicationDidResignActive:(NSNotification *)aNotification
{
+#ifndef __x86_64__
[o_remote stopListening: self];
+#endif
}
/* Triggered when the computer goes to sleep */
return nil;
}
-- (id)getInteractionList
+- (id)getCoreDialogProvider
{
- if( o_interaction_list )
- return o_interaction_list;
+ if( o_coredialogs )
+ return o_coredialogs;
return nil;
}
- (IBAction)showBookmarks:(id)sender
{
- dialog_Question( p_intf, _("Video Settings not saved"),
- _("An error occured while saving your settings via SimplePrefs."), "Yes", "No", "Cancel" );
-
/* we need the wizard-nib for the bookmarks's extract functionality */
if( !nib_wizard_loaded )
{
- (IBAction)viewErrorsAndWarnings:(id)sender
{
- [[[self getInteractionList] getErrorPanel] showPanel];
+ [[[self getCoreDialogProvider] getErrorPanel] showPanel];
}
- (IBAction)showMessagesPanel:(id)sender
if( [o_msg_arr count] + 2 > 400 )
{
- unsigned rid[] = { 0, 1 };
- [o_msg_arr removeObjectsFromIndices: (unsigned *)&rid
+ NSUInteger rid[] = { 0, 1 };
+ /* FIXME: THIS METHOD WILL BE DEPRECATED */
+ [o_msg_arr removeObjectsFromIndices: (NSUInteger *)&rid
numIndices: sizeof(rid)/sizeof(rid[0])];
}
}
@end
+
+/*****************************************************************************
+ * VLCApplication interface
+ * exclusively used to implement media key support on Al Apple keyboards
+ * b_justJumped is required as the keyboard send its events faster than
+ * the user can actually jump through his media
+ *****************************************************************************/
+
+@implementation VLCApplication
+
+- (void)sendEvent: (NSEvent*)event
+{
+ if( [event type] == NSSystemDefined && [event subtype] == 8 )
+ {
+ int keyCode = (([event data1] & 0xFFFF0000) >> 16);
+ int keyFlags = ([event data1] & 0x0000FFFF);
+ int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
+ int keyRepeat = (keyFlags & 0x1);
+
+ if( keyCode == NX_KEYTYPE_PLAY && keyState == 0 )
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
+
+ if( keyCode == NX_KEYTYPE_FAST && !b_justJumped )
+ {
+ if( keyState == 0 && keyRepeat == 0 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_NEXT );
+ }
+ else if( keyRepeat == 1 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT );
+ b_justJumped = YES;
+ [self performSelector:@selector(resetJump)
+ withObject: NULL
+ afterDelay:0.25];
+ }
+ }
+
+ if( keyCode == NX_KEYTYPE_REWIND && !b_justJumped )
+ {
+ if( keyState == 0 && keyRepeat == 0 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PREV );
+ }
+ else if( keyRepeat == 1 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
+ b_justJumped = YES;
+ [self performSelector:@selector(resetJump)
+ withObject: NULL
+ afterDelay:0.25];
+ }
+ }
+ }
+ [super sendEvent: event];
+}
+
+- (void)resetJump
+{
+ b_justJumped = NO;
+}
+
+@end