summaryrefslogtreecommitdiffstats
path: root/Source/CPack/WiX/cmWIXShortcut.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2015-02-21 11:38:14 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2015-02-21 11:38:14 (GMT)
commit53d7dafface62d40ea795456394f7ab1d5ee6712 (patch)
tree6c8e3c7038b1831b857b481c16071d493775e123 /Source/CPack/WiX/cmWIXShortcut.cxx
parentdc0f3fb44fb9384438ece513c12d83a36e385802 (diff)
downloadCMake-53d7dafface62d40ea795456394f7ab1d5ee6712.zip
CMake-53d7dafface62d40ea795456394f7ab1d5ee6712.tar.gz
CMake-53d7dafface62d40ea795456394f7ab1d5ee6712.tar.bz2
CPackWIX: Refactor start menu and desktop shortcut creation.
Diffstat (limited to 'Source/CPack/WiX/cmWIXShortcut.cxx')
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.cxx86
1 files changed, 86 insertions, 0 deletions
diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx
new file mode 100644
index 0000000..1c755ec
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXShortcut.cxx
@@ -0,0 +1,86 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2015 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmWIXShortcut.h"
+
+#include "cmWIXFilesSourceWriter.h"
+
+void cmWIXShortcuts::insert(
+ Type type, std::string const& id, cmWIXShortcut const& shortcut)
+{
+ this->Shortcuts[type][id].push_back(shortcut);
+}
+
+bool cmWIXShortcuts::empty(Type type) const
+{
+ return this->Shortcuts.find(type) == this->Shortcuts.end();
+}
+
+bool cmWIXShortcuts::EmitShortcuts(
+ Type type,
+ std::string const& registryKey,
+ std::string const& cpackComponentName,
+ cmWIXFilesSourceWriter& fileDefinitions) const
+{
+ shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type);
+
+ if(i == this->Shortcuts.end())
+ {
+ return false;
+ }
+
+ shortcut_id_map_t const& id_map = i->second;
+
+ std::string shortcutPrefix;
+ std::string registrySuffix;
+
+ switch(type)
+ {
+ case START_MENU:
+ shortcutPrefix = "CM_S";
+ break;
+ case DESKTOP:
+ shortcutPrefix = "CM_DS";
+ registrySuffix = "_desktop";
+ break;
+ default:
+ return false;
+ }
+
+ for(shortcut_id_map_t::const_iterator j = id_map.begin();
+ j != id_map.end(); ++j)
+ {
+ std::string const& id = j->first;
+ shortcut_list_t const& shortcutList = j->second;
+
+ for(shortcut_list_t::const_iterator k = shortcutList.begin();
+ k != shortcutList.end(); ++k)
+ {
+ cmWIXShortcut const& shortcut = *k;
+ fileDefinitions.EmitShortcut(id, shortcut, shortcutPrefix);
+ }
+ }
+
+ fileDefinitions.EmitInstallRegistryValue(
+ registryKey, cpackComponentName, registrySuffix);
+
+ return true;
+}
+
+void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
+{
+ for(shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
+ i != this->Shortcuts.end(); ++i)
+ {
+ types.insert(i->first);
+ }
+}