Commit a8038909 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: implemented saving of the debug log as RTFD and slightly extended the...

macosx: implemented saving of the debug log as RTFD and slightly extended the catcher for outdated OS X versions.
parent 0bd6fe5f
...@@ -163,6 +163,7 @@ ...@@ -163,6 +163,7 @@
openReadMe = id; openReadMe = id;
openRecentItem = id; openRecentItem = id;
openWebsite = id; openWebsite = id;
saveDebugLog = id;
showBookmarks = id; showBookmarks = id;
showExtended = id; showExtended = id;
showInformationPanel = id; showInformationPanel = id;
...@@ -301,8 +302,9 @@ ...@@ -301,8 +302,9 @@
"o_mi_vol_down" = NSMenuItem; "o_mi_vol_down" = NSMenuItem;
"o_mi_vol_up" = NSMenuItem; "o_mi_vol_up" = NSMenuItem;
"o_mi_website" = NSMenuItem; "o_mi_website" = NSMenuItem;
"o_msgs_btn_crashlog" = NSButton; "o_msgs_crashlog_btn" = NSButton;
"o_msgs_panel" = id; "o_msgs_panel" = id;
"o_msgs_save_btn" = id;
"o_mu_add_intf" = NSMenu; "o_mu_add_intf" = NSMenu;
"o_mu_aspect_ratio" = NSMenu; "o_mu_aspect_ratio" = NSMenu;
"o_mu_audio" = NSMenu; "o_mu_audio" = NSMenu;
......
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
<integer>4</integer> <integer>4</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>3706</integer> <integer>282</integer>
<integer>29</integer>
<integer>915</integer> <integer>915</integer>
<integer>29</integer>
<integer>3568</integer> <integer>3568</integer>
<integer>3706</integer>
<integer>21</integer> <integer>21</integer>
<integer>282</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>9G55</string> <string>9G55</string>
......
/***************************************************************************** /*****************************************************************************
* intf.h: MacOS X interface module * intf.h: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2008 the VideoLAN team * Copyright (C) 2002-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -159,7 +159,8 @@ static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned ); ...@@ -159,7 +159,8 @@ static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned );
NSMutableArray * o_msg_arr; /* messages array */ NSMutableArray * o_msg_arr; /* messages array */
NSLock * o_msg_lock; /* messages lock */ NSLock * o_msg_lock; /* messages lock */
BOOL b_msg_arr_changed; /* did the array change? */ BOOL b_msg_arr_changed; /* did the array change? */
IBOutlet NSButton * o_msgs_btn_crashlog; /* messages open crashlog */ IBOutlet NSButton * o_msgs_crashlog_btn; /* messages open crashlog */
IBOutlet NSButton * o_msgs_save_btn; /* save the log as rtf */
/* CrashReporter panel */ /* CrashReporter panel */
IBOutlet NSButton * o_crashrep_dontSend_btn; IBOutlet NSButton * o_crashrep_dontSend_btn;
...@@ -407,6 +408,7 @@ static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned ); ...@@ -407,6 +408,7 @@ static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned );
- (IBAction)showInformationPanel:(id)sender; - (IBAction)showInformationPanel:(id)sender;
- (IBAction)crashReporterAction:(id)sender; - (IBAction)crashReporterAction:(id)sender;
- (IBAction)saveDebugLog:(id)sender;
- (IBAction)togglePlaylist:(id)sender; - (IBAction)togglePlaylist:(id)sender;
- (void)updateTogglePlaylistState; - (void)updateTogglePlaylistState;
......
...@@ -33,10 +33,6 @@ ...@@ -33,10 +33,6 @@
#include <vlc_keys.h> #include <vlc_keys.h>
#include <unistd.h> /* execl() */ #include <unistd.h> /* execl() */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#import "intf.h" #import "intf.h"
#import "fspanel.h" #import "fspanel.h"
#import "vout.h" #import "vout.h"
...@@ -57,8 +53,6 @@ ...@@ -57,8 +53,6 @@
#import "simple_prefs.h" #import "simple_prefs.h"
#import "vlm.h" #import "vlm.h"
#import <vlc_input.h>
#import <vlc_interface.h>
#import <AddressBook/AddressBook.h> #import <AddressBook/AddressBook.h>
/***************************************************************************** /*****************************************************************************
...@@ -111,27 +105,6 @@ void CloseIntf ( vlc_object_t *p_this ) ...@@ -111,27 +105,6 @@ void CloseIntf ( vlc_object_t *p_this )
free( p_intf->p_sys ); free( p_intf->p_sys );
} }
static void MsgCallback( msg_cb_data_t *data, msg_item_t *item, unsigned int i )
{
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]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreMessageReceived"
object: nil
userInfo: o_dict];
[o_pool release];
vlc_restorecancel( canc );
}
/***************************************************************************** /*****************************************************************************
* Run: main loop * Run: main loop
*****************************************************************************/ *****************************************************************************/
...@@ -174,6 +147,33 @@ static void Run( intf_thread_t *p_intf ) ...@@ -174,6 +147,33 @@ static void Run( intf_thread_t *p_intf )
#pragma mark - #pragma mark -
#pragma mark Variables Callback #pragma mark Variables Callback
/*****************************************************************************
* MsgCallback: Callback triggered by the core once a new debug message is
* ready to be displayed. We store everything in a NSArray in our Cocoa part
* of this file, so we are forwarding everything through notifications.
*****************************************************************************/
static void MsgCallback( msg_cb_data_t *data, msg_item_t *item, unsigned int i )
{
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]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreMessageReceived"
object: nil
userInfo: o_dict];
[o_pool release];
vlc_restorecancel( canc );
}
/***************************************************************************** /*****************************************************************************
* playlistChanged: Callback triggered by the intf-change playlist * playlistChanged: Callback triggered by the intf-change playlist
* variable, to let the intf update the playlist. * variable, to let the intf update the playlist.
...@@ -318,6 +318,30 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -318,6 +318,30 @@ static VLCMain *_o_sharedMainInstance = nil;
/* Check if we already did this once. Opening the other nibs calls it too, because VLCMain is the owner */ /* Check if we already did this once. Opening the other nibs calls it too, because VLCMain is the owner */
if( nib_main_loaded ) return; if( nib_main_loaded ) return;
/* check whether the user runs a valid version of OS X */
if( MACOS_VERSION < 10.5f )
{
NSAlert *ourAlert;
int i_returnValue;
NSString *o_blabla;
if( MACOS_VERSION == 10.5f )
o_blabla = _NS("VLC's last release for your OS is the 0.9 series." );
else if( MACOS_VERSION == 10.3f )
o_blabla = _NS("VLC's last release for your OS is VLC 0.8.6i, which is prone to known security issues." );
else // 10.2 and 10.1, still 3% of the OS X market share
o_blabla = _NS("VLC's last release for your OS is VLC 0.7.2, which is highly out of date and prone to " \
"known security issues. We recommend you to update your Mac to a modern version of Mac OS X.");
ourAlert = [NSAlert alertWithMessageText: _NS("Your version of Mac OS X is no longer supported")
defaultButton: _NS("Quit")
alternateButton: NULL
otherButton: NULL
informativeTextWithFormat: _NS("VLC media player %s requires Mac OS X 10.5 or higher.\n\n%@"), VLC_Version(), o_blabla];
[ourAlert setAlertStyle: NSCriticalAlertStyle];
i_returnValue = [ourAlert runModal];
[NSApp performSelectorOnMainThread: @selector(terminate:) withObject:nil waitUntilDone:NO];
return;
}
[self initStrings]; [self initStrings];
[o_window setExcludedFromWindowsMenu: YES]; [o_window setExcludedFromWindowsMenu: YES];
...@@ -470,21 +494,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -470,21 +494,6 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_controls setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf [o_controls setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf
var: "intf-add" selector: @selector(toggleVar:)]; var: "intf-add" selector: @selector(toggleVar:)];
/* check whether the user runs a valid version of OSX; alert is auto-released */
if( MACOS_VERSION < 10.4f )
{
NSAlert *ourAlert;
int i_returnValue;
ourAlert = [NSAlert alertWithMessageText: _NS("Your version of Mac OS X is not supported")
defaultButton: _NS("Quit")
alternateButton: NULL
otherButton: NULL
informativeTextWithFormat: _NS("VLC media player requires Mac OS X 10.4 or higher.")];
[ourAlert setAlertStyle: NSCriticalAlertStyle];
i_returnValue = [ourAlert runModal];
[NSApp terminate: self];
}
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
} }
...@@ -527,7 +536,8 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -527,7 +536,8 @@ static VLCMain *_o_sharedMainInstance = nil;
/* messages panel */ /* messages panel */
[o_msgs_panel setTitle: _NS("Messages")]; [o_msgs_panel setTitle: _NS("Messages")];
[o_msgs_btn_crashlog setTitle: _NS("Open CrashLog...")]; [o_msgs_crashlog_btn setTitle: _NS("Open CrashLog...")];
[o_msgs_save_btn setTitle: _NS("Save this Log...")];
/* main menu */ /* main menu */
[o_mi_about setTitle: [_NS("About VLC media player") \ [o_mi_about setTitle: [_NS("About VLC media player") \
...@@ -1611,7 +1621,10 @@ static void * manage_cleanup( void * args ) ...@@ -1611,7 +1621,10 @@ static void * manage_cleanup( void * args )
if( p_intf->p_sys->b_intf_show ) if( p_intf->p_sys->b_intf_show )
{ {
[o_window makeKeyAndOrderFront: self]; if( [[o_controls voutView] isFullscreen] && config_GetInt( VLCIntf, "macosx-fspanel" ) )
[[o_controls getFSPanel] fadeIn];
else
[o_window makeKeyAndOrderFront: self];
p_intf->p_sys->b_intf_show = false; p_intf->p_sys->b_intf_show = false;
} }
...@@ -2450,6 +2463,28 @@ end: ...@@ -2450,6 +2463,28 @@ end:
[o_msg_lock unlock]; [o_msg_lock unlock];
} }
- (IBAction)saveDebugLog:(id)sender
{
NSOpenPanel * saveFolderPanel = [[NSSavePanel alloc] init];
[saveFolderPanel setCanChooseDirectories: NO];
[saveFolderPanel setCanChooseFiles: YES];
[saveFolderPanel setCanSelectHiddenExtension: NO];
[saveFolderPanel setCanCreateDirectories: YES];
[saveFolderPanel setRequiredFileType: @"rtfd"];
[saveFolderPanel beginSheetForDirectory:nil file: [NSString stringWithFormat: _NS("VLC Debug Log (%s).rtfd"), VLC_Version()] modalForWindow: o_msgs_panel modalDelegate:self didEndSelector:@selector(saveDebugLogAsRTF:returnCode:contextInfo:) contextInfo:nil];
}
- (void)saveDebugLogAsRTF: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
{
BOOL b_returned;
if( returnCode == NSOKButton )
{
b_returned = [o_messages writeRTFDToFile: [sheet filename] atomically: YES];
if(! b_returned )
msg_Warn( p_intf, "Error while saving the debug log" );
}
}
#pragma mark - #pragma mark -
#pragma mark Playlist toggling #pragma mark Playlist toggling
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment