Commit d7d59888 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Simplify events mapping

parent 49cdb3d1
......@@ -175,29 +175,19 @@ void EventObj::callback(const libvlc_event_t* event,
plugin_unlock(&lock);
}
vlcplugin_event_t *EventObj::find_event(const char *s) const
vlcplugin_event_t *EventObj::find_event(const NPString &name) const
{
for( size_t i = 0; i < ARRAY_SIZE(vlcevents); i++ )
{
if( strncmp(vlcevents[i].name, s, strlen(vlcevents[i].name)) == 0 )
if( strncmp(vlcevents[i].name, name.UTF8Characters, strlen(vlcevents[i].name)) == 0 )
return &vlcevents[i];
}
return NULL;
}
const char *EventObj::find_name(const libvlc_event_t *event)
{
for( size_t i = 0; i < ARRAY_SIZE(vlcevents); i++ )
{
if( vlcevents[i].libvlc_type == event->type )
return vlcevents[i].name;
}
return NULL;
}
bool EventObj::insert(const NPString &name, NPObject *listener, bool bubble)
{
vlcplugin_event_t *event = find_event(name.UTF8Characters);
vlcplugin_event_t *event = find_event(name);
if( !event )
return false;
......@@ -217,7 +207,7 @@ bool EventObj::insert(const NPString &name, NPObject *listener, bool bubble)
bool EventObj::remove(const NPString &name, NPObject *listener, bool bubble)
{
vlcplugin_event_t *event = find_event(name.UTF8Characters);
vlcplugin_event_t *event = find_event(name);
if( !event )
return false;
......
......@@ -85,7 +85,7 @@ private:
NPVariant *_npparams;
uint32_t _npcount;
};
libvlc_event_manager_t *_em; /* libvlc media_player event manager */
public:
EventObj(): _em(NULL), _already_in_deliver(false) { /* deferred to init() */ }
bool init();
......@@ -98,8 +98,9 @@ public:
void unhook_manager(void *);
void hook_manager(libvlc_event_manager_t *, void *);
private:
vlcplugin_event_t *find_event(const char *s) const;
const char *find_name(const libvlc_event_t *event);
libvlc_event_manager_t *_em; /* libvlc media_player event manager */
vlcplugin_event_t *find_event(const NPString &name) const;
typedef std::vector<Listener> lr_l;
typedef std::vector<VLCEvent> ev_l;
lr_l _llist; /* list of registered listeners with 'addEventListener' method */
......
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