Commit 7bba9f86 authored by Damien Fouilleul's avatar Damien Fouilleul

mozilla: backporting from 0.8.6

parent 12478f83
......@@ -6,7 +6,7 @@ noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla)
MOSTLYCLEANFILES = $(npvlc_DATA)
CLEANFILES = stamp-pic $(BUILT_SOURCES)
EXTRA_DIST = $(DIST_sources) npvlc_rc.rc vlc.r
EXTRA_DIST = $(DIST_sources) install.js npvlc_rc.rc vlc.r
SOURCES_mozilla_common = \
vlcshell.cpp \
......
......@@ -61,6 +61,7 @@ const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
{
"audio",
"input",
"log",
"playlist",
"video",
"VersionInfo",
......@@ -70,39 +71,55 @@ const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propert
enum LibvlcRootNPObjectPropertyIds
{
ID_audio = 0,
ID_input,
ID_playlist,
ID_video,
ID_VersionInfo,
ID_root_audio = 0,
ID_root_input,
ID_root_log,
ID_root_playlist,
ID_root_video,
ID_root_VersionInfo,
};
RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_audio:
case ID_root_audio:
OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
return INVOKERESULT_NO_ERROR;
case ID_input:
case ID_root_input:
OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
return INVOKERESULT_NO_ERROR;
case ID_playlist:
case ID_root_log:
OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
return INVOKERESULT_NO_ERROR;
case ID_root_playlist:
OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
return INVOKERESULT_NO_ERROR;
case ID_video:
case ID_root_video:
OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
return INVOKERESULT_NO_ERROR;
case ID_VersionInfo:
NPUTF8 *versionStr = NULL;
versionStr = strdup( VLC_Version() );
if (!versionStr)
return INVOKERESULT_GENERIC_ERROR;
STRINGZ_TO_NPVARIANT(versionStr, result);
case ID_root_VersionInfo:
{
int len = strlen(VLC_Version());
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, VLC_Version(), len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -115,7 +132,7 @@ const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNam
enum LibvlcRootNPObjectMethodIds
{
ID_version,
ID_root_versionInfo,
};
RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
......@@ -128,21 +145,25 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVari
switch( index )
{
case ID_version:
case ID_root_versionInfo:
if( argCount == 0 )
{
NPUTF8 *versionStr = NULL;
versionStr = strdup( VLC_Version() );
if (!versionStr)
return INVOKERESULT_GENERIC_ERROR;
STRINGZ_TO_NPVARIANT(versionStr, result);
int len = strlen(VLC_Version());
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, VLC_Version(), len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -162,8 +183,8 @@ const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::prope
enum LibvlcAudioNPObjectPropertyIds
{
ID_mute,
ID_volume,
ID_audio_mute,
ID_audio_volume,
};
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
......@@ -176,7 +197,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
switch( index )
{
case ID_mute:
case ID_audio_mute:
{
vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
......@@ -188,7 +209,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(muted, result);
return INVOKERESULT_NO_ERROR;
}
case ID_volume:
case ID_audio_volume:
{
int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
......@@ -200,6 +221,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -215,7 +238,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
switch( index )
{
case ID_mute:
case ID_audio_mute:
if( NPVARIANT_IS_BOOLEAN(value) )
{
libvlc_audio_set_mute(p_plugin->getVLC(),
......@@ -229,7 +252,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
case ID_volume:
case ID_audio_volume:
if( isNumberValue(value) )
{
libvlc_audio_set_volume(p_plugin->getVLC(),
......@@ -243,6 +266,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -257,7 +282,7 @@ const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodN
enum LibvlcAudioNPObjectMethodIds
{
ID_togglemute,
ID_audio_togglemute,
};
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
......@@ -270,7 +295,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
switch( index )
{
case ID_togglemute:
case ID_audio_togglemute:
if( argCount == 0 )
{
libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
......@@ -288,7 +313,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -313,13 +338,13 @@ const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::prope
enum LibvlcInputNPObjectPropertyIds
{
ID_length,
ID_position,
ID_time,
ID_state,
ID_rate,
ID_fps,
ID_hasvout,
ID_input_length,
ID_input_position,
ID_input_time,
ID_input_state,
ID_input_rate,
ID_input_fps,
ID_input_hasvout,
};
RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result)
......@@ -333,7 +358,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
{
if( index != ID_state )
if( index != ID_input_state )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -349,7 +374,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
switch( index )
{
case ID_length:
case ID_input_length:
{
double val = (double)libvlc_input_get_length(p_input, &ex);
libvlc_input_free(p_input);
......@@ -362,7 +387,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_position:
case ID_input_position:
{
double val = libvlc_input_get_position(p_input, &ex);
libvlc_input_free(p_input);
......@@ -375,7 +400,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_time:
case ID_input_time:
{
double val = (double)libvlc_input_get_time(p_input, &ex);
libvlc_input_free(p_input);
......@@ -388,7 +413,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_state:
case ID_input_state:
{
int val = libvlc_input_get_state(p_input, &ex);
libvlc_input_free(p_input);
......@@ -401,7 +426,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_rate:
case ID_input_rate:
{
float val = libvlc_input_get_rate(p_input, &ex);
libvlc_input_free(p_input);
......@@ -414,7 +439,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_fps:
case ID_input_fps:
{
double val = libvlc_input_get_fps(p_input, &ex);
libvlc_input_free(p_input);
......@@ -427,7 +452,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_hasvout:
case ID_input_hasvout:
{
vlc_bool_t val = libvlc_input_has_vout(p_input, &ex);
libvlc_input_free(p_input);
......@@ -440,6 +465,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
libvlc_input_free(p_input);
}
......@@ -464,7 +491,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
switch( index )
{
case ID_position:
case ID_input_position:
{
if( ! NPVARIANT_IS_DOUBLE(value) )
{
......@@ -483,7 +510,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
case ID_time:
case ID_input_time:
{
vlc_int64_t val;
if( NPVARIANT_IS_INT32(value) )
......@@ -506,7 +533,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
case ID_rate:
case ID_input_rate:
{
float val;
if( NPVARIANT_IS_INT32(value) )
......@@ -529,6 +556,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
libvlc_input_free(p_input);
}
......@@ -559,23 +588,26 @@ const int LibvlcMessageNPObject::propertyCount = sizeof(LibvlcMessageNPObject::p
enum LibvlcMessageNPObjectPropertyIds
{
ID_severity,
ID_type,
ID_name,
ID_header,
ID_message,
ID_message_severity,
ID_message_type,
ID_message_name,
ID_message_header,
ID_message_message,
};
RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_severity:
case ID_message_severity:
{
INT32_TO_NPVARIANT(_msg.i_severity, result);
return INVOKERESULT_NO_ERROR;
}
case ID_type:
case ID_message_type:
{
if( _msg.psz_type )
{
......@@ -593,7 +625,7 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
case ID_name:
case ID_message_name:
{
if( _msg.psz_name )
{
......@@ -611,7 +643,7 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
case ID_header:
case ID_message_header:
{
if( _msg.psz_header )
{
......@@ -629,7 +661,7 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
case ID_message:
case ID_message_message:
{
if( _msg.psz_message )
{
......@@ -647,6 +679,9 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -662,17 +697,27 @@ const int LibvlcMessageNPObject::methodCount = sizeof(LibvlcMessageNPObject::met
** implementation of libvlc message iterator object
*/
void LibvlcMessageIteratorNPObject::setLog(LibvlcLogNPObject* p_vlclog)
LibvlcMessageIteratorNPObject::LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass),
_p_iter(NULL)
{
_p_vlclog = p_vlclog;
if( p_vlclog->_p_log )
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
_p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
_p_iter = libvlc_log_get_iterator(p_log, NULL);
}
}
else
_p_iter = NULL;
};
LibvlcMessageIteratorNPObject::~LibvlcMessageIteratorNPObject()
{
if( _p_iter )
libvlc_log_iterator_free(_p_iter, NULL);
}
const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
{
"hasNext",
......@@ -682,16 +727,19 @@ const int LibvlcMessageIteratorNPObject::propertyCount = sizeof(LibvlcMessageIte
enum LibvlcMessageIteratorNPObjectPropertyIds
{
ID_hasNext,
ID_messageiterator_hasNext,
};
RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_hasNext:
case ID_messageiterator_hasNext:
{
if( _p_iter && _p_vlclog->_p_log )
if( _p_iter && p_plugin->getLog() )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
......@@ -710,6 +758,9 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int ind
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -728,7 +779,8 @@ enum LibvlcMessageIteratorNPObjectMethodIds
RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
{
if( _p_iter && _p_vlclog->_p_log )
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
......@@ -737,6 +789,8 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, c
{
case ID_messageiterator_next:
if( argCount == 0 )
{
if( _p_iter && p_plugin->getLog() )
{
struct libvlc_log_message_t buffer;
......@@ -762,8 +816,11 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, c
return INVOKERESULT_OUT_OF_MEMORY;
}
}
default:
return INVOKERESULT_GENERIC_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -782,16 +839,19 @@ const int LibvlcMessagesNPObject::propertyCount = sizeof(LibvlcMessagesNPObject:
enum LibvlcMessagesNPObjectPropertyIds
{
ID_count,
ID_messages_count,
};
RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_count:
case ID_messages_count:
{
libvlc_log_t *p_log = _p_vlclog->_p_log;
libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
libvlc_exception_t ex;
......@@ -811,6 +871,9 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::getProperty(int index, NPV
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -826,11 +889,14 @@ const int LibvlcMessagesNPObject::methodCount = sizeof(LibvlcMessagesNPObject::m
enum LibvlcMessagesNPObjectMethodIds
{
ID_messages_clear,
ID_iterator,
ID_messages_iterator,
};
RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
......@@ -839,7 +905,7 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NP
case ID_messages_clear:
if( argCount == 0 )
{
libvlc_log_t *p_log = _p_vlclog->_p_log;
libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
libvlc_log_clear(p_log, &ex);
......@@ -854,14 +920,13 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NP
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_iterator:
case ID_messages_iterator:
if( argCount == 0 )
{
LibvlcMessageIteratorNPObject* iter =
static_cast<LibvlcMessageIteratorNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageIteratorNPObject>::getClass()));
if( iter )
{
iter->setLog(_p_vlclog);
OBJECT_TO_NPVARIANT(iter, result);
return INVOKERESULT_NO_ERROR;
}
......@@ -870,15 +935,29 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NP
return INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
/*
** implementation of libvlc message object
*/
LibvlcLogNPObject::LibvlcLogNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass)
{
_p_vlcmessages = static_cast<LibvlcMessagesNPObject*>(NPN_CreateObject(instance, RuntimeNPClass<LibvlcMessagesNPObject>::getClass()));
};
LibvlcLogNPObject::~LibvlcLogNPObject()
{
NPN_ReleaseObject(_p_vlcmessages);
};
const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
{
"messages",
......@@ -889,8 +968,8 @@ const int LibvlcLogNPObject::propertyCount = sizeof(LibvlcLogNPObject::propertyN
enum LibvlcLogNPObjectPropertyIds
{
ID_messages,
ID_verbosity,
ID_log_messages,
ID_log_verbosity,
};
RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVariant &result)
......@@ -903,14 +982,14 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian
switch( index )
{
case ID_messages:
case ID_log_messages:
{
OBJECT_TO_NPVARIANT(NPN_RetainObject(_p_vlcmessages), result);
return INVOKERESULT_NO_ERROR;
}
case ID_verbosity:
case ID_log_verbosity:
{
if( _p_log )
if( p_plugin->getLog() )
{
INT32_TO_NPVARIANT(libvlc_get_log_verbosity(p_plugin->getVLC(),
&ex), result);
......@@ -928,6 +1007,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -943,22 +1024,24 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
switch( index )
{
case ID_verbosity:
case ID_log_verbosity:
if( isNumberValue(value) )
{
libvlc_instance_t* p_libvlc = p_plugin->getVLC();
libvlc_log_t *p_log = p_plugin->getLog();
int verbosity = numberValue(value);
if( verbosity >= 0 )
{
if( ! _p_log )
if( ! p_log )
{
_p_log = libvlc_log_open(p_libvlc, &ex);
p_log = libvlc_log_open(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
p_plugin->setLog(p_log);
}
libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
if( libvlc_exception_raised(&ex) )
......@@ -968,11 +1051,11 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
return INVOKERESULT_GENERIC_ERROR;
}
}
else if( _p_log )
else if( p_log )
{
/* close log when verbosity is set to -1 */
libvlc_log_close(_p_log, &ex);
_p_log = NULL;
p_plugin->setLog(NULL);
libvlc_log_close(p_log, &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
......@@ -983,6 +1066,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -995,23 +1080,146 @@ const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
const int LibvlcLogNPObject::methodCount = sizeof(LibvlcLogNPObject::methodNames)/sizeof(NPUTF8 *);
/*
** implementation of libvlc playlist items object
*/
const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
{
"count",
};
const int LibvlcPlaylistItemsNPObject::propertyCount = sizeof(LibvlcPlaylistItemsNPObject::propertyNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistItemsNPObjectPropertyIds
{
ID_playlistitems_count,
};
RuntimeNPObject::InvokeResult LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
switch( index )
{
case ID_playlistitems_count:
{
int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
{
"clear",
"remove",
};
const int LibvlcPlaylistItemsNPObject::methodCount = sizeof(LibvlcPlaylistItemsNPObject::methodNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistItemsNPObjectMethodIds
{
ID_playlistitems_clear,