本文整理汇总了C++中OSFactory::getResourcePath方法的典型用法代码示例。如果您正苦于以下问题:C++ OSFactory::getResourcePath方法的具体用法?C++ OSFactory::getResourcePath怎么用?C++ OSFactory::getResourcePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSFactory
的用法示例。
在下文中一共展示了OSFactory::getResourcePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkinObject
ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
{
vlc_value_t val, text;
// Create a variable to add items in wxwindows popup menu
var_Create( pIntf, "intf-skins", VLC_VAR_STRING |
VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND );
text.psz_string = _("Select skin");
var_Change( pIntf, "intf-skins", VLC_VAR_SETTEXT, &text, NULL );
// Scan vlt files in the resource path
OSFactory *pOsFactory = OSFactory::instance( pIntf );
list<string> resPath = pOsFactory->getResourcePath();
list<string>::const_iterator it;
for( it = resPath.begin(); it != resPath.end(); it++ )
{
parseDirectory( *it );
}
// Set the callback
var_AddCallback( pIntf, "intf-skins", changeSkin, this );
// variable for opening a dialog box to change skins
var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID |
VLC_VAR_ISCOMMAND );
text.psz_string = _("Open skin ...");
var_Change( pIntf, "intf-skins-interactive", VLC_VAR_SETTEXT, &text, NULL );
// Set the callback
var_AddCallback( pIntf, "intf-skins-interactive", changeSkin, this );
}
示例2: LoadCatalog
void XMLParser::LoadCatalog()
{
// Get the resource path and look for the DTD
OSFactory *pOSFactory = OSFactory::instance( getIntf() );
const list<string> &resPath = pOSFactory->getResourcePath();
const string &sep = pOSFactory->getDirSeparator();
list<string>::const_iterator it;
#ifdef HAVE_SYS_STAT_H
struct stat statBuf;
// Try to load the catalog first (needed at least on win32 where
// we don't have a default catalog)
for( it = resPath.begin(); it != resPath.end(); ++it )
{
string catalog_path = (*it) + sep + "skin.catalog";
if( !stat( catalog_path.c_str(), &statBuf ) )
{
msg_Dbg( getIntf(), "Using catalog %s", catalog_path.c_str() );
xml_CatalogLoad( m_pXML, catalog_path.c_str() );
break;
}
}
if( it == resPath.end() )
{
// Ok, try the default one
xml_CatalogLoad( m_pXML, NULL );
}
for( it = resPath.begin(); it != resPath.end(); ++it )
{
string path = (*it) + sep + "skin.dtd";
if( !stat( path.c_str(), &statBuf ) )
{
// DTD found
msg_Dbg( getIntf(), "using DTD %s", path.c_str() );
// Add an entry in the default catalog
xml_CatalogAdd( m_pXML, "public",
"-//VideoLAN//DTD VLC Skins V"
SKINS_DTD_VERSION "//EN", path.c_str() );
break;
}
}
if( it == resPath.end() )
{
msg_Err( getIntf(), "cannot find the skins DTD");
}
#endif
}
示例3: extract
bool ThemeLoader::extract( const string &fileName )
{
bool result = true;
char *tmpdir = tempnam( NULL, "vlt" );
string tempPath = sFromLocale( tmpdir );
free( tmpdir );
// Extract the file in a temporary directory
if( ! extractTarGz( fileName, tempPath ) &&
! extractZip( fileName, tempPath ) )
{
deleteTempFiles( tempPath );
return false;
}
string path;
string xmlFile;
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
// Find the XML file in the theme
if( findFile( tempPath, DEFAULT_XML_FILE, xmlFile ) )
{
path = getFilePath( xmlFile );
}
else
{
// No XML file, check if it is a winamp2 skin
string mainBmp;
if( findFile( tempPath, "main.bmp", mainBmp ) )
{
msg_Dbg( getIntf(), "trying to load a winamp2 skin" );
path = getFilePath( mainBmp );
// Look for winamp2.xml in the resource path
list<string> resPath = pOsFactory->getResourcePath();
list<string>::const_iterator it;
for( it = resPath.begin(); it != resPath.end(); it++ )
{
if( findFile( *it, WINAMP2_XML_FILE, xmlFile ) )
break;
}
}
}
if( !xmlFile.empty() )
{
// Parse the XML file
if (! parse( path, xmlFile ) )
{
msg_Err( getIntf(), "error while parsing %s", xmlFile.c_str() );
result = false;
}
}
else
{
msg_Err( getIntf(), "no XML found in theme %s", fileName.c_str() );
result = false;
}
// Clean-up
deleteTempFiles( tempPath );
return result;
}
示例4: SkinObject
ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf )
{
vlc_value_t val, text;
// Create a variable to add items in wxwindows popup menu
var_Create( pIntf, "intf-skins", VLC_VAR_STRING |
VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND );
text.psz_string = _("Select skin");
var_Change( pIntf, "intf-skins", VLC_VAR_SETTEXT, &text, NULL );
// Scan vlt files in the resource path
OSFactory *pOsFactory = OSFactory::instance( pIntf );
list<string> resPath = pOsFactory->getResourcePath();
list<string>::const_iterator it;
for( it = resPath.begin(); it != resPath.end(); ++it )
{
parseDirectory( *it );
}
// retrieve skins from skins directories and locate default skins
map<string,string>::const_iterator itmap, itdefault;
for( itmap = m_skinsMap.begin(); itmap != m_skinsMap.end(); ++itmap )
{
string name = itmap->first;
string path = itmap->second;
val.psz_string = (char*) path.c_str();
text.psz_string = (char*) name.c_str();
var_Change( getIntf(), "intf-skins", VLC_VAR_ADDCHOICE, &val,
&text );
if( name == "Default" )
itdefault = itmap;
}
// retrieve last skins stored or skins requested by user
char* psz_current = var_InheritString( getIntf(), "skins2-last" );
string current = string( psz_current ? psz_current : "" );
free( psz_current );
// check if skins exists and is readable
bool b_readable = !ifstream( current.c_str() ).fail();
msg_Dbg( getIntf(), "requested skins %s is %s accessible",
current.c_str(), b_readable ? "" : "NOT" );
// set the default skins if given skins not accessible
if( !b_readable )
current = itdefault->second;
// save this valid skins for reuse
config_PutPsz( getIntf(), "skins2-last", current.c_str() );
// Update repository
updateRepository();
// Set the callback
var_AddCallback( pIntf, "intf-skins", changeSkin, this );
// variable for opening a dialog box to change skins
var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID |
VLC_VAR_ISCOMMAND );
text.psz_string = _("Open skin ...");
var_Change( pIntf, "intf-skins-interactive", VLC_VAR_SETTEXT, &text, NULL );
// Set the callback
var_AddCallback( pIntf, "intf-skins-interactive", changeSkin, this );
}
示例5: ThemeLoader
//---------------------------------------------------------------------------
// Run: main loop
//---------------------------------------------------------------------------
static void *Run( void * p_obj )
{
int canc = vlc_savecancel();
intf_thread_t *p_intf = (intf_thread_t *)p_obj;
bool b_error = false;
char *skin_last = NULL;
ThemeLoader *pLoader = NULL;
OSLoop *loop = NULL;
vlc_mutex_lock( &p_intf->p_sys->init_lock );
// Initialize singletons
if( OSFactory::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot initialize OSFactory" );
b_error = true;
goto end;
}
if( AsyncQueue::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot initialize AsyncQueue" );
b_error = true;
goto end;
}
if( Interpreter::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot instanciate Interpreter" );
b_error = true;
goto end;
}
if( VarManager::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot instanciate VarManager" );
b_error = true;
goto end;
}
if( VlcProc::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot initialize VLCProc" );
b_error = true;
goto end;
}
if( VoutManager::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot instanciate VoutManager" );
b_error = true;
goto end;
}
if( ThemeRepository::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot instanciate ThemeRepository" );
b_error = true;
goto end;
}
if( Dialogs::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "cannot instanciate qt4 dialogs provider" );
b_error = true;
goto end;
}
// Load a theme
skin_last = config_GetPsz( p_intf, "skins2-last" );
pLoader = new ThemeLoader( p_intf );
if( !skin_last || !*skin_last || !pLoader->load( skin_last ) )
{
// Get the resource path and try to load the default skin
OSFactory *pOSFactory = OSFactory::instance( p_intf );
const list<string> &resPath = pOSFactory->getResourcePath();
const string &sep = pOSFactory->getDirSeparator();
list<string>::const_iterator it;
for( it = resPath.begin(); it != resPath.end(); it++ )
{
string path = (*it) + sep + "default.vlt";
if( pLoader->load( path ) )
{
// Theme loaded successfully
break;
}
}
if( it == resPath.end() )
{
// Last chance: the user can select a new theme file
if( Dialogs::instance( p_intf ) )
{
CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf );
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
pQueue->push( CmdGenericPtr( pCmd ) );
}
else
{
// No dialogs provider, just quit...
CmdQuit *pCmd = new CmdQuit( p_intf );
//.........这里部分代码省略.........
示例6: Run
//---------------------------------------------------------------------------
// Run: main loop
//---------------------------------------------------------------------------
static void Run( intf_thread_t *p_intf )
{
// Load a theme
ThemeLoader *pLoader = new ThemeLoader( p_intf );
char *skin_last = config_GetPsz( p_intf, "skins2-last" );
if( !skin_last || !*skin_last || !pLoader->load( skin_last ) )
{
// Get the resource path and try to load the default skin
OSFactory *pOSFactory = OSFactory::instance( p_intf );
const list<string> &resPath = pOSFactory->getResourcePath();
const string &sep = pOSFactory->getDirSeparator();
list<string>::const_iterator it;
for( it = resPath.begin(); it != resPath.end(); it++ )
{
string path = (*it) + sep + "default.vlt";
if( pLoader->load( path ) )
{
// Theme loaded successfully
break;
}
}
if( it == resPath.end() )
{
// Last chance: the user can select a new theme file
if( Dialogs::instance( p_intf ) )
{
CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf );
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
pQueue->push( CmdGenericPtr( pCmd ) );
}
else
{
// No dialogs provider, just quit...
CmdQuit *pCmd = new CmdQuit( p_intf );
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
pQueue->push( CmdGenericPtr( pCmd ) );
msg_Err( p_intf,
"Cannot show the \"open skin\" dialog: exiting...");
}
}
}
delete pLoader;
if( skin_last )
{
free( skin_last );
}
// Get the instance of OSLoop
OSLoop *loop = OSFactory::instance( p_intf )->getOSLoop();
// Check if we need to start playing
if( p_intf->b_play )
{
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
}
// Enter the main event loop
loop->run();
// Delete the theme and save the configuration of the windows
if( p_intf->p_sys->p_theme )
{
p_intf->p_sys->p_theme->saveConfig();
delete p_intf->p_sys->p_theme;
p_intf->p_sys->p_theme = NULL;
}
}