CRegStdBase::CRegStdBase (const stdstring& key, bool force, HKEY base) : CRegBaseCommon<stdstring> (key, force, base) { stdstring::size_type pos = key.find_last_of(_T('\\')); m_path = key.substr(0, pos); m_key = key.substr(pos + 1); }
/** * Constructor. * @param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" * @param def the default value used when the key does not exist or a read error occured * @param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry * @param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. */ CRegStdWORD::CRegStdWORD(stdstring key, DWORD def, BOOL force, HKEY base) { m_value = 0; m_defaultvalue = def; m_force = force; m_base = base; m_read = FALSE; stdstring::size_type pos = key.find_last_of(_T('\\')); m_path = key.substr(0, pos); m_key = key.substr(pos + 1); read(); }
void CSIPropertyPage::InitWorkfileView() { LVCOLUMN lvCol; // Return if no files found or multiple if (m_filenames.empty() || m_filenames.size() != 1) return; // Get a reference to the list view m_list = GetDlgItem(m_hwnd, IDC_LIST2); // Macro enables group view ListView_EnableGroupView(m_list, TRUE); // Macro enables tool tips ListView_SetExtendedListViewStyle(m_list, LVS_EX_INFOTIP | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT); // Initialize columns appearing in list view SecureZeroMemory(&lvCol, sizeof(LVCOLUMN)); // Set the column titles std::wstring columnProp = getTortoiseSIString(IDS_PROP_NAME_COLUMN); std::wstring valueProp = getTortoiseSIString(IDS_PROP_VALUE_COLUMN); // Define the columns appearing in the list view lvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; lvCol.cx = 100; lvCol.pszText = (LPWSTR)columnProp.c_str(); SendMessage(m_list, LVM_INSERTCOLUMN, 0, (LPARAM)&lvCol); lvCol.cx = 225; lvCol.pszText = (LPWSTR)valueProp.c_str(); SendMessage(m_list, LVM_INSERTCOLUMN, 1, (LPARAM)&lvCol); // Retrieve highlighted file name const stdstring fileName = m_filenames.front(); // Check if folder or file properties should be displayed if (PathIsDirectory(fileName.c_str())) { initFolderProperties(fileName); } else { initFileProperties(fileName); } }
CCmdLineParser::ITERPOS CCmdLineParser::getNext(ITERPOS& pos, stdstring& sKey, stdstring& sValue) const { if (m_valueMap.end() == pos) { sKey.clear(); return pos; } else { sKey = pos->first; sValue = pos->second; return ++pos; } }
/** * Create and populate file properties page */ void CSIPropertyPage::initFileProperties(const stdstring file) { int iItemIndex = 0; int iGroupId = 100; LVGROUP lvGroup; LVITEM lvitem; // Retrieve group name std::wstring lockGrpName = getTortoiseSIString(IDS_PROP_LOCK_GROUP_NAME); // Retrieve property names std::wstring lockPropName = getTortoiseSIString(IDS_PROP_LOCK_NAME); std::wstring lockCpIdPropName = getTortoiseSIString(IDS_PROP_LOCK_CPID); std::wstring lockTypePropName = getTortoiseSIString(IDS_PROP_LOCK_TYPE); // Retrieve highlighted file name stdstring fileName = m_filenames.front(); // Retrieve file properties from Integrity std::shared_ptr<IntegrityActions::MemberProperties> memProp = IntegrityActions::getMemberInfo(IStatusCache::getInstance().getIntegritySession(), file.c_str()); // Can't retrieve properties if (!memProp) { return; } // Extract required properties std::wstring memRev = memProp->getMemberRev(); std::wstring workingRev = memProp->getWorkingRev(); std::wstring sandboxName = memProp->getSandboxName(); std::wstring cpId = memProp->getChangePackageId(); // Initialize entries in the list view SecureZeroMemory(&lvitem, sizeof(LVITEM)); // Specify member functions that contain data lvitem.mask = LVIF_TEXT | LVIF_GROUPID | LVIF_COLUMNS; // Retrieve the file locks and related info for (std::shared_ptr<IntegrityActions::LockProperties> lock : memProp->getLockers()) { LVGROUP lvLockGroup; // Increment the group id iGroupId++; // Extract lock info std::wstring lockName = lock->getLockName(); std::wstring lockType = lock->getLockType(); std::wstring lockCpId = lock->getLockChangePackageId(); SecureZeroMemory(&lvLockGroup, sizeof(LVGROUP)); // Insert the lock group - one for each lock lvLockGroup.cbSize = sizeof(LVGROUP); lvLockGroup.mask = LVGF_HEADER | LVGF_GROUPID; lvLockGroup.pszHeader = (LPWSTR)lockGrpName.c_str(); lvLockGroup.iGroupId = iGroupId; SendMessage(m_list, LVM_INSERTGROUP, 0, (LPARAM)&lvLockGroup); if (!lockName.empty()) { lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)lockPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)lockName.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } if (!lockCpId.empty()) { lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)lockCpIdPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)lockCpId.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } if (!lockType.empty()) { lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)lockTypePropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)lockType.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } } // Retrieve group file name std::wstring fileGrpName = getTortoiseSIString(IDS_PROP_FILE_GROUP_NAME); SecureZeroMemory(&lvGroup, sizeof(LVGROUP)); // Insert group containing file properties lvGroup.cbSize = sizeof(LVGROUP); lvGroup.mask = LVGF_HEADER | LVGF_GROUPID; lvGroup.pszHeader = (LPWSTR)fileGrpName.c_str(); lvGroup.iGroupId = iGroupId; SendMessage(m_list, LVM_INSERTGROUP, 0, (LPARAM)&lvGroup); if (!memRev.empty()) { std::wstring memberRevPropName = getTortoiseSIString(IDS_PROP_MEMBER_REV); lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)memberRevPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)memRev.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } if (!workingRev.empty()) { std::wstring workRevPropName = getTortoiseSIString(IDS_PROP_WORKING_REV); lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)workRevPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)workingRev.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } if (!cpId.empty()) { std::wstring cpIdPropName = getTortoiseSIString(IDS_PROP_WORKING_CPID); lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)cpIdPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)cpId.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } if (!sandboxName.empty()) { std::wstring sandboxNamePropName = getTortoiseSIString(IDS_PROP_SANDBOX_NAME); lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)sandboxNamePropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)sandboxName.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } // Holds file status std::wstring status; if (m_flags != 0) { if (hasFileStatus(m_flags, FileStatus::Member)) { if (!status.empty()) { status += _T(" | "); } status += _T("Member"); } if (hasFileStatus(m_flags, FileStatus::Locked)) { if (!status.empty()) { status += _T(" | "); } status += _T("Locked"); } if (hasFileStatus(m_flags, FileStatus::Incoming)) { if (!status.empty()) { status += _T(" | "); } status += _T("Incoming"); } if (hasFileStatus(m_flags, FileStatus::FormerMember)) { if (!status.empty()) { status += _T(" | "); } status += _T("FormerMember"); } if (hasFileStatus(m_flags, FileStatus::Modified)) { if (!status.empty()) { status += _T(" | "); } status += _T("Modified"); } if (hasFileStatus(m_flags, FileStatus::Moved)) { if (!status.empty()) { status += _T(" | "); } status += _T("Moved"); } if (hasFileStatus(m_flags, FileStatus::Renamed)) { if (!status.empty()) { status += _T(" | "); } status += _T("Renamed"); } if (hasFileStatus(m_flags, FileStatus::MergeNeeded)) { if (!status.empty()) { status += _T(" | "); } status += _T("MergeNeeded"); } if (hasFileStatus(m_flags, FileStatus::Drop)) { if (!status.empty()) { status += _T(" | "); } status += _T("Drop"); } if (hasFileStatus(m_flags, FileStatus::Add)) { if (!status.empty()) { status += _T(" | "); } status += _T("Add"); } } if (!status.empty()) { std::wstring statusPropName = getTortoiseSIString(IDS_PROP_STATUS); lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)statusPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)status.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } }
/** * Create and populate folder properties page */ void CSIPropertyPage::initFolderProperties(const stdstring folder) { int iItemIndex = 0; int iGroupId = 100; LVGROUP lvGroup; LVITEM lvitem; // Retrieve file properties from Integrity std::shared_ptr<IntegrityActions::FolderProperties> folderProp = IntegrityActions::getFolderInfo(IStatusCache::getInstance().getIntegritySession(), folder.c_str()); // Can't retrieve properties if (!folderProp) { return; } // Extract properties to be displayed from properties object time_t lastCheckpoint = folderProp->getLastCheckpoint(); std::wstring developmentPath = folderProp->getDevelopmentPath(); std::wstring projectName = folderProp->getProjectName(); std::wstring sandboxName = folderProp->getSandboxName(); std::wstring serverName = folderProp->getServerName(); std::wstring serverPort = folderProp->getServerPort(); std::wstring revision = folderProp->getRevision(); // Retrieve title for folder group displayed on properties page std::wstring folderGrpName = getTortoiseSIString(IDS_PROP_FOLDER_GROUP_NAME); SecureZeroMemory(&lvGroup, sizeof(LVGROUP)); // Insert group containing folder properties lvGroup.cbSize = sizeof(LVGROUP); lvGroup.mask = LVGF_HEADER | LVGF_GROUPID; lvGroup.pszHeader = (LPWSTR)folderGrpName.c_str(); lvGroup.iGroupId = iGroupId; SendMessage(m_list, LVM_INSERTGROUP, 0, (LPARAM)&lvGroup); // Initialize entries in the list view SecureZeroMemory(&lvitem, sizeof(LVITEM)); // Specify member functions that contain data lvitem.mask = LVIF_TEXT | LVIF_GROUPID | LVIF_COLUMNS; // Display devpath info if (!developmentPath.empty()) { // Retrieve property name to be displayed std::wstring devPathPropName = getTortoiseSIString(IDS_PROP_DEVPATH); // Create entry and add to list of properties lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)devPathPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)developmentPath.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } // Display project name if (!projectName.empty()) { // Retrieve property name to be displayed std::wstring projectNamePropName = getTortoiseSIString(IDS_PROP_PROJECT_NAME); // Create entry and add to list of properties lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)projectNamePropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)projectName.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } // Display sandbox name if (!sandboxName.empty()) { // Retrieve property name to be displayed std::wstring sandboxNamePropName = getTortoiseSIString(IDS_PROP_SANDBOX_NAME); // Create entry and add to list of properties lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)sandboxNamePropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)sandboxName.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } // Display server name and port if (!serverName.empty()) { // Stores server and port info std::wstring serverInfo; // Retrieve property name to be displayed std::wstring serverNamePropName = getTortoiseSIString(IDS_PROP_SERVER_NAME); // Display as <server name>:<port number> serverInfo += serverName; // Add port number to server info if (!serverPort.empty()) { serverInfo += _T(":"); serverInfo += serverPort; } // Create entry and add to list of properties lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)serverNamePropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)serverInfo.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } // Display checkpoint info if (!revision.empty()) { std::wstring revInfo; // Retrieve property name to be displayed std::wstring revisionPropName = getTortoiseSIString(IDS_PROP_REVISION); wchar_t timeBuf[30]; struct tm* timeinfo; // Display checkpoint time as dd/mm/yy hh:mm timeinfo = localtime(&lastCheckpoint); wcsftime(timeBuf, 30, L"%d/%m/%y %#I:%M %p", timeinfo); // Add time info to checkpoint revInfo += revision; revInfo += _T(" at "); revInfo += timeBuf; // Create entry and add to list of properties lvitem.iItem = iItemIndex; lvitem.iGroupId = iGroupId; lvitem.iSubItem = 0; lvitem.pszText = (LPWSTR)revisionPropName.c_str(); SendMessage(m_list, LVM_INSERTITEM, 0, (LPARAM)&lvitem); lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)revInfo.c_str(); SendMessage(m_list, LVM_SETITEMTEXT, iItemIndex++, (LPARAM)&lvitem); } }