コード例 #1
0
ファイル: theme_loader.cpp プロジェクト: Kafay/vlc
bool ThemeLoader::extractZip( const string &zipFile, const string &rootDir )
{
    // Try to open the ZIP file
    unzFile file = unzOpen( zipFile.c_str() );
    unz_global_info info;

    if( unzGetGlobalInfo( file, &info ) != UNZ_OK )
    {
        return false;
    }
    // Extract all the files in the archive
    for( unsigned long i = 0; i < info.number_entry; i++ )
    {
        if( !extractFileInZip( file, rootDir ) )
        {
            msg_Warn( getIntf(), "error while unzipping %s",
                      zipFile.c_str() );
            unzClose( file );
            return false;
        }

        if( i < info.number_entry - 1 )
        {
            // Go the next file in the archive
            if( unzGoToNextFile( file ) !=UNZ_OK )
            {
                msg_Warn( getIntf(), "error while unzipping %s",
                          zipFile.c_str() );
                unzClose( file );
                return false;
            }
        }
    }
    unzClose( file );
    return true;
}
コード例 #2
0
ファイル: skin_parser.cpp プロジェクト: 12307/VLC-for-VS2010
int SkinParser::convertInRange( const char *value, int minValue, int maxValue,
                                const string &rAttribute ) const
{
    int intValue = atoi( value );

    if( intValue < minValue )
    {
        msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the "
                  "expected range [%i, %i], using %i instead",
                  rAttribute.c_str(), intValue, minValue, maxValue, minValue );
        return minValue;
    }
    else if( intValue > maxValue )
    {
        msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the "
                  "expected range [%i, %i], using %i instead",
                  rAttribute.c_str(), intValue, minValue, maxValue, maxValue );
        return maxValue;
    }
    else
    {
        return intValue;
    }
}
コード例 #3
0
ファイル: stream.cpp プロジェクト: forthyen/SDesk
const string Stream::getAsStringName() const
{
    string fullName = getAsStringFullName();

    // XXX: This should be done in VLC core, not here...
    // Remove path information if any
    OSFactory *pFactory = OSFactory::instance( getIntf() );
    string::size_type pos = fullName.rfind( pFactory->getDirSeparator() );
    if( pos != string::npos )
    {
        fullName = fullName.substr( pos + 1, fullName.size() - pos + 1 );
    }

    return fullName;
}
コード例 #4
0
void VlcProc::init_variables()
{
    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;

    SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
    SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
    SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );

    audio_volume_t volume = aout_VolumeGet( pPlaylist );
    SET_VOLUME( m_cVarVolume, volume, false );
    bool b_is_muted = aout_IsMuted( VLC_OBJECT(pPlaylist) );
    SET_BOOL( m_cVarMute, b_is_muted );

    update_equalizer();
}
コード例 #5
0
ファイル: macosx_window.cpp プロジェクト: qdk0901/vlc
MacOSXWindow::MacOSXWindow( intf_thread_t *pIntf, GenericWindow &rWindow,
                            bool dragDrop, bool playOnDrop,
                            MacOSXWindow *pParentWindow ):
    OSWindow( pIntf ), m_pParent( pParentWindow ), m_dragDrop( dragDrop )
{
    // Create the window
    Rect rect;
    SetRect( &rect, 0, 0, 0, 0 );
    CreateNewWindow( kDocumentWindowClass, kWindowNoShadowAttribute |
                     kWindowNoTitleBarAttribute, &rect, &m_win );

    // Create the event handler for this window
    OSFactory *pOSFactory = OSFactory::instance( getIntf() );
    ((MacOSXLoop*)pOSFactory->getOSLoop())->registerWindow( rWindow, m_win );
}
コード例 #6
0
void VlcProc::init_variables()
{
    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;

    SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
    SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
    SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );

    audio_volume_t volume;
    aout_VolumeGet( pPlaylist, &volume );
    SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
    SET_BOOL( m_cVarMute, volume == 0 );

    update_equalizer();
}
コード例 #7
0
ファイル: top_window.cpp プロジェクト: 371816210/vlc_vlc
void TopWindow::setLastHit( CtrlGeneric *pNewHitControl )
{
    // Send a leave event to the left control
    if( m_pLastHitControl && (pNewHitControl != m_pLastHitControl) )
    {
        // Don't send the event if another control captured the mouse
        if( !m_pCapturingControl || (m_pCapturingControl == m_pLastHitControl))
        {
            EvtLeave evt( getIntf() );
            m_pLastHitControl->handleEvent( evt );
        }
    }

    m_pLastHitControl = pNewHitControl;
}
コード例 #8
0
void FSM::addTransition( const string &state1, const string &event,
                         const string &state2, CmdGeneric *pCmd )
{
    // Check that we already know the states
    if( m_states.find( state1 ) == m_states.end() ||
        m_states.find( state2 ) == m_states.end() )
    {
        msg_Warn( getIntf(),
                  "FSM: ignoring transition between invalid states" );
        return;
    }

    Key_t key( state1, event );
    Data_t data( state2, pCmd );

    // Check that the transition doesn't already exist
    if( m_transitions.find( key ) != m_transitions.end() )
    {
        msg_Warn( getIntf(), "FSM: transition already exists" );
        return;
    }

    m_transitions[key] = data;
}
コード例 #9
0
ファイル: dialogs.cpp プロジェクト: FLYKingdom/vlc
Dialogs::~Dialogs()
{
    if( m_pProvider && m_pModule )
    {
        // Detach the dialogs provider from its parent interface
        vlc_object_detach( m_pProvider );

        module_unneed( m_pProvider, m_pModule );
        vlc_object_release( m_pProvider );
    }

    /* Unregister callbacks */
    var_DelCallback( getIntf()->p_libvlc, "intf-popupmenu",
                     PopupMenuCB, this );
}
コード例 #10
0
ファイル: win32_tooltip.cpp プロジェクト: Flameeyes/vlc
Win32Tooltip::Win32Tooltip( intf_thread_t *pIntf, HINSTANCE hInst,
                            HWND hParentWindow ):
    OSTooltip( pIntf )
{
    // Create the window
    m_hWnd = CreateWindowEx( WS_EX_TOOLWINDOW,
        "SkinWindowClass", "default name", WS_POPUP, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hParentWindow, 0,
        hInst, NULL );

    if( !m_hWnd )
    {
        msg_Err( getIntf(), "createWindow failed" );
        return;
    }
}
コード例 #11
0
ファイル: ini_file.cpp プロジェクト: qdk0901/vlc
void IniFile::parseFile()
{
    VarManager *pVarManager = VarManager::instance( getIntf() );

    // Open the file
    std::fstream fs( m_path.c_str(), std::fstream::in );
    if( fs.is_open() )
    {
        std::string section;
        std::string line;
        while( !fs.eof() )
        {
            // Read the next line
            fs >> line;

            switch( line[0] )
            {
            // "[section]" line ?
            case '[':
                section = line.substr( 1, line.size() - 2);
                break;

            // Comment
            case ';':
            case '#':
                break;

            // Variable declaration
            default:
                size_t eqPos = line.find( '=' );
                std::string var = line.substr( 0, eqPos );
                std::string val = line.substr( eqPos + 1, line.size() - eqPos - 1);

                std::string name = m_name + "." + section + "." + var;

                // Convert to lower case because of some buggy winamp2 skins
                for( size_t i = 0; i < name.size(); i++ )
                {
                    name[i] = tolower( (unsigned char)name[i] );
                }

                // Register the value in the var manager
                pVarManager->registerConst( name, val );
            }
        }
        fs.close();
    }
コード例 #12
0
ファイル: cmd_playlist.cpp プロジェクト: mstorsjo/vlc
void CmdPlaylistSave::execute()
{
    const char *psz_module;
    if( m_file.find( ".xsp", 0 ) != std::string::npos )
        psz_module = "export-xspf";
    else if( m_file.find( "m3u", 0 ) != std::string::npos )
        psz_module = "export-m3u";
    else if( m_file.find( "html", 0 ) != std::string::npos )
        psz_module = "export-html";
    else
    {
        msg_Err(getIntf(),"Did not recognise playlist export file type");
        return;
    }

    playlist_Export( getPL(), m_file.c_str(), psz_module );
}
コード例 #13
0
GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
                              int minWidth, int maxWidth, int minHeight,
                              int maxHeight ):
    SkinObject( pIntf ), m_pWindow( NULL ), m_width( width ),
    m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ),
    m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL ),
    m_visible( false ), m_pVarActive( NULL )
{
    // Get the OSFactory
    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
    // Create the graphics buffer
    m_pImage = pOsFactory->createOSGraphics( width, height );

    // Create the "active layout" variable and register it in the manager
    m_pVarActive = new VarBoolImpl( pIntf );
    VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarActive ) );
}
コード例 #14
0
ファイル: vout_window.cpp プロジェクト: forthyen/SDesk
void VoutWindow::resize( int width, int height )
{
    // Get the OSFactory
    OSFactory *pOsFactory = OSFactory::instance( getIntf() );

    // Recreate the image
    if( m_pImage )
    {
        delete m_pImage;
    }
    m_pImage = pOsFactory->createOSGraphics( width, height );
    // Draw a black rectangle
    m_pImage->fillRect( 0, 0, width, height, 0 );

    // Resize the window
    GenericWindow::resize( width, height );
}
コード例 #15
0
ファイル: evt_scroll.cpp プロジェクト: forthyen/SDesk
const string EvtScroll::getAsString() const
{
    string event = "scroll";

    // Add the direction
    if( m_direction == kUp )
        event += ":up";
    else if( m_direction == kDown )
        event += ":down";
    else
        msg_Warn( getIntf(), "Unknown scrolling direction" );

    // Add the modifier
    addModifier( event );

    return event;
}
コード例 #16
0
Win32Window::~Win32Window()
{
    Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() );
    pFactory->m_windowMap[m_hWnd] = NULL;

    if( m_hWnd )
    {
        if( m_dragDrop )
        {
            // Remove the window from the list of drop targets
            RevokeDragDrop( m_hWnd );
            m_pDropTarget->Release();
        }

        DestroyWindow( m_hWnd );
    }
}
コード例 #17
0
void Playlist::buildList()
{
    clear();

    vlc_mutex_lock( &m_pPlaylist->object_lock );
    for( int i = 0; i < m_pPlaylist->i_size; i++ )
    {
        // Get the name of the playlist item
        UString *pName =
            new UString( getIntf(), m_pPlaylist->pp_items[i]->input.psz_name );
        // Is it the played stream ?
        bool playing = (i == m_pPlaylist->i_index );
        // Add the item in the list
        m_list.push_back( Elem_t( UStringPtr( pName ), false, playing ) );
    }
    vlc_mutex_unlock( &m_pPlaylist->object_lock );
}
コード例 #18
0
ファイル: top_window.cpp プロジェクト: 0xheart0/vlc
void TopWindow::processEvent( EvtKey &rEvtKey )
{
    // Forward the event to the focused control, if any
    if( m_pFocusControl )
    {
        m_pFocusControl->handleEvent( rEvtKey );
        return;
    }

    // Only do the action when the key is down
    if( rEvtKey.getKeyState() == EvtKey::kDown )
    {
        getIntf()->p_sys->p_dialogs->sendKey( rEvtKey.getModKey() );
    }

    // Always store the modifier, which can be needed for scroll events.
    m_currModifier = rEvtKey.getMod();
}
コード例 #19
0
Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
{
    m_step = (float)config_GetInt( pIntf, "volume-step" ) / AOUT_VOLUME_MAX;
    if( var_InheritBool( pIntf, "qt-volume-complete" ) )
    {
        m_max = 400;
        m_volumeMax = AOUT_VOLUME_MAX;
    }
    else
    {
        m_max = 200;
        m_volumeMax = AOUT_VOLUME_MAX / 2;
    }

    // Initial value
    audio_volume_t val = aout_VolumeGet( getIntf()->p_sys->p_playlist );
    set( val, false );
}
コード例 #20
0
ファイル: evt_special.cpp プロジェクト: 12307/VLC-for-VS2010
const string EvtSpecial::getAsString() const
{
    string event = "special";

    // Add the action
    if( m_action == kShow )
        event += ":show";
    else if( m_action == kHide )
        event += ":hide";
    else if( m_action == kEnable )
        event += ":enable";
    else if( m_action == kDisable )
        event += ":disable";
    else
        msg_Warn( getIntf(), "unknown action type" );

    return event;
}
コード例 #21
0
ファイル: xmlparser.cpp プロジェクト: forthyen/SDesk
XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName ):
    SkinObject( pIntf )
{
    m_pReader = xmlNewTextReaderFilename( rFileName.c_str() );
    if( !m_pReader )
    {
        msg_Err( getIntf(), "Failed to open %s for parsing",
                 rFileName.c_str() );
        return;
    }

    // Activate DTD validation
    xmlTextReaderSetParserProp( m_pReader, XML_PARSER_DEFAULTATTRS, 1 );
    xmlTextReaderSetParserProp( m_pReader, XML_PARSER_VALIDATE, 1 );

    // Set the error handler
    xmlTextReaderSetErrorHandler( m_pReader, handleError, this );
}
コード例 #22
0
ファイル: x11_factory.cpp プロジェクト: DawidNowicki/vlc
bool X11Factory::init()
{
    // make sure xlib is safe-thread
    if( !vlc_xlib_init( VLC_OBJECT( getIntf() ) ) )
    {
        msg_Err( getIntf(), "initializing xlib for multi-threading failed" );
        return false;
    }

    // Create the X11 display
    m_pDisplay = new X11Display( getIntf() );

    // Get the display
    Display *pDisplay = m_pDisplay->getDisplay();
    if( pDisplay == NULL )
    {
        // Initialization failed
        return false;
    }

    // Create the timer loop
    m_pTimerLoop = new X11TimerLoop( getIntf(),
                                     ConnectionNumber( pDisplay ) );

    // Initialize the resource path
    char *datadir = config_GetUserDir( VLC_DATA_DIR );
    m_resourcePath.push_back( (std::string)datadir + "/skins2" );
    free( datadir );
    m_resourcePath.push_back( (std::string)"share/skins2" );
    datadir = config_GetDataDir();
    m_resourcePath.push_back( (std::string)datadir + "/skins2" );
    free( datadir );

    // Determine the monitor geometry
    getDefaultGeometry( &m_screenWidth, &m_screenHeight );

    // list all available monitors
    int num_screen;
    XineramaScreenInfo* info = XineramaQueryScreens( pDisplay, &num_screen );
    if( info )
    {
        msg_Dbg( getIntf(), "number of monitors detected : %i", num_screen );
        for( int i = 0; i < num_screen; i++ )
            msg_Dbg( getIntf(), "  monitor #%i : %ix%i at +%i+%i",
                                i, info[i].width, info[i].height,
                                info[i].x_org, info[i].y_org );
        XFree( info );
    }

    return true;
}
コード例 #23
0
ファイル: x11_dragdrop.cpp プロジェクト: 12307/VLC-for-VS2010
void X11DragDrop::dndPosition( ldata_t data )
{
    Window src = data[0];
    m_xPos = data[2] >> 16;
    m_yPos = data[2] & 0xffff;
    Time time = data[3];

    Atom selectionAtom = XInternAtom( XDISPLAY, "XdndSelection", 0 );
    //Atom targetAtom = XInternAtom( XDISPLAY, "text/plain", 0 );
    Atom targetAtom = XInternAtom( XDISPLAY, "text/uri-list", 0 );
    Atom propAtom = XInternAtom( XDISPLAY, "VLC_SELECTION", 0 );

    Atom actionAtom = XInternAtom( XDISPLAY, "XdndActionCopy", 0 );
    Atom typeAtom = XInternAtom( XDISPLAY, "XdndFinished", 0 );

    // Convert the selection into the given target
    // NEEDED or it doesn't work!
    XConvertSelection( XDISPLAY, selectionAtom, targetAtom, propAtom, src,
                       time );

    actionAtom = XInternAtom( XDISPLAY, "XdndActionCopy", 0 );
    typeAtom = XInternAtom( XDISPLAY, "XdndStatus", 0 );

    XEvent event;
    event.type = ClientMessage;
    event.xclient.window = src;
    event.xclient.display = XDISPLAY;
    event.xclient.message_type = typeAtom;
    event.xclient.format = 32;
    event.xclient.data.l[0] = m_wnd;
    // Accept the drop (1), or not (0).
    event.xclient.data.l[1] = m_target != None ? 1 : 0;
    event.xclient.data.l[2] = 0;
    event.xclient.data.l[3] = 0;
    event.xclient.data.l[4] = actionAtom;

    // Tell the source whether we accept the drop
    XSendEvent( XDISPLAY, src, False, 0, &event );

    // transmit DragOver event
    EvtDragOver evt( getIntf(), m_xPos, m_yPos );
    m_pWin->processEvent( evt );
}
コード例 #24
0
ファイル: top_window.cpp プロジェクト: CSRedRat/vlc
void TopWindow::onTooltipChange( const CtrlGeneric &rCtrl )
{
    // Check that the control is the active one
    if( m_pLastHitControl && m_pLastHitControl == &rCtrl )
    {
        if( rCtrl.getTooltipText().size() )
        {
            // Set the tooltip text variable
            VarManager *pVarManager = VarManager::instance( getIntf() );
            pVarManager->getTooltipText().set( rCtrl.getTooltipText() );
            m_rWindowManager.showTooltip();
        }
        else
        {
            // Nothing to display, so hide the tooltip
            m_rWindowManager.hideTooltip();
        }
    }
}
コード例 #25
0
ファイル: skin_parser.cpp プロジェクト: banketree/faplayer
const int SkinParser::getRefHeight( bool toScreen )
{
    if( toScreen )
    {
        OSFactory *pOsFactory = OSFactory::instance( getIntf() );
        return pOsFactory->getScreenHeight();
    }

    string panelId = m_panelStack.back();
    if( panelId != "none" )
    {
        const BuilderData::Panel panel = m_pData->m_listPanel.back();
        return panel.m_height;
    }
    else
    {
        const BuilderData::Layout layout = m_pData->m_listLayout.back();
        return layout.m_height;
    }
}
コード例 #26
0
ファイル: tooltip.cpp プロジェクト: 12307/VLC-for-VS2010
void Tooltip::makeImage( const UString &rText )
{
    // Render the text on a bitmap
    GenericBitmap *pBmpTip = m_rFont.drawString( rText, 0 );
    if( !pBmpTip )
    {
        return;
    }
    int w = pBmpTip->getWidth() + 10;
    int h = m_rFont.getSize() + 8;

    // Create the image of the tooltip
    delete m_pImage;
    m_pImage = OSFactory::instance( getIntf() )->createOSGraphics( w, h );
    m_pImage->fillRect( 0, 0, w, h, 0xffffd0 );
    m_pImage->drawRect( 0, 0, w, h, 0x000000 );
    m_pImage->drawBitmap( *pBmpTip, 0, 0, 5, 5, -1, -1, true );

    delete pBmpTip;
}
コード例 #27
0
ファイル: theme_loader.cpp プロジェクト: paa/vlc
string ThemeLoader::getFilePath( const string &rFullPath )
{
    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
    const string &sep = pOsFactory->getDirSeparator();
    // Find the last separator ('/' or '\')
    string::size_type p = rFullPath.rfind( sep, rFullPath.size() );
    string basePath;
    if( p != string::npos )
    {
        if( p < rFullPath.size() - 1)
        {
            basePath = rFullPath.substr( 0, p );
        }
        else
        {
            basePath = rFullPath;
        }
    }
    return basePath;
}
コード例 #28
0
ファイル: var_tree.cpp プロジェクト: qdk0901/vlc
VarTree::Iterator VarTree::add( int id, const UStringPtr &rcString,
                  bool selected, bool playing, bool expanded, bool readonly,
                  int pos )
{
    Iterator it;
    if( pos == -1 )
    {
        it = m_children.end();
    }
    else
    {
        it = m_children.begin();
        for( int i = 0; i < pos && it != m_children.end(); ++it, i++ );
    }

    return m_children.insert( it,
                              VarTree( getIntf(), this, id, rcString,
                                       selected, playing,
                                       expanded, readonly ) );
}
コード例 #29
0
ファイル: dialogs.cpp プロジェクト: AsamQi/vlc
void Dialogs::showFileGeneric( const string &rTitle, const string &rExtensions,
                               DlgCallback callback, int flags )
{
    if( m_pProvider && m_pProvider->pf_show_dialog )
    {
        intf_dialog_args_t *p_arg = (intf_dialog_args_t*)
                                    calloc( 1, sizeof( intf_dialog_args_t ) );

        p_arg->psz_title = strdup( rTitle.c_str() );
        p_arg->psz_extensions = strdup( rExtensions.c_str() );

        p_arg->b_save = flags & kSAVE;
        p_arg->b_multiple = flags & kMULTIPLE;

        p_arg->p_arg = getIntf();
        p_arg->pf_callback = callback;

        m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILE_GENERIC,
                                     0, p_arg );
    }
}
コード例 #30
0
ファイル: ctrl_resize.cpp プロジェクト: 0xheart0/vlc
void CtrlResize::CmdResizeResize::execute()
{
    EvtMotion *pEvtMotion = static_cast<EvtMotion*>(m_pParent->m_pEvt);

    m_pParent->changeCursor( m_pParent->m_direction );

    int newWidth = m_pParent->m_width;
    newWidth += pEvtMotion->getXPos() - m_pParent->m_xPos;
    int newHeight = m_pParent->m_height;
    newHeight += pEvtMotion->getYPos() - m_pParent->m_yPos;

    // Create a resize command, instead of calling the window manager directly.
    // Thanks to this trick, the duplicate resizing commands will be trashed
    // in the asynchronous queue, thus making resizing faster
    CmdGeneric *pCmd = new CmdResize( m_pParent->getIntf(),
                                      m_pParent->m_rWindowManager,
                                      m_pParent->m_rLayout,
                                      newWidth, newHeight );
    // Push the command in the asynchronous command queue
    AsyncQueue::instance( getIntf() )->push( CmdGenericPtr( pCmd ) );
}