[Herecast-commit] herecast/src/HerecastLib/APDB Location.cpp,1.8,1.9 Location.h,1.3,1.4
Status: Beta
Brought to you by:
mdpaciga
|
From: Mark P. <mdp...@us...> - 2005-07-21 20:57:40
|
Update of /cvsroot/herecast/herecast/src/HerecastLib/APDB In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18388/src/HerecastLib/APDB Modified Files: Location.cpp Location.h Log Message: added a SendMessage API, so third party applications can retrieve info from Herecast. This change included storing the most recent Ap* in the class itself, instead of as a static variable within the lookup method. Index: Location.h =================================================================== RCS file: /cvsroot/herecast/herecast/src/HerecastLib/APDB/Location.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Location.h 14 Dec 2004 06:36:41 -0000 1.3 --- Location.h 21 Jul 2005 19:56:32 -0000 1.4 *************** *** 18,24 **** --- 18,26 ---- WiFi *pWiFi; AccessPoint* pClosestAccessPoint; + Ap* pClosestAp; int nNextActiveScan; int lookup(TCHAR* atcLocationBuf, TCHAR* atcBuildingBuf); + int ApiReturnString(string str, HWND hWnd, HWND hWndDest); public: *************** *** 29,33 **** void click(); TCHAR* toString(DWORD *pnStatus = NULL, BOOL *pIsReliable = NULL); ! friend void location_bssidCallback(PNDIS_WLAN_BSSID pBSSID, void* data); --- 31,36 ---- void click(); TCHAR* toString(DWORD *pnStatus = NULL, BOOL *pIsReliable = NULL); ! int execAPIMsg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); ! friend void location_bssidCallback(PNDIS_WLAN_BSSID pBSSID, void* data); Index: Location.cpp =================================================================== RCS file: /cvsroot/herecast/herecast/src/HerecastLib/APDB/Location.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Location.cpp 14 Dec 2004 07:35:09 -0000 1.8 --- Location.cpp 21 Jul 2005 19:56:32 -0000 1.9 *************** *** 22,25 **** --- 22,26 ---- #include "../LibMain/stdafx.h" #include "../LibMain/resource.h" + #include "../LibMain/herecast.h" #include "Location.h" #include "apdb.h" *************** *** 71,74 **** --- 72,76 ---- this->pClosestAccessPoint = NULL; + this->pClosestAp = NULL; this->hInst = hInstance; this->nNextActiveScan = TODAYITEM_ACTIVESCAN_INTERVAL; *************** *** 124,129 **** int Location::lookup(TCHAR* atcLocationBuf, TCHAR* atcBuildingBuf) { - static Ap* pClosestAp = NULL; - UCHAR *oMacAddress = pClosestAccessPoint->getMacAddr(); --- 126,129 ---- *************** *** 295,296 **** --- 295,375 ---- pAPDB->checkUploadNeeded(); } + + + int Location::execAPIMsg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) + { + HWND hWndDest = (HWND) wParam; + COPYDATASTRUCT *pCD; + + if (!pClosestAp) { + return 0; + } + + switch (msg) { + case WM_COPYDATA: + pCD = (COPYDATASTRUCT*) lParam; + if (pCD->dwData == HC_PARSE_URL) { + string result = ""; + + int size = WideCharToMultiByte(CP_ACP, 0, (WCHAR*)pCD->lpData, -1, NULL, 0, 0, 0); + + char* lpBuffer = new char[size]; + + if (WideCharToMultiByte(CP_ACP, 0, (WCHAR*)pCD->lpData, -1, lpBuffer, size, 0, 0)) { + result = pClosestAp->parseUrl(lpBuffer); + } + + delete [] lpBuffer; + + return ApiReturnString(result, hWnd, hWndDest); + } + return 0; + + case HC_GET_BSSID: return ApiReturnString(pClosestAp->getBssid().toHexString(), hWnd, hWndDest); + case HC_GET_LOCATION: return ApiReturnString(pClosestAp->getLocation(), hWnd, hWndDest); + case HC_GET_FLOOR: return ApiReturnString(pClosestAp->getFloor(), hWnd, hWndDest); + case HC_GET_FLOOR2: return ApiReturnString(pClosestAp->getFloorDecorated(), hWnd, hWndDest); + case HC_GET_BUILDING: return ApiReturnString(pClosestAp->getBuilding(), hWnd, hWndDest); + case HC_GET_STREETADDR:return ApiReturnString(pClosestAp->getStreetaddr(), hWnd, hWndDest); + case HC_GET_AREA: return ApiReturnString(pClosestAp->getArea(), hWnd, hWndDest); + case HC_GET_CITY: return ApiReturnString(pClosestAp->getCity(), hWnd, hWndDest); + case HC_GET_PROVINCE: return ApiReturnString(pClosestAp->getProvince(), hWnd, hWndDest); + case HC_GET_COUNTRY: return ApiReturnString(pClosestAp->getCountry(), hWnd, hWndDest); + case HC_GET_NETWORK: return ApiReturnString(pClosestAp->getNetwork(), hWnd, hWndDest); + + case HC_GET_BUILDINGID:return pClosestAp->getBuildingId(); + case HC_GET_AREAID: return pClosestAp->getAreaId(); + case HC_GET_CITYID: return pClosestAp->getCityId(); + case HC_GET_PROVINCEID:return pClosestAp->getProvinceId(); + case HC_GET_COUNTRYID: return pClosestAp->getCountryId(); + case HC_GET_NETWORKID: return pClosestAp->getNetworkId(); + + } + + return 0; + } + + + int Location::ApiReturnString(string str, HWND hWnd, HWND hWndDest) + { + int result = 0; + + + // Convert the buffer from ASCII to Unicode. + int size = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0); + + WCHAR *lpBufferW = new WCHAR[size]; + + if (MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, lpBufferW, size)) { + COPYDATASTRUCT cd; + cd.dwData = 0; + cd.cbData = size * sizeof(WCHAR); + cd.lpData = lpBufferW; + + result = SendMessage(hWndDest, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cd); + } + + delete [] lpBufferW; + + return result; + } |