- Timestamp:
- Oct 17, 2008 2:20:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r13328 r13376 91 91 pParm->u.uint64 = u64; 92 92 } 93 94 /** Extract a callback pointer value from an HGCM parameter structure */95 static int VBoxHGCMParmPtrGet (VBOXHGCMSVCPARM *pParm,96 PFNVBOXHGCMCALLBACK *ppfnCallback,97 void **ppvData)98 {99 if (pParm->type == VBOX_HGCM_SVC_PARM_CALLBACK)100 {101 *ppfnCallback = pParm->u.callback.pFunction;102 *ppvData = pParm->u.callback.pvData;103 return VINF_SUCCESS;104 }105 106 return VERR_INVALID_PARAMETER;107 }108 109 93 110 94 namespace guestProp { … … 135 119 /** Callback function supplied by the host for notification of updates 136 120 * to properties */ 137 PFN VBOXHGCMCALLBACKmpfnHostCallback;121 PFNHGCMSVCEXT mpfnHostCallback; 138 122 /** User data pointer to be supplied to the host callback function */ 139 123 void *mpvHostData; … … 207 191 SELF *pSelf = reinterpret_cast<SELF *>(pvService); 208 192 return pSelf->hostCall(u32Function, cParms, paParms); 193 } 194 195 /** 196 * @copydoc VBOXHGCMSVCHELPERS::pfnRegisterExtension 197 * Installs a host callback for notifications of property changes. 198 */ 199 static DECLCALLBACK(int) svcRegisterExtension (void *pvService, 200 PFNHGCMSVCEXT pfnExtension, 201 void *pvExtension) 202 { 203 AssertLogRelReturn(VALID_PTR(pvService), VERR_INVALID_PARAMETER); 204 SELF *pSelf = reinterpret_cast<SELF *>(pvService); 205 // pSelf->mpfnHostCallback = pfnExtension; 206 pSelf->mpvHostData = pvExtension; 207 return VINF_SUCCESS; 209 208 } 210 209 private: … … 218 217 int enumProps(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 219 218 void notifyHost(const char *pszProperty); 220 static DECLCALLBACK(int) reqNotify(PFN VBOXHGCMCALLBACKpfnCallback,219 static DECLCALLBACK(int) reqNotify(PFNHGCMSVCEXT pfnCallback, 221 220 void *pvData, char *pszName, 222 221 char *pszValue, uint32_t u32TimeHigh, … … 882 881 * @thread request thread 883 882 */ 884 int Service::reqNotify(PFN VBOXHGCMCALLBACKpfnCallback, void *pvData,883 int Service::reqNotify(PFNHGCMSVCEXT pfnCallback, void *pvData, 885 884 char *pszName, char *pszValue, uint32_t u32TimeHigh, 886 885 uint32_t u32TimeLow, char *pszFlags) 887 886 { 888 887 HOSTCALLBACKDATA HostCallbackData; 889 HostCallbackData.hdr.u32Magic = VBOXHGCMCALLBACKMAGIC; 890 HostCallbackData.hdr.cbStruct = sizeof(HostCallbackData); 891 HostCallbackData.hdr.pvData = pvData; 888 HostCallbackData.u32Magic = HOSTCALLBACKMAGIC; 892 889 HostCallbackData.pcszName = pszName; 893 890 HostCallbackData.pcszValue = pszValue; 894 891 HostCallbackData.u64Timestamp = RT_MAKE_U64(u32TimeLow, u32TimeHigh); 895 892 HostCallbackData.pcszFlags = pszFlags; 896 pfnCallback(&HostCallbackData.hdr); 893 AssertRC(pfnCallback(pvData, 0, reinterpret_cast<void *>(&HostCallbackData), 894 sizeof(HostCallbackData))); 897 895 RTStrFree(pszName); 898 896 RTStrFree(pszValue); … … 1037 1035 LogFlowFunc(("ENUM_PROPS\n")); 1038 1036 rc = enumProps(cParms, paParms); 1039 break;1040 case REGISTER_CALLBACK:1041 if ((1 != cParms) || (paParms[0].type != VBOX_HGCM_SVC_PARM_CALLBACK))1042 rc = VERR_INVALID_PARAMETER;1043 else1044 {1045 PFNVBOXHGCMCALLBACK pfnCallback = NULL;1046 void *pvData = NULL;1047 rc = VBoxHGCMParmPtrGet (&paParms[0], &pfnCallback, &pvData);1048 mpfnHostCallback = pfnCallback;1049 mpvHostData = pvData;1050 }1051 1037 break; 1052 1038 default: … … 1121 1107 ptable->cbClient = 0; 1122 1108 1123 ptable->pfnUnload = Service::svcUnload;1124 ptable->pfnConnect = Service::svcConnectDisconnect;1125 ptable->pfnDisconnect = Service::svcConnectDisconnect;1126 ptable->pfnCall = Service::svcCall;1127 ptable->pfnHostCall = Service::svcHostCall;1128 ptable->pfnSaveState = NULL; /* The service is stateless by definition, so the */1129 ptable->pfnLoadState = NULL; /* normal construction done before restoring suffices */1130 ptable->pfnRegisterExtension = NULL;1109 ptable->pfnUnload = Service::svcUnload; 1110 ptable->pfnConnect = Service::svcConnectDisconnect; 1111 ptable->pfnDisconnect = Service::svcConnectDisconnect; 1112 ptable->pfnCall = Service::svcCall; 1113 ptable->pfnHostCall = Service::svcHostCall; 1114 ptable->pfnSaveState = NULL; /* The service is stateless by definition, so the */ 1115 ptable->pfnLoadState = NULL; /* normal construction done before restoring suffices */ 1116 ptable->pfnRegisterExtension = Service::svcRegisterExtension; 1131 1117 1132 1118 /* Service specific initialization. */
Note:
See TracChangeset
for help on using the changeset viewer.