[browser] add exception handling.
[vuplus_dvbapp] / lib / actions / action.cpp
index f0debf2..a2d85ff 100644 (file)
@@ -2,6 +2,7 @@
 #include <lib/base/init.h>
 #include <lib/base/init_num.h>
 #include <lib/actions/actionids.h>
+#include <lib/driver/rc.h>
 
 /*
 
@@ -87,7 +88,7 @@ void eActionMap::unbindAction(const std::string &context, ePyObject function)
 }
 
 
-void eActionMap::bindKey(const std::string &device, int key, int flags, const std::string &context, const std::string &action)
+void eActionMap::bindKey(const std::string &domain, const std::string &device, int key, int flags, const std::string &context, const std::string &action)
 {
                // first, search the actionlist table
        unsigned int i;
@@ -101,6 +102,7 @@ void eActionMap::bindKey(const std::string &device, int key, int flags, const st
                        bind.m_key = key;
                        bind.m_flags = flags;
                        bind.m_action = actions[i].m_id;
+                       bind.m_domain = domain;
                        m_native_keys.insert(std::pair<std::string,eNativeKeyBinding>(context, bind));
                        return;
                }
@@ -113,9 +115,27 @@ void eActionMap::bindKey(const std::string &device, int key, int flags, const st
        bind.m_key = key;
        bind.m_flags = flags;
        bind.m_action = action;
+       bind.m_domain = domain;
        m_python_keys.insert(std::pair<std::string,ePythonKeyBinding>(context, bind));
 }
 
+void eActionMap::unbindKeyDomain(const std::string &domain)
+{
+       for (std::multimap<std::string, eNativeKeyBinding>::iterator i(m_native_keys.begin()); i != m_native_keys.end(); ++i)
+               if (i->second.m_domain == domain)
+               {
+                       m_native_keys.erase(i);
+                       i = m_native_keys.begin();
+               }
+
+       for (std::multimap<std::string, ePythonKeyBinding>::iterator i(m_python_keys.begin()); i != m_python_keys.end(); ++i)
+               if (i->second.m_domain == domain)
+               {
+                       m_python_keys.erase(i);
+                       i = m_python_keys.begin();
+               }
+}
+
 struct call_entry
 {
        ePyObject m_fnc, m_arg;
@@ -130,9 +150,14 @@ void eActionMap::keyPressed(const std::string &device, int key, int flags)
        std::list<call_entry> call_list;
        
                /* iterate active contexts. */
-       for (std::multimap<int,eActionBinding>::const_iterator c(m_bindings.begin());
+       for (std::multimap<int,eActionBinding>::iterator c(m_bindings.begin());
                c != m_bindings.end(); ++c)
        {
+               if (flags == eRCKey::flagMake)
+                       c->second.m_prev_seen_make_key = key;
+               else if (c->second.m_prev_seen_make_key != key)  // ignore repeat or break when the make code for this key was not visible
+                       continue;
+
                        /* is this a native context? */
                if (c->second.m_widget)
                {
@@ -183,7 +208,7 @@ void eActionMap::keyPressed(const std::string &device, int key, int flags)
                                }
                        } else
                        {
-                               eDebug("wildcard.");
+//                             eDebug("wildcard.");
                                ePyObject pArgs = PyTuple_New(2);
                                PyTuple_SET_ITEM(pArgs, 0, PyInt_FromLong(key));
                                PyTuple_SET_ITEM(pArgs, 1, PyInt_FromLong(flags));