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) ...@@ -6,7 +6,7 @@ noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla)
MOSTLYCLEANFILES = $(npvlc_DATA) MOSTLYCLEANFILES = $(npvlc_DATA)
CLEANFILES = stamp-pic $(BUILT_SOURCES) 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 = \ SOURCES_mozilla_common = \
vlcshell.cpp \ vlcshell.cpp \
......
...@@ -61,6 +61,7 @@ const NPUTF8 * const LibvlcRootNPObject::propertyNames[] = ...@@ -61,6 +61,7 @@ const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
{ {
"audio", "audio",
"input", "input",
"log",
"playlist", "playlist",
"video", "video",
"VersionInfo", "VersionInfo",
...@@ -70,38 +71,54 @@ const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propert ...@@ -70,38 +71,54 @@ const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propert
enum LibvlcRootNPObjectPropertyIds enum LibvlcRootNPObjectPropertyIds
{ {
ID_audio = 0, ID_root_audio = 0,
ID_input, ID_root_input,
ID_playlist, ID_root_log,
ID_video, ID_root_playlist,
ID_VersionInfo, ID_root_video,
ID_root_VersionInfo,
}; };
RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result)
{ {
switch( index ) VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{ {
case ID_audio: switch( index )
OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result); {
return INVOKERESULT_NO_ERROR; case ID_root_audio:
case ID_input: OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result); return INVOKERESULT_NO_ERROR;
return INVOKERESULT_NO_ERROR; case ID_root_input:
case ID_playlist: OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result); return INVOKERESULT_NO_ERROR;
return INVOKERESULT_NO_ERROR; case ID_root_log:
case ID_video: OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result); return INVOKERESULT_NO_ERROR;
return INVOKERESULT_NO_ERROR; case ID_root_playlist:
case ID_VersionInfo: OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
NPUTF8 *versionStr = NULL; return INVOKERESULT_NO_ERROR;
case ID_root_video:
versionStr = strdup( VLC_Version() ); OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
if (!versionStr) return INVOKERESULT_NO_ERROR;
return INVOKERESULT_GENERIC_ERROR; case ID_root_VersionInfo:
{
STRINGZ_TO_NPVARIANT(versionStr, result); int len = strlen(VLC_Version());
return INVOKERESULT_NO_ERROR; 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; return INVOKERESULT_GENERIC_ERROR;
} }
...@@ -115,7 +132,7 @@ const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNam ...@@ -115,7 +132,7 @@ const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNam
enum LibvlcRootNPObjectMethodIds enum LibvlcRootNPObjectMethodIds
{ {
ID_version, ID_root_versionInfo,
}; };
RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) 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 ...@@ -128,21 +145,25 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVari
switch( index ) switch( index )
{ {
case ID_version: case ID_root_versionInfo:
if( argCount == 0 ) if( argCount == 0 )
{ {
NPUTF8 *versionStr = NULL; int len = strlen(VLC_Version());
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
versionStr = strdup( VLC_Version() ); if( retval )
if (!versionStr) {
return INVOKERESULT_GENERIC_ERROR; memcpy(retval, VLC_Version(), len);
STRINGN_TO_NPVARIANT(retval, len, result);
STRINGZ_TO_NPVARIANT(versionStr, result); }
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
default: default:
return INVOKERESULT_NO_SUCH_METHOD; ;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -162,8 +183,8 @@ const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::prope ...@@ -162,8 +183,8 @@ const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::prope
enum LibvlcAudioNPObjectPropertyIds enum LibvlcAudioNPObjectPropertyIds
{ {
ID_mute, ID_audio_mute,
ID_volume, ID_audio_volume,
}; };
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
...@@ -176,7 +197,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -176,7 +197,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
switch( index ) switch( index )
{ {
case ID_mute: case ID_audio_mute:
{ {
vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex); vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
...@@ -188,7 +209,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -188,7 +209,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(muted, result); BOOLEAN_TO_NPVARIANT(muted, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_volume: case ID_audio_volume:
{ {
int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex); int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
...@@ -200,6 +221,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -200,6 +221,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(volume, result); INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -215,7 +238,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -215,7 +238,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
switch( index ) switch( index )
{ {
case ID_mute: case ID_audio_mute:
if( NPVARIANT_IS_BOOLEAN(value) ) if( NPVARIANT_IS_BOOLEAN(value) )
{ {
libvlc_audio_set_mute(p_plugin->getVLC(), libvlc_audio_set_mute(p_plugin->getVLC(),
...@@ -229,7 +252,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -229,7 +252,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
case ID_volume: case ID_audio_volume:
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_audio_set_volume(p_plugin->getVLC(), libvlc_audio_set_volume(p_plugin->getVLC(),
...@@ -243,6 +266,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -243,6 +266,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -257,7 +282,7 @@ const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodN ...@@ -257,7 +282,7 @@ const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodN
enum LibvlcAudioNPObjectMethodIds enum LibvlcAudioNPObjectMethodIds
{ {
ID_togglemute, ID_audio_togglemute,
}; };
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) 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 ...@@ -270,7 +295,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
switch( index ) switch( index )
{ {
case ID_togglemute: case ID_audio_togglemute:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex); libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
...@@ -288,7 +313,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar ...@@ -288,7 +313,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
default: default:
return INVOKERESULT_NO_SUCH_METHOD; ;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -313,13 +338,13 @@ const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::prope ...@@ -313,13 +338,13 @@ const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::prope
enum LibvlcInputNPObjectPropertyIds enum LibvlcInputNPObjectPropertyIds
{ {
ID_length, ID_input_length,
ID_position, ID_input_position,
ID_time, ID_input_time,
ID_state, ID_input_state,
ID_rate, ID_input_rate,
ID_fps, ID_input_fps,
ID_hasvout, ID_input_hasvout,
}; };
RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result)
...@@ -333,7 +358,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -333,7 +358,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
if( index != ID_state ) if( index != ID_input_state )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -349,7 +374,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -349,7 +374,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
switch( index ) switch( index )
{ {
case ID_length: case ID_input_length:
{ {
double val = (double)libvlc_input_get_length(p_input, &ex); double val = (double)libvlc_input_get_length(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -362,7 +387,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -362,7 +387,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_position: case ID_input_position:
{ {
double val = libvlc_input_get_position(p_input, &ex); double val = libvlc_input_get_position(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -375,7 +400,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -375,7 +400,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_time: case ID_input_time:
{ {
double val = (double)libvlc_input_get_time(p_input, &ex); double val = (double)libvlc_input_get_time(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -388,7 +413,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -388,7 +413,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_state: case ID_input_state:
{ {
int val = libvlc_input_get_state(p_input, &ex); int val = libvlc_input_get_state(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -401,7 +426,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -401,7 +426,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_rate: case ID_input_rate:
{ {
float val = libvlc_input_get_rate(p_input, &ex); float val = libvlc_input_get_rate(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -414,7 +439,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -414,7 +439,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_fps: case ID_input_fps:
{ {
double val = libvlc_input_get_fps(p_input, &ex); double val = libvlc_input_get_fps(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -427,7 +452,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -427,7 +452,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_hasvout: case ID_input_hasvout:
{ {
vlc_bool_t val = libvlc_input_has_vout(p_input, &ex); vlc_bool_t val = libvlc_input_has_vout(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -440,6 +465,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -440,6 +465,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(val, result); BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default:
;
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
...@@ -464,7 +491,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -464,7 +491,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
switch( index ) switch( index )
{ {
case ID_position: case ID_input_position:
{ {
if( ! NPVARIANT_IS_DOUBLE(value) ) if( ! NPVARIANT_IS_DOUBLE(value) )
{ {
...@@ -483,7 +510,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -483,7 +510,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_time: case ID_input_time:
{ {
vlc_int64_t val; vlc_int64_t val;
if( NPVARIANT_IS_INT32(value) ) if( NPVARIANT_IS_INT32(value) )
...@@ -506,7 +533,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -506,7 +533,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_rate: case ID_input_rate:
{ {
float val; float val;
if( NPVARIANT_IS_INT32(value) ) if( NPVARIANT_IS_INT32(value) )
...@@ -529,6 +556,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -529,6 +556,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default:
;
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
...@@ -559,93 +588,99 @@ const int LibvlcMessageNPObject::propertyCount = sizeof(LibvlcMessageNPObject::p ...@@ -559,93 +588,99 @@ const int LibvlcMessageNPObject::propertyCount = sizeof(LibvlcMessageNPObject::p
enum LibvlcMessageNPObjectPropertyIds enum LibvlcMessageNPObjectPropertyIds
{ {
ID_severity, ID_message_severity,
ID_type, ID_message_type,
ID_name, ID_message_name,
ID_header, ID_message_header,
ID_message, ID_message_message,
}; };
RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
{ {
switch( index ) VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{ {
case ID_severity: switch( index )
{
INT32_TO_NPVARIANT(_msg.i_severity, result);
return INVOKERESULT_NO_ERROR;
}
case ID_type:
{ {
if( _msg.psz_type ) case ID_message_severity:
{
int len = strlen(_msg.psz_type);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_type, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{ {
NULL_TO_NPVARIANT(result); INT32_TO_NPVARIANT(_msg.i_severity, result);
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_ERROR; case ID_message_type:
}
case ID_name:
{
if( _msg.psz_name )
{ {
int len = strlen(_msg.psz_name); if( _msg.psz_type )
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{ {
memcpy(retval, _msg.psz_name, len); int len = strlen(_msg.psz_type);
STRINGN_TO_NPVARIANT(retval, len, result); NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_type, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
} }
} else
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
}
case ID_header:
{
if( _msg.psz_header )
{
int len = strlen(_msg.psz_header);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{ {
memcpy(retval, _msg.psz_header, len); NULL_TO_NPVARIANT(result);
STRINGN_TO_NPVARIANT(retval, len, result);
} }
return INVOKERESULT_NO_ERROR;
} }
else case ID_message_name:
{ {
NULL_TO_NPVARIANT(result); if( _msg.psz_name )
{
int len = strlen(_msg.psz_name);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_name, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_ERROR; case ID_message_header:
}
case ID_message:
{
if( _msg.psz_message )
{ {
int len = strlen(_msg.psz_message); if( _msg.psz_header )
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{ {
memcpy(retval, _msg.psz_message, len); int len = strlen(_msg.psz_header);
STRINGN_TO_NPVARIANT(retval, len, result); NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_header, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{
NULL_TO_NPVARIANT(result);
} }
return INVOKERESULT_NO_ERROR;
} }
else case ID_message_message:
{ {
NULL_TO_NPVARIANT(result); if( _msg.psz_message )
{
int len = strlen(_msg.psz_message);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_message, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_ERROR; default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -662,17 +697,27 @@ const int LibvlcMessageNPObject::methodCount = sizeof(LibvlcMessageNPObject::met ...@@ -662,17 +697,27 @@ const int LibvlcMessageNPObject::methodCount = sizeof(LibvlcMessageNPObject::met
** implementation of libvlc message iterator object ** 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; VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_vlclog->_p_log ) if( p_plugin )
{ {
_p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL); libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
_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[] = const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
{ {
"hasNext", "hasNext",
...@@ -682,33 +727,39 @@ const int LibvlcMessageIteratorNPObject::propertyCount = sizeof(LibvlcMessageIte ...@@ -682,33 +727,39 @@ const int LibvlcMessageIteratorNPObject::propertyCount = sizeof(LibvlcMessageIte
enum LibvlcMessageIteratorNPObjectPropertyIds enum LibvlcMessageIteratorNPObjectPropertyIds
{ {
ID_hasNext, ID_messageiterator_hasNext,
}; };
RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
{ {
switch( index ) VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{ {
case ID_hasNext: switch( index )
{ {
if( _p_iter && _p_vlclog->_p_log ) case ID_messageiterator_hasNext:
{ {
libvlc_exception_t ex; if( _p_iter && p_plugin->getLog() )
libvlc_exception_init(&ex); {
libvlc_exception_t ex;
libvlc_exception_init(&ex);
BOOLEAN_TO_NPVARIANT(libvlc_log_iterator_has_next(_p_iter, &ex), result); BOOLEAN_TO_NPVARIANT(libvlc_log_iterator_has_next(_p_iter, &ex), result);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));