]> git.sesse.net Git - vlc/blobdiff - projects/activex/vlccontrol2.cpp
Replace libvlc_exception_get_message with libvlc_errmsg
[vlc] / projects / activex / vlccontrol2.cpp
index 8fcacd176c8fc515fedb3daccef0634826b18478..2acec96e03ae5590085504745145ce7f3e296d7d 100644 (file)
@@ -38,7 +38,7 @@ HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex)
 {
     if( libvlc_exception_raised(ex) )
     {
-        p->setErrorInfo(riid,libvlc_exception_get_message(ex));
+        p->setErrorInfo(riid,libvlc_errmsg());
         libvlc_exception_clear(ex);
         return E_FAIL;
     }
@@ -51,6 +51,7 @@ HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex)
 
 EMIT_EXCEPTION_BRIDGE( VLCAudio )
 EMIT_EXCEPTION_BRIDGE( VLCInput )
+EMIT_EXCEPTION_BRIDGE( VLCMarquee )
 EMIT_EXCEPTION_BRIDGE( VLCMessageIterator )
 EMIT_EXCEPTION_BRIDGE( VLCMessages )
 EMIT_EXCEPTION_BRIDGE( VLCLog )
@@ -623,7 +624,7 @@ VLCLog::~VLCLog()
 {
     delete _p_vlcmessages;
     if( _p_log )
-        libvlc_log_close(_p_log, NULL);
+        libvlc_log_close(_p_log);
 
     if( _p_typeinfo )
         _p_typeinfo->Release();
@@ -724,13 +725,7 @@ STDMETHODIMP VLCLog::get_verbosity(long* level)
         libvlc_instance_t* p_libvlc;
         HRESULT hr = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(hr) )
-        {
-            libvlc_exception_t ex;
-            libvlc_exception_init(&ex);
-
-            *level = libvlc_get_log_verbosity(p_libvlc, &ex);
-            hr = exception_bridge(&ex);
-        }
+            *level = libvlc_get_log_verbosity(p_libvlc);
         return hr;
     }
     else
@@ -758,12 +753,12 @@ STDMETHODIMP VLCLog::put_verbosity(long verbosity)
                 hr = exception_bridge(&ex);
             }
             if( SUCCEEDED(hr) )
-                libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
+                libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity);
         }
         else if( _p_log )
         {
             /* close log  when verbosity is set to -1 */
-            libvlc_log_close(_p_log, &ex);
+            libvlc_log_close(_p_log);
             _p_log = NULL;
         }
         hr = exception_bridge(&ex);
@@ -773,6 +768,252 @@ STDMETHODIMP VLCLog::put_verbosity(long verbosity)
 
 /*******************************************************************************/
 
+VLCMarquee::~VLCMarquee()
+{
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCMarquee::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
+        {
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMarquee, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
+        }
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMarquee::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+    if( NULL == ppTInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        _p_typeinfo->AddRef();
+        *ppTInfo = _p_typeinfo;
+        return NOERROR;
+    }
+    *ppTInfo = NULL;
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMarquee::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+        UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMarquee::Invoke(DISPID dispIdMember, REFIID riid,
+        LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+        VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMarquee::enable()
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::disable()
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::color(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::opacity(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::position(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::refresh(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::size(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::text(BSTR text)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        char *psz_text = CStrFromBSTR(CP_UTF8, text);
+        libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
+        hr = exception_bridge(&ex);
+        CoTaskMemFree(psz_text);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::timeout(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::x(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::y(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+/*******************************************************************************/
+
 /* STL forward iterator used by VLCEnumIterator class to implement IEnumVARIANT */
 
 class VLCMessageSTLIterator
@@ -953,38 +1194,20 @@ STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
 
 STDMETHODIMP VLCMessages::clear()
 {
-    HRESULT hr = NOERROR;
     libvlc_log_t *p_log = _p_vlclog->_p_log;
     if( p_log )
-    {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_log_clear(p_log, &ex);
-        hr = exception_bridge(&ex);
-    }
-    return hr;
+        libvlc_log_clear(p_log);
+    return NOERROR;
 };
 
 STDMETHODIMP VLCMessages::get_count(long* count)
 {
-    HRESULT hr = S_OK;
-
     if( NULL == count )
         return E_POINTER;
 
     libvlc_log_t *p_log = _p_vlclog->_p_log;
-    if( p_log )
-    {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        *count = libvlc_log_count(p_log, &ex);
-        hr = exception_bridge(&ex);
-    }
-    else
-        *count = 0;
-    return hr;
+    *count = libvlc_log_count(p_log);
+    return S_OK;
 };
 
 STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
@@ -1016,7 +1239,7 @@ VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog )
 VLCMessageIterator::~VLCMessageIterator()
 {
     if( _p_iter )
-        libvlc_log_iterator_free(_p_iter, NULL);
+        libvlc_log_iterator_free(_p_iter);
 
     if( _p_typeinfo )
         _p_typeinfo->Release();
@@ -1095,25 +1318,19 @@ STDMETHODIMP VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid,
 
 STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
 {
-    HRESULT hr = S_OK;
-
     if( NULL == hasNext )
         return E_POINTER;
 
     if( _p_iter &&  _p_vlclog->_p_log )
     {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        *hasNext = libvlc_log_iterator_has_next(_p_iter, &ex) ?
+        *hasNext = libvlc_log_iterator_has_next(_p_iter) ?
                    VARIANT_TRUE : VARIANT_FALSE;
-        hr = exception_bridge(&ex);
     }
     else
     {
         *hasNext = VARIANT_FALSE;
     }
-    return hr;
+    return S_OK;
 };
 
 STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
@@ -1129,17 +1346,10 @@ STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
 
         buffer.sizeof_msg = sizeof(buffer);
 
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_log_iterator_next(_p_iter, &buffer, &ex);
-        hr = exception_bridge(&ex);
-        if( SUCCEEDED(hr) )
-        {
-            *message = new VLCMessage(_p_instance, buffer);
-            if( !message )
-                hr = E_OUTOFMEMORY;
-        }
+        libvlc_log_iterator_next(_p_iter, &buffer);
+        *message = new VLCMessage(_p_instance, buffer);
+        if( !message )
+            hr = E_OUTOFMEMORY;
     }
     return hr;
 };
@@ -1900,6 +2110,7 @@ STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
 
 VLCVideo::~VLCVideo()
 {
+    delete _p_vlcmarquee;
     if( _p_typeinfo )
         _p_typeinfo->Release();
 };
@@ -2381,6 +2592,20 @@ STDMETHODIMP VLCVideo::toggleTeletext()
     return hr;
 };
 
+STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcmarquee;
+    if( NULL != _p_vlcmarquee )
+    {
+        _p_vlcmarquee->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
 /*******************************************************************************/
 
 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
@@ -2554,7 +2779,7 @@ STDMETHODIMP VLCControl2::get_Toolbar(VARIANT_BOOL *visible)
         return E_POINTER;
 
     /*
-     * Note to developpers
+     * Note to developers
      *
      * Returning the _b_toolbar is closer to the method specification.
      * But returning True when toolbar is not implemented so not displayed