diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 2d66258774ff97337fbedc2488b63b6e4d5f0596..6dd1183c99f096b9800b6d08699050982352f03e 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -2297,6 +2297,7 @@ dbus_get_shortcuts(void) { GError *error = NULL; GHashTable * shortcuts; + if (!org_sflphone_SFLphone_ConfigurationManager_get_shortcuts( configurationManagerProxy, &shortcuts, &error)) { diff --git a/sflphone-client-gnome/src/shortcuts.c b/sflphone-client-gnome/src/shortcuts.c index 652d4496ea46c4059d7e5bdf4714f65559550a9d..4e95667171ebce1496d3270f7fa403d96031bda7 100644 --- a/sflphone-client-gnome/src/shortcuts.c +++ b/sflphone-client-gnome/src/shortcuts.c @@ -387,6 +387,8 @@ shortcuts_initialize_bindings () gchar* action, *maskAndKey, *token1, *token2 = NULL; guint mask, key = 0; + DEBUG("Shortcuts: Initialize bindings"); + // get shortcuts stored in config through dbus shortcutsMap = dbus_get_shortcuts (); @@ -402,7 +404,6 @@ shortcuts_initialize_bindings () action = shortcutsKeysElement->data; maskAndKey = g_strdup (g_hash_table_lookup (shortcutsMap, action)); - DEBUG("-------------------- maskAndKey %s", maskAndKey); token1 = strtok (maskAndKey, "x"); token2 = strtok (NULL, "x"); @@ -411,7 +412,7 @@ shortcuts_initialize_bindings () // Value not setted if (token1 && token2){ - DEBUG("token1 %s, token2 %s", token1, token2); + DEBUG("Ahortcuts: token1 %s, token2 %s", token1, token2); mask = atoi (token1); key = atoi (token2); @@ -465,17 +466,15 @@ filter_keys (const GdkXEvent *xevent, const GdkEvent *event, gpointer data) int i = 0; xev = (XEvent *) xevent; - if (xev->type != KeyPress) - { - return GDK_FILTER_CONTINUE; - } + if (xev->type != KeyPress) { + return GDK_FILTER_CONTINUE; + } key = (XKeyEvent *) xevent; keystate = key->state & ~(Mod2Mask | Mod5Mask | LockMask); // try to find corresponding action - while (accelerators_list[i].action != NULL) - { + while (accelerators_list[i].action != NULL) { if (accelerators_list[i].key == key->keycode && accelerators_list[i].mask == keystate) { diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index 8f0e2bd02d2673b89bd218ff915a151703764acc..e64a4edff402ad31966ae67eec913ed39d978615 100755 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -733,6 +733,8 @@ std::map<std::string, std::string> ConfigurationManager::getShortcuts() { void ConfigurationManager::setShortcuts( const std::map<std::string, std::string>& shortcutsMap) { + std::map<std::string, std::string> map_cpy = shortcutsMap; + /* std::map<std::string, std::string> map_cpy = shortcutsMap; std::map<std::string, std::string>::iterator it; @@ -740,9 +742,12 @@ void ConfigurationManager::setShortcuts( std::string key = shortcutsKeys.at(i); it = map_cpy.find(key); if (it != shortcutsMap.end()) { + Manager::instance().setConfig("Shortcuts", key, it->second); } } + */ + Manager::instance().shortcutPreferences.setShortcuts(map_cpy); Manager::instance().saveConfig(); } diff --git a/sflphone-common/src/preferences.cpp b/sflphone-common/src/preferences.cpp index 70fb6eb7406b6452e70a13cbd5a3464dcc8f7e63..23566f24d2ef5a6b125898645d89a7acbcd7c5b2 100644 --- a/sflphone-common/src/preferences.cpp +++ b/sflphone-common/src/preferences.cpp @@ -444,54 +444,49 @@ ShortcutPreferences::ShortcutPreferences() : _hangup("") ShortcutPreferences::~ShortcutPreferences() {} -std::map<std::string, std::string> ShortcutPreferences::getShortcuts() +std::map<std::string, std::string> ShortcutPreferences::getShortcuts() { std::map<std::string, std::string> shortcutsMap; - shortcutsMap.insert(std::pair<std::string, std::string>(hangupShortKey, _hangup.data())); - shortcutsMap.insert(std::pair<std::string, std::string>(pickupShortKey, _pickup.data())); - shortcutsMap.insert(std::pair<std::string, std::string>(popupShortKey, _popup.data())); - shortcutsMap.insert(std::pair<std::string, std::string>(toggleHoldShortKey, _toggleHold.data())); - shortcutsMap.insert(std::pair<std::string, std::string>(togglePickupHangupShortKey, _togglePickupHangup.data())); + shortcutsMap.insert(std::pair<std::string, std::string>(hangupShortKey, _hangup)); + shortcutsMap.insert(std::pair<std::string, std::string>(pickupShortKey, _pickup)); + shortcutsMap.insert(std::pair<std::string, std::string>(popupShortKey, _popup)); + shortcutsMap.insert(std::pair<std::string, std::string>(toggleHoldShortKey, _toggleHold)); + shortcutsMap.insert(std::pair<std::string, std::string>(togglePickupHangupShortKey, _togglePickupHangup)); return shortcutsMap; } -void ShortcutPreferences::setShortcuts(std::map<std::string, int> shortcut) +void ShortcutPreferences::setShortcuts(std::map<std::string, std::string> map_cpy) { - std::map<std::string, int> map_cpy = shortcut; - std::map<std::string, int>::iterator it; + // std::map<std::string, int> map_cpy = shortcut; + std::map<std::string, std::string>::iterator it; it = map_cpy.find(hangupShortKey); if (it != map_cpy.end()) { - std::stringstream hangupstr; hangupstr << it->second; - _hangup = hangupstr.str(); + _hangup = it->second; } it = map_cpy.find(pickupShortKey); if (it != map_cpy.end()) { - std::stringstream pickupstr; pickupstr << it->second; - _pickup = pickupstr.str(); + _pickup = it->second; } it = map_cpy.find(popupShortKey); if (it != map_cpy.end()) { - std::stringstream popupstr; popupstr << it->second; - _popup = popupstr.str(); + _popup = it->second; } it = map_cpy.find(toggleHoldShortKey); if(it != map_cpy.end()) { - std::stringstream holdstr; holdstr << it->second; - _toggleHold = holdstr.str(); + _toggleHold = it->second; } it = map_cpy.find(togglePickupHangupShortKey); if(it != map_cpy.end()) { - std::stringstream togglestr; togglestr << it->second; - _togglePickupHangup = togglestr.str(); + _togglePickupHangup = it->second; } /* for (int i = 0; i < (int)shortcutsKeys.size(); i++) { @@ -537,13 +532,13 @@ void ShortcutPreferences::unserialize(Conf::MappingNode *map) Conf::ScalarNode *val = NULL; val = (Conf::ScalarNode *)(map->getValue(hangupShortKey)); - if(val) { _hangup = atoi(val->getValue().data()); val = NULL; } + if(val) { _hangup = val->getValue(); val = NULL; } val = (Conf::ScalarNode *)(map->getValue(pickupShortKey)); - if(val) { _pickup = atoi(val->getValue().data()); val = NULL; } + if(val) { _pickup = val->getValue(); val = NULL; } val = (Conf::ScalarNode *)(map->getValue(popupShortKey)); - if(val) { _popup = atoi(val->getValue().data()); val = NULL; } + if(val) { _popup = val->getValue(); val = NULL; } val = (Conf::ScalarNode *)(map->getValue(toggleHoldShortKey)); - if(val) { _toggleHold = atoi(val->getValue().data()); val = NULL; } + if(val) { _toggleHold = val->getValue(); val = NULL; } val = (Conf::ScalarNode *)(map->getValue(togglePickupHangupShortKey)); - if(val) { _togglePickupHangup = atoi(val->getValue().data()); val = NULL; } + if(val) { _togglePickupHangup = val->getValue(); val = NULL; } } diff --git a/sflphone-common/src/preferences.h b/sflphone-common/src/preferences.h index 34b42f4227ce035c749013a1b7ba02bea2703f9c..cc3d8e380414c390b081e58731fd99ebbdeb0145 100755 --- a/sflphone-common/src/preferences.h +++ b/sflphone-common/src/preferences.h @@ -375,8 +375,8 @@ class ShortcutPreferences : public Serializable { virtual void unserialize(Conf::MappingNode *map); + void setShortcuts(std::map<std::string, std::string> shortcut); std::map<std::string, std::string> getShortcuts(void); - void setShortcuts(std::map<std::string, int> shortcut); std::string getHangup(void) { return _hangup; } void setHangup(std::string hangup) { _hangup = hangup; }