Changeset 9809 in vbox
- Timestamp:
- Jun 19, 2008 8:28:07 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/VBoxInfoSvc.h
r9727 r9809 57 57 /** Prefix for extra data keys used by the get and set key value functions */ 58 58 #define VBOX_SHARED_INFO_KEY_PREFIX "Guest/" 59 /** Helper macro for the length of the prefix VBOX_SHARED_INFO_KEY_PREFIX */ 60 #define VBOX_SHARED_INFO_PREFIX_LEN (sizeof(VBOX_SHARED_INFO_KEY_PREFIX) - 1) 59 61 /** Maximum length for extra data keys used by the get and set key value functions */ 60 62 enum { KEY_MAX_LEN = 64 }; -
trunk/src/VBox/Main/ConsoleImpl.cpp
r8684 r9809 82 82 83 83 #include <VBox/HostServices/VBoxClipboardSvc.h> 84 #ifdef VBOX_WITH_INFO_SVC 85 # include <VBox/HostServices/VBoxInfoSvc.h> 86 #endif 84 87 85 88 #include <set> … … 4013 4016 4014 4017 AutoWriteLock alock (this); 4018 int vrc = VINF_SUCCESS; 4015 4019 4016 4020 /* sanity */ … … 4052 4056 alock.enter(); 4053 4057 } 4058 # ifdef VBOX_WITH_INFO_SVC 4059 /* Save all guest/host configuration registry entries to the machine XML 4060 * file as extra data. */ 4061 PCFGMNODE pRegistry = CFGMR3GetChild (CFGMR3GetRoot (mpVM), "Guest/Registry/"); 4062 PCFGMLEAF pValue = CFGMR3GetFirstValue (pRegistry); 4063 vrc = VINF_SUCCESS; 4064 while (pValue != NULL && RT_SUCCESS(vrc)) 4065 { 4066 using namespace svcInfo; 4067 char szKeyName[KEY_MAX_LEN]; 4068 char szKeyValue[KEY_MAX_VALUE_LEN]; 4069 char szExtraDataName[VBOX_SHARED_INFO_PREFIX_LEN + KEY_MAX_LEN]; 4070 vrc = CFGMR3GetValueName (pValue, szKeyName, KEY_MAX_LEN); 4071 if (RT_SUCCESS(vrc)) 4072 vrc = CFGMR3QueryString (pRegistry, szKeyName, szKeyValue, sizeof(szKeyValue)); 4073 if (RT_SUCCESS(vrc)) 4074 { 4075 strcpy(szExtraDataName, VBOX_SHARED_INFO_KEY_PREFIX); 4076 strncpy(szExtraDataName + VBOX_SHARED_INFO_PREFIX_LEN, szKeyName, sizeof(szKeyName)); 4077 szExtraDataName[sizeof(szExtraDataName) - 1] = 0; 4078 } 4079 if (RT_SUCCESS(vrc)) 4080 if (FAILED(mMachine->SetExtraData(Bstr(szExtraDataName).raw(), Bstr(szKeyValue).raw()))) 4081 vrc = VERR_UNRESOLVED_ERROR; /* We only need to know that we have to stop. */ 4082 if (RT_SUCCESS(vrc)) 4083 pValue = CFGMR3GetNextValue (pValue); 4084 } 4085 # endif /* VBOX_WITH_INFO_SVC defined */ 4054 4086 #endif /* VBOX_HGCM */ 4055 4087 … … 4086 4118 4087 4119 HRESULT rc = S_OK; 4088 intvrc = VINF_SUCCESS;4120 vrc = VINF_SUCCESS; 4089 4121 4090 4122 /* -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r9728 r9809 1664 1664 rc = CFGMR3InsertNode(pRoot, "Guest", &pGuest); RC_CHECK(); 1665 1665 rc = CFGMR3InsertNode(pGuest, "Registry", &pRegistry); RC_CHECK(); 1666 /* Load the saved machine registry. This is stored as extra data 1667 * keys in the machine XML file, starting with the prefix 1668 * VBOX_SHARED_INFO_KEY_PREFIX. */ 1669 Bstr strExtraDataKey; 1670 for (;;) 1671 { 1672 Bstr strNextExtraDataKey; 1673 Bstr strExtraDataValue; 1674 1675 /* get the next key */ 1676 hrc = pMachine->GetNextExtraDataKey(strExtraDataKey, strNextExtraDataKey.asOutParam(), 1677 strExtraDataValue.asOutParam()); 1678 1679 /* stop if for some reason there's nothing more to request */ 1680 if (FAILED(hrc) || !strNextExtraDataKey) 1681 break; 1682 1683 strExtraDataKey = strNextExtraDataKey; 1684 Utf8Str strExtraDataKeyUtf8 = Utf8Str(strExtraDataKey); 1685 1686 /* we only care about keys starting with VBOX_SHARED_INFO_KEY_PREFIX */ 1687 if (strncmp(strExtraDataKeyUtf8.raw(), VBOX_SHARED_INFO_KEY_PREFIX, VBOX_SHARED_INFO_PREFIX_LEN) != 0) 1688 continue; 1689 char *pszCFGMValueName = (char*)strExtraDataKeyUtf8.raw() + VBOX_SHARED_INFO_PREFIX_LEN; 1690 1691 /* now let's have a look at the value */ 1692 Utf8Str strCFGMValueUtf8 = Utf8Str(strExtraDataValue); 1693 const char *pszCFGMValue = strCFGMValueUtf8.raw(); 1694 /* empty value means remove value which we've already done */ 1695 if (pszCFGMValue && *pszCFGMValue) 1696 { 1697 rc = CFGMR3InsertString(pRegistry, pszCFGMValueName, pszCFGMValue); 1698 AssertMsgRC(rc, ("failed to insert CFGM value '%s' to key '%s'\n", pszCFGMValue, pszCFGMValueName)); 1699 } 1700 } 1701 1666 1702 /* Setup the service. */ 1667 1703 VBOXHGCMSVCPARM parm;
Note:
See TracChangeset
for help on using the changeset viewer.