2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2015-02-21 14:38:14 +03:00
|
|
|
#include "cmWIXShortcut.h"
|
|
|
|
|
|
|
|
#include "cmWIXFilesSourceWriter.h"
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmWIXShortcuts::insert(Type type, std::string const& id,
|
|
|
|
cmWIXShortcut const& shortcut)
|
2015-02-21 14:38:14 +03:00
|
|
|
{
|
|
|
|
this->Shortcuts[type][id].push_back(shortcut);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmWIXShortcuts::empty(Type type) const
|
|
|
|
{
|
|
|
|
return this->Shortcuts.find(type) == this->Shortcuts.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmWIXShortcuts::EmitShortcuts(
|
2016-05-16 17:34:04 +03:00
|
|
|
Type type, std::string const& registryKey,
|
2015-02-21 14:38:14 +03:00
|
|
|
std::string const& cpackComponentName,
|
|
|
|
cmWIXFilesSourceWriter& fileDefinitions) const
|
|
|
|
{
|
|
|
|
shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == this->Shortcuts.end()) {
|
2015-02-21 14:38:14 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-21 14:38:14 +03:00
|
|
|
|
|
|
|
shortcut_id_map_t const& id_map = i->second;
|
|
|
|
|
|
|
|
std::string shortcutPrefix;
|
|
|
|
std::string registrySuffix;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (type) {
|
2015-02-21 14:38:14 +03:00
|
|
|
case START_MENU:
|
|
|
|
shortcutPrefix = "CM_S";
|
|
|
|
break;
|
|
|
|
case DESKTOP:
|
|
|
|
shortcutPrefix = "CM_DS";
|
|
|
|
registrySuffix = "_desktop";
|
|
|
|
break;
|
2015-02-21 20:07:36 +03:00
|
|
|
case STARTUP:
|
|
|
|
shortcutPrefix = "CM_SS";
|
|
|
|
registrySuffix = "_startup";
|
|
|
|
break;
|
2015-02-21 14:38:14 +03:00
|
|
|
default:
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-21 14:38:14 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (shortcut_id_map_t::const_iterator j = id_map.begin(); j != id_map.end();
|
|
|
|
++j) {
|
2015-02-21 14:38:14 +03:00
|
|
|
std::string const& id = j->first;
|
|
|
|
shortcut_list_t const& shortcutList = j->second;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t shortcutListIndex = 0; shortcutListIndex < shortcutList.size();
|
|
|
|
++shortcutListIndex) {
|
2015-02-21 19:30:31 +03:00
|
|
|
cmWIXShortcut const& shortcut = shortcutList[shortcutListIndex];
|
2016-05-16 17:34:04 +03:00
|
|
|
fileDefinitions.EmitShortcut(id, shortcut, shortcutPrefix,
|
|
|
|
shortcutListIndex);
|
2015-02-21 14:38:14 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-21 14:38:14 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
fileDefinitions.EmitInstallRegistryValue(registryKey, cpackComponentName,
|
|
|
|
registrySuffix);
|
2015-02-21 14:38:14 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
|
|
|
|
i != this->Shortcuts.end(); ++i) {
|
2015-02-21 14:38:14 +03:00
|
|
|
types.insert(i->first);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-21 14:38:14 +03:00
|
|
|
}
|
2015-02-21 19:30:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmWIXShortcuts::CreateFromProperties(std::string const& id,
|
|
|
|
std::string const& directoryId,
|
|
|
|
cmInstalledFile const& installedFile)
|
2015-02-21 19:30:31 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
CreateFromProperty("CPACK_START_MENU_SHORTCUTS", START_MENU, id, directoryId,
|
|
|
|
installedFile);
|
2015-02-21 19:30:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
CreateFromProperty("CPACK_DESKTOP_SHORTCUTS", DESKTOP, id, directoryId,
|
|
|
|
installedFile);
|
2015-02-21 20:07:36 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
CreateFromProperty("CPACK_STARTUP_SHORTCUTS", STARTUP, id, directoryId,
|
|
|
|
installedFile);
|
2015-02-21 19:30:31 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName,
|
|
|
|
Type type, std::string const& id,
|
|
|
|
std::string const& directoryId,
|
|
|
|
cmInstalledFile const& installedFile)
|
2015-02-21 19:30:31 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string> list;
|
|
|
|
installedFile.GetPropertyAsList(propertyName, list);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < list.size(); ++i) {
|
2015-02-21 19:30:31 +03:00
|
|
|
cmWIXShortcut shortcut;
|
|
|
|
shortcut.label = list[i];
|
|
|
|
shortcut.workingDirectoryId = directoryId;
|
|
|
|
insert(type, id, shortcut);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-21 19:30:31 +03:00
|
|
|
}
|