[Herecast-commit] herecast/src/HerecastTester HerecastAPI.cpp,NONE,1.1 HerecastAPI.h,NONE,1.1 Hereca
Status: Beta
Brought to you by:
mdpaciga
|
From: Mark P. <mdp...@us...> - 2005-07-21 20:03:31
|
Update of /cvsroot/herecast/herecast/src/HerecastTester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15137/src/HerecastTester Added Files: HerecastAPI.cpp HerecastAPI.h HerecastTester.cpp HerecastTester.rc HerecastTester.vcp ReadMe.txt StdAfx.cpp StdAfx.h herecast.h newres.h resource.h Log Message: added HerecastTester project, initially just for testing the API --- NEW FILE: HerecastTester.vcp --- # Microsoft eMbedded Visual Tools Project File - Name="HerecastTester" - Package Owner=<4> # Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02 # ** DO NOT EDIT ** # TARGTYPE "Win32 (WCE ARMV4) Application" 0xa301 # TARGTYPE "Win32 (WCE emulator) Application" 0xa601 CFG=HerecastTester - Win32 (WCE emulator) Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "HerecastTester.vcn". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "HerecastTester.vcn" CFG="HerecastTester - Win32 (WCE emulator) Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "HerecastTester - Win32 (WCE emulator) Release" (based on "Win32 (WCE emulator) Application") !MESSAGE "HerecastTester - Win32 (WCE emulator) Debug" (based on "Win32 (WCE emulator) Application") !MESSAGE "HerecastTester - Win32 (WCE ARMV4) Release" (based on "Win32 (WCE ARMV4) Application") !MESSAGE "HerecastTester - Win32 (WCE ARMV4) Debug" (based on "Win32 (WCE ARMV4) Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" # PROP ATL_Project 2 !IF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "emulatorRel" # PROP BASE Intermediate_Dir "emulatorRel" # PROP BASE CPU_ID "{32E52003-403E-442D-BE48-DE10F8C6131D}" # PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "emulatorRel" # PROP Intermediate_Dir "emulatorRel" # PROP CPU_ID "{32E52003-403E-442D-BE48-DE10F8C6131D}" # PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP Target_Dir "" RSC=rc.exe # ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "_X86_" /d "x86" /d "_i386_" /r # ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "_X86_" /d "x86" /d "_i386_" /r CPP=cl.exe # ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "i_386_" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /Yu"stdafx.h" /Gs8192 /GF /O2 /c # ADD CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "i_386_" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /Yu"stdafx.h" /Gs8192 /GF /O2 /c MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 commctrl.lib coredll.lib $(CEx86Corelibc) aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86 # ADD LINK32 commctrl.lib coredll.lib $(CEx86Corelibc) aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86 !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "emulatorDbg" # PROP BASE Intermediate_Dir "emulatorDbg" # PROP BASE CPU_ID "{32E52003-403E-442D-BE48-DE10F8C6131D}" # PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "emulatorDbg" # PROP Intermediate_Dir "emulatorDbg" # PROP CPU_ID "{32E52003-403E-442D-BE48-DE10F8C6131D}" # PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP Target_Dir "" RSC=rc.exe # ADD BASE RSC /l 0x409 /d "$(CePlatform)" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "_X86_" /d "x86" /d "_i386_" /r # ADD RSC /l 0x409 /d "$(CePlatform)" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "_X86_" /d "x86" /d "_i386_" /r CPP=cl.exe # ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D "_i386_" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "i_386_" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /Yu"stdafx.h" /Gs8192 /GF /c # ADD CPP /nologo /W3 /Zi /Od /D "DEBUG" /D "_i386_" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "i_386_" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /Yu"stdafx.h" /Gs8192 /GF /c MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 commctrl.lib coredll.lib $(CEx86Corelibc) aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /debug /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86 # ADD LINK32 commctrl.lib coredll.lib $(CEx86Corelibc) aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /debug /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86 !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "ARMV4Rel" # PROP BASE Intermediate_Dir "ARMV4Rel" # PROP BASE CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}" # PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "ARMV4Rel" # PROP Intermediate_Dir "ARMV4Rel" # PROP CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}" # PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP Target_Dir "" RSC=rc.exe # ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "NDEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r # ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "NDEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r CPP=clarm.exe # ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /Yu"stdafx.h" /O2 /M$(CECrtMT) /c # ADD CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /Yu"stdafx.h" /O2 /M$(CECrtMT) /c MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 commctrl.lib coredll.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM # ADD LINK32 commctrl.lib coredll.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "ARMV4Dbg" # PROP BASE Intermediate_Dir "ARMV4Dbg" # PROP BASE CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}" # PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "ARMV4Dbg" # PROP Intermediate_Dir "ARMV4Dbg" # PROP CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}" # PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}" # PROP Target_Dir "" RSC=rc.exe # ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "DEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r # ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "DEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r CPP=clarm.exe # ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /Yu"stdafx.h" /M$(CECrtMTDebug) /c # ADD CPP /nologo /W3 /Zi /Od /D "DEBUG" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "UNICODE" /D "_UNICODE" /FR /Yu"stdafx.h" /M$(CECrtMTDebug) /c MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 commctrl.lib coredll.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM # ADD LINK32 commctrl.lib coredll.lib aygshell.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM !ENDIF # Begin Target # Name "HerecastTester - Win32 (WCE emulator) Release" # Name "HerecastTester - Win32 (WCE emulator) Debug" # Name "HerecastTester - Win32 (WCE ARMV4) Release" # Name "HerecastTester - Win32 (WCE ARMV4) Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\HerecastAPI.cpp !IF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Release" DEP_CPP_HEREC=\ ".\HerecastAPI.h"\ ".\StdAfx.h"\ !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Debug" DEP_CPP_HEREC=\ ".\HerecastAPI.h"\ ".\StdAfx.h"\ !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Release" DEP_CPP_HEREC=\ ".\HerecastAPI.h"\ ".\StdAfx.h"\ !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Debug" DEP_CPP_HEREC=\ ".\herecast.h"\ ".\HerecastAPI.h"\ ".\StdAfx.h"\ !ENDIF # End Source File # Begin Source File SOURCE=.\HerecastTester.cpp !IF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Release" DEP_CPP_HERECA=\ ".\StdAfx.h"\ !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Debug" DEP_CPP_HERECA=\ ".\StdAfx.h"\ !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Release" DEP_CPP_HERECA=\ ".\StdAfx.h"\ !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Debug" DEP_CPP_HERECA=\ ".\herecast.h"\ ".\HerecastAPI.h"\ ".\StdAfx.h"\ !ENDIF # End Source File # Begin Source File SOURCE=.\HerecastTester.rc !IF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Release" !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Debug" !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Release" !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Debug" !ENDIF # End Source File # Begin Source File SOURCE=.\StdAfx.cpp !IF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Release" DEP_CPP_STDAF=\ ".\StdAfx.h"\ # ADD CPP /Yc"stdafx.h" !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE emulator) Debug" DEP_CPP_STDAF=\ ".\StdAfx.h"\ # ADD CPP /Yc"stdafx.h" !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Release" DEP_CPP_STDAF=\ ".\StdAfx.h"\ # ADD CPP /Yc"stdafx.h" !ELSEIF "$(CFG)" == "HerecastTester - Win32 (WCE ARMV4) Debug" DEP_CPP_STDAF=\ ".\StdAfx.h"\ # ADD CPP /Yc"stdafx.h" !ENDIF # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\HerecastAPI.h # End Source File # Begin Source File SOURCE=.\newres.h # End Source File # Begin Source File SOURCE=.\resource.h # End Source File # Begin Source File SOURCE=.\StdAfx.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\ReadMe.txt # End Source File # End Target # End Project --- NEW FILE: newres.h --- #ifndef __NEWRES_H__ #define __NEWRES_H__ #if !defined(UNDER_CE) #define UNDER_CE _WIN32_WCE #endif #if defined(_WIN32_WCE) #if !defined(WCEOLE_ENABLE_DIALOGEX) #define DIALOGEX DIALOG DISCARDABLE #endif #include <commctrl.h> #define SHMENUBAR RCDATA #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300) #include <aygshell.h> #define AFXCE_IDR_SCRATCH_SHMENU 28700 #else #define I_IMAGENONE (-2) #define NOMENU 0xFFFF #define IDS_SHNEW 1 #define IDM_SHAREDNEW 10 #define IDM_SHAREDNEWDEFAULT 11 #endif // _WIN32_WCE_PSPC #define AFXCE_IDD_SAVEMODIFIEDDLG 28701 #endif // _WIN32_WCE #ifdef RC_INVOKED #ifndef _INC_WINDOWS #define _INC_WINDOWS #include "winuser.h" // extract from windows header #include "winver.h" #endif #endif #ifdef IDC_STATIC #undef IDC_STATIC #endif #define IDC_STATIC (-1) #endif //__NEWRES_H__ --- NEW FILE: resource.h --- //{{NO_DEPENDENCIES}} // Microsoft eMbedded Visual C++ generated include file. // Used by HERECASTTESTER.RC // --- NEW FILE: HerecastTester.cpp --- #include "stdafx.h" #include "HerecastAPI.h" // globals HerecastAPI g_herecast; // forward declarations INT InitilizeClasses(HINSTANCE hInstance); HWND CreateMyWindow(HINSTANCE hInstance); LRESULT CALLBACK WndProc(HWND hWnd, UINT uimessage, WPARAM wParam, LPARAM lParam) ; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { InitilizeClasses(hInstance); CreateMyWindow(hInstance); // Example of checking to see if Herecast is running if (!g_herecast.findHerecast()) { MessageBox(0, TEXT("Herecast is not running"), TEXT("Error"), 0); return 1; } // Example of getting an integer (City ID) int id = g_herecast.getCityID(); if (id) { WCHAR strResult[256]; wsprintf(strResult, L"City ID: %i", id); MessageBox(0, strResult, L"Get an ID", 0); } else { MessageBox(0, TEXT("City is unknown"), TEXT("Error"), 0); } // Example of getting a string (City) WCHAR *result = g_herecast.getCity(); if (result) { MessageBox(0, result, L"Get a String", 0); } else { MessageBox(0, TEXT("City is unknown"), TEXT("Error"), 0); } // Example of parsing a URL (could be any string, really) result = g_herecast.parseURL(L"building={building},bssid={bssid}"); if (result) { MessageBox(0, result, L"Parse a URL", 0); } else { MessageBox(0, TEXT("No answer from Herecast"), TEXT("Error"), 0); } return 0; } // These next functions set up our dummy window, which is necessary to receive // strings. INT InitilizeClasses(HINSTANCE hInstance) { WNDCLASS wc; memset(&wc, 0, sizeof(wc)); wc.style = 0; wc.lpfnWndProc = (WNDPROC) WndProc; wc.hInstance = hInstance; wc.hIcon = 0; wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.lpszClassName = TEXT("HerecastTester"); return RegisterClass(&wc); } HWND CreateMyWindow(HINSTANCE hInstance) { HWND hWnd = CreateWindow(TEXT("HerecastTester"), TEXT("HerecastTester"), 0, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, SW_HIDE); //this window is never actually shown UpdateWindow(hWnd); return hWnd; } LRESULT CALLBACK WndProc(HWND hWnd, UINT uimessage, WPARAM wParam, LPARAM lParam) { switch (uimessage) { case WM_CREATE: g_herecast.setMyHWND(hWnd); return 0; case WM_COPYDATA: return g_herecast.My_WM_COPYDATA(hWnd, uimessage, wParam, lParam); } return DefWindowProc(hWnd, uimessage, wParam, lParam) ; } --- NEW FILE: herecast.h --- /* API Version 1.0 Compatible with Herecast 1.06 and later Sample usage: void HerecastTest() { HWND hwnd = FindWindow(TEXT("Herecast"), NULL); if (!hwnd) { MessageBox(hwnd, TEXT("Herecast not running"), TEXT("Error"), 0); return; } WCHAR buf[HC_FIELDSIZE]; LRESULT result = SendMessage(hwnd, HC_GET_BSSID, buf, HC_FIELDSIZE); if (!result) { MessageBox(hwnd, TEXT("No answer from Herecast"), TEXT("Error"), 0); return; } MessageBox(hwnd, buf, TEXT("BSSID"), 0); } */ #ifndef __HERECAST_H #define __HERECAST_H #define HC_FIELDSIZE 32 // including null termination #define HC_PARSE_URL WM_APP+0 #define HC_GET_BSSID WM_APP+1 #define HC_GET_LOCATION WM_APP+2 #define HC_GET_FLOOR WM_APP+3 #define HC_GET_FLOOR2 WM_APP+4 #define HC_GET_BUILDING WM_APP+5 #define HC_GET_BUILDINGID WM_APP+6 #define HC_GET_STREETADDR WM_APP+7 #define HC_GET_AREA WM_APP+8 #define HC_GET_AREAID WM_APP+9 #define HC_GET_CITY WM_APP+10 #define HC_GET_CITYID WM_APP+11 #define HC_GET_PROVINCE WM_APP+12 #define HC_GET_PROVINCEID WM_APP+13 #define HC_GET_COUNTRY WM_APP+14 #define HC_GET_COUNTRYID WM_APP+15 #define HC_GET_NETWORK WM_APP+16 #define HC_GET_NETWORKID WM_APP+17 #endif --- NEW FILE: ReadMe.txt --- HerecastTester.cpp The main test program. It demonstrates how to access the Herecast API using the HerecastAPI interface object. HerecastAPI An interface that simplifies access to the Herecast API. You can either use this as is, or view the code to see how the API itself works. --- NEW FILE: HerecastAPI.cpp --- #include "stdafx.h" #include "HerecastAPI.h" HerecastAPI::HerecastAPI() { lastString = NULL; hwndHerecast = NULL; hwndSelf = NULL; } HerecastAPI::~HerecastAPI() { free(lastString); lastString = NULL; } LRESULT CALLBACK HerecastAPI::My_WM_COPYDATA(HWND hWnd, UINT uimessage, WPARAM wParam, LPARAM lParam) { COPYDATASTRUCT *pCD = (COPYDATASTRUCT*) lParam; free(lastString); lastString = _wcsdup((WCHAR*)pCD->lpData); return 1; } HWND HerecastAPI::findHerecast() { hwndHerecast = FindWindow(TEXT("Herecast"), NULL); return hwndHerecast; } unsigned long HerecastAPI::getInt(int msg) { findHerecast(); return SendMessage(hwndHerecast, msg, 0, 0); } WCHAR* HerecastAPI::getString(int msg) { findHerecast(); LRESULT result = SendMessage(hwndHerecast, msg, (WPARAM)hwndSelf, 0); return result ? lastString : NULL; } WCHAR* HerecastAPI::parseURL(WCHAR *url) { findHerecast(); COPYDATASTRUCT cd; cd.dwData = HC_PARSE_URL; cd.cbData = wcslen(url) * sizeof(WCHAR); cd.lpData = url; if (SendMessage(hwndHerecast, WM_COPYDATA, (WPARAM)hwndSelf, (LPARAM)&cd)) { return lastString; } return NULL; } --- NEW FILE: StdAfx.h --- // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #if !defined(AFX_STDAFX_H__DD5C74D5_65D8_4EAF_86B3_C0A648BF9C32__INCLUDED_) #define AFX_STDAFX_H__DD5C74D5_65D8_4EAF_86B3_C0A648BF9C32__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #if (_WIN32_WCE <= 211) #error This project can not be built for H/PC Pro 2.11 or earlier platforms. #endif #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> // Local Header Files // TODO: reference additional headers your program requires here //{{AFX_INSERT_LOCATION}} // Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__DD5C74D5_65D8_4EAF_86B3_C0A648BF9C32__INCLUDED_) --- NEW FILE: StdAfx.cpp --- // stdafx.cpp : source file that includes just the standard includes // HerecastTester.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file --- NEW FILE: HerecastTester.rc --- //Microsoft eMbedded Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "newres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""newres.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED --- NEW FILE: HerecastAPI.h --- #ifndef __HERECASTAPI_H #define __HERECASTAPI_H /* Here's all you need to do to use this interface: 1. Your main WndProc needs to forward WM_COPYDATA messages to this interface. You can do this like so: case WM_COPYDATA: return herecast.My_WM_COPYDATA(hWnd, msg, wParam, lParam); 2. You need to call setMyHWND(). One good place to do this would be in WM_CREATE of the same WndProc. 3. Call findHerecast(), the get* methods, or parseURL() as you wish. These are all pretty self-explanatory. See HerecastTester.cpp for examples. If all you want to use is findHerecast and the get*ID methods, you can actually skip steps 1 and 2. */ #include "herecast.h" class HerecastAPI { private: HWND hwndSelf; // HWND to our own window (needed for parseURL) HWND hwndHerecast; // HWND of the Herecast window WCHAR* lastString; // last string received via WM_COPYDATA unsigned long getInt(int msg); // get an integer from Herecast WCHAR* getString(int msg); // get a string from Herecast public: HerecastAPI(); ~HerecastAPI(); void setMyHWND(HWND hWnd) { hwndSelf = hWnd; } LRESULT CALLBACK My_WM_COPYDATA(HWND hWnd, UINT uimessage, WPARAM wParam, LPARAM lParam); // findHerecast returns NULL if Herecast isn't running HWND findHerecast(); // the get*ID methods return the unique ID associated with the current // building/area/etc. If the object is not in the database, or if // Herecast isn't running, 0 is returned. unsigned long getBuildingID() { return getInt(HC_GET_BUILDINGID); } unsigned long getAreaID() { return getInt(HC_GET_AREAID); } unsigned long getCityID() { return getInt(HC_GET_CITYID); } unsigned long getProvinceID() { return getInt(HC_GET_PROVINCEID); } unsigned long getCountryID() { return getInt(HC_GET_COUNTRYID); } unsigned long getNetworkID() { return getInt(HC_GET_NETWORKID); } // the remaining methods return the human-understandable names of the // current building/city/etc. NULL is returned if Herecast isn't // running or the location isn't in the database. WCHAR* getBssid() { return getString(HC_GET_BSSID); } WCHAR* getLocation() { return getString(HC_GET_LOCATION); } WCHAR* getFloor() { return getString(HC_GET_FLOOR); } // eg: 2 WCHAR* getFloor2() { return getString(HC_GET_FLOOR2); } // eg: 2nd floor WCHAR* getBuilding() { return getString(HC_GET_BUILDING); } WCHAR* getStreetaddr() { return getString(HC_GET_STREETADDR); } WCHAR* getCity() { return getString(HC_GET_CITY); } WCHAR* getArea() { return getString(HC_GET_AREA); } WCHAR* getProvince() { return getString(HC_GET_PROVINCE); } WCHAR* getCountry() { return getString(HC_GET_COUNTRY); } WCHAR* getNetwork() { return getString(HC_GET_NETWORK); } // parses a subscription URL (or any string) containing fields such as // {building}, {city}, etc. WCHAR* parseURL(WCHAR *url); }; #endif |