Commit b99ae3e2 authored by Damien Fouilleul's avatar Damien Fouilleul

all: activex plugin Set/GetVariable support all of VLC types

parent 30efcc2b
......@@ -355,15 +355,13 @@ STDMETHODIMP VLCControl::setVariable( BSTR name, VARIANT value)
HRESULT hr = E_INVALIDARG;
int i_type;
vlc_value_t val;
if( VLC_SUCCESS == VLC_VariableType(i_vlc, psz_varname, &i_type) )
{
VARIANT arg;
VariantInit(&arg);
vlc_value_t val;
hr = DISP_E_TYPEMISMATCH;
switch( i_type )
{
case VLC_VAR_BOOL:
......@@ -373,6 +371,7 @@ STDMETHODIMP VLCControl::setVariable( BSTR name, VARIANT value)
break;
case VLC_VAR_INTEGER:
case VLC_VAR_HOTKEY:
hr = VariantChangeType(&value, &arg, 0, VT_I4);
if( SUCCEEDED(hr) )
val.i_int = V_I4(&arg);
......@@ -385,21 +384,66 @@ STDMETHODIMP VLCControl::setVariable( BSTR name, VARIANT value)
break;
case VLC_VAR_STRING:
case VLC_VAR_MODULE:
case VLC_VAR_FILE:
case VLC_VAR_DIRECTORY:
case VLC_VAR_VARIABLE:
hr = VariantChangeType(&value, &arg, 0, VT_BSTR);
if( SUCCEEDED(hr) )
{
val.psz_string = CStrFromBSTR(codePage, V_BSTR(&arg));
VariantClear(&arg);
}
break;
case VLC_VAR_TIME:
// use a double value to represent time (base is expressed in seconds)
hr = VariantChangeType(&value, &arg, 0, VT_R8);
if( SUCCEEDED(hr) )
val.i_time = (signed __int64)(V_R8(&arg)*1000000.0);
break;
default:
hr = DISP_E_TYPEMISMATCH;
}
}
else {
// no defined type, defaults to VARIANT type
hr = NO_ERROR;
switch( V_VT(&value) )
{
case VT_BOOL:
val.b_bool = (VARIANT_TRUE == V_BOOL(&value)) ? VLC_TRUE : VLC_FALSE;
i_type = VLC_VAR_BOOL;
break;
case VT_I4:
val.i_int = V_I4(&value);
i_type = VLC_VAR_INTEGER;
break;
case VT_R4:
val.f_float = V_R4(&value);
i_type = VLC_VAR_FLOAT;
break;
case VT_BSTR:
val.psz_string = CStrFromBSTR(codePage, V_BSTR(&value));
i_type = VLC_VAR_STRING;
break;
case VT_R8:
// use a double value to represent time (base is expressed in seconds)
val.i_time = (signed __int64)(V_R8(&value)*1000000.0);
i_type = VLC_VAR_TIME;
break;
default:
hr = DISP_E_TYPEMISMATCH;
}
}
if( SUCCEEDED(hr) )
{
VariantClear(&arg);
hr = (VLC_SUCCESS == VLC_VariableSet(i_vlc, psz_varname, val)) ? NOERROR : E_FAIL;
if( (VLC_VAR_STRING == i_type) && (NULL != val.psz_string) )
free(val.psz_string);
}
}
free(psz_varname);
return hr;
......@@ -440,6 +484,7 @@ STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
break;
case VLC_VAR_INTEGER:
case VLC_VAR_HOTKEY:
V_VT(value) = VT_I4;
V_I4(value) = val.i_int;
break;
......@@ -450,10 +495,21 @@ STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
break;
case VLC_VAR_STRING:
case VLC_VAR_MODULE:
case VLC_VAR_FILE:
case VLC_VAR_DIRECTORY:
case VLC_VAR_VARIABLE:
V_VT(value) = VT_BSTR;
V_BSTR(value) = BSTRFromCStr(codePage, val.psz_string);
free(val.psz_string);
break;
case VLC_VAR_TIME:
// use a double value to represent time (base is expressed in seconds)
V_VT(value) = VT_R8;
V_R8(value) = ((double)val.i_time)/1000000.0;
break;
default:
hr = DISP_E_TYPEMISMATCH;
}
......
......@@ -1043,6 +1043,37 @@ int VLC_VariableType( int i_object, char const *psz_var, int *pi_type )
return VLC_ENOOBJ;
}
/* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
* we handle it as a configuration variable. Don't tell Gildas :) -- sam */
if( !strncmp( psz_var, "conf::", 6 ) )
{
module_config_t *p_item;
char const *psz_newvar = psz_var + 6;
p_item = config_FindConfig( VLC_OBJECT(p_vlc), psz_newvar );
if( p_item )
{
switch( p_item->i_type )
{
case CONFIG_ITEM_BOOL:
i_type = VLC_VAR_BOOL;
break;
case CONFIG_ITEM_INTEGER:
i_type = VLC_VAR_INTEGER;
break;
case CONFIG_ITEM_FLOAT:
i_type = VLC_VAR_FLOAT;
break;
default:
i_type = VLC_VAR_STRING;
break;
}
}
else
i_type = 0;
}
else
i_type = VLC_VAR_TYPE & var_Type( p_vlc , psz_var );
if( i_object ) vlc_object_release( p_vlc );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment