Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

applescript.m

00001 /*****************************************************************************
00002  * applescript.m: MacOS X AppleScript support
00003  *****************************************************************************
00004  * Copyright (C) 2002-2003 the VideoLAN team
00005  * $Id: applescript.m 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Derk-Jan Hartman <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include "intf.h"
00028 #include "applescript.h"
00029 #include "controls.h"
00030 #include "open.h"
00031 
00032 
00033 /*****************************************************************************
00034  * VLGetURLScriptCommand implementation 
00035  *****************************************************************************/
00036 @implementation VLGetURLScriptCommand
00037 
00038 - (id)performDefaultImplementation {
00039     NSString *o_command = [[self commandDescription] commandName];
00040     NSString *o_urlString = [self directParameter];
00041 
00042     if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] )
00043     {
00044         intf_thread_t * p_intf = VLCIntf;
00045         playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00046                                                         FIND_ANYWHERE );
00047         if( p_playlist == NULL )
00048         {
00049             return nil;
00050         }
00051 
00052         if ( o_urlString )
00053         {
00054             NSURL * o_url;
00055     
00056             playlist_Add( p_playlist, [o_urlString fileSystemRepresentation],
00057                           [[[NSFileManager defaultManager] displayNameAtPath: o_urlString] UTF8String],
00058                           PLAYLIST_INSERT, PLAYLIST_END );
00059 
00060             o_url = [NSURL fileURLWithPath: o_urlString];
00061             if( o_url != nil )
00062             { 
00063                 [[NSDocumentController sharedDocumentController]
00064                     noteNewRecentDocumentURL: o_url]; 
00065             }
00066         }
00067         vlc_object_release( p_playlist );
00068     }
00069     return nil;
00070 }
00071 
00072 @end
00073 
00074 
00075 /*****************************************************************************
00076  * VLControlScriptCommand implementation 
00077  *****************************************************************************/
00078 /*
00079  * This entire control command needs a better design. more object oriented.
00080  * Applescript developers would be very welcome (hartman)
00081  */
00082 @implementation VLControlScriptCommand
00083 
00084 - (id)performDefaultImplementation {
00085     NSString *o_command = [[self commandDescription] commandName];
00086 
00087     intf_thread_t * p_intf = VLCIntf;
00088     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00089                                                     FIND_ANYWHERE );
00090     if( p_playlist == NULL )
00091     {
00092         return nil;
00093     }
00094     
00095     VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls];
00096     
00097     if ( o_controls )
00098     {
00099         if ( [o_command isEqualToString:@"play"] )
00100         {
00101             [o_controls play:self];
00102             return nil;
00103         }
00104         else if ( [o_command isEqualToString:@"stop"] )
00105         {
00106             [o_controls stop:self];
00107             return nil;
00108         }
00109         else if ( [o_command isEqualToString:@"previous"] )
00110         {
00111             [o_controls prev:self];
00112             return nil;
00113         }
00114         else if ( [o_command isEqualToString:@"next"] )
00115         {
00116             [o_controls next:self];
00117             return nil;
00118         }
00119         else if ( [o_command isEqualToString:@"fullscreen"] )
00120         {
00121             NSMenuItem *o_mi = [[NSMenuItem alloc] initWithTitle: _NS("Fullscreen") action: nil keyEquivalent:@""];
00122             [o_controls windowAction:[o_mi autorelease]];
00123             return nil;
00124         }
00125         else if ( [o_command isEqualToString:@"mute"] )
00126         {
00127             [o_controls mute:self];
00128             return nil;
00129         }
00130         else if ( [o_command isEqualToString:@"volumeUp"] )
00131         {
00132             [o_controls volumeUp:self];
00133             return nil;
00134         }
00135         else if ( [o_command isEqualToString:@"volumeDown"] )
00136         {
00137             [o_controls volumeDown:self];
00138             return nil;
00139         }
00140     }
00141     vlc_object_release( p_playlist );
00142     return nil;
00143 }
00144 
00145 @end

Generated on Tue Dec 20 10:14:38 2005 for vlc-0.8.4a by  doxygen 1.4.2