diff options
Diffstat (limited to 'gps+')
-rw-r--r-- | gps+/GPS+.vcproj | 247 | ||||
-rw-r--r-- | gps+/common.h | 51 | ||||
-rw-r--r-- | gps+/gps.cpp | 34 | ||||
-rw-r--r-- | gps+/gps.h | 31 | ||||
-rw-r--r-- | gps+/gps_class.cpp | 337 | ||||
-rw-r--r-- | gps+/gps_class.h | 90 | ||||
-rw-r--r-- | gps+/main.cpp | 88 | ||||
-rw-r--r-- | gps+/options.cpp | 151 | ||||
-rw-r--r-- | gps+/options.h | 29 | ||||
-rw-r--r-- | gps+/resource.h | 20 | ||||
-rw-r--r-- | gps+/resource.rc | 111 | ||||
-rw-r--r-- | gps+/services.cpp | 37 | ||||
-rw-r--r-- | gps+/services.h | 29 | ||||
-rw-r--r-- | gps+/version.h | 3 | ||||
-rw-r--r-- | gps+/version.rc | 43 |
15 files changed, 1301 insertions, 0 deletions
diff --git a/gps+/GPS+.vcproj b/gps+/GPS+.vcproj new file mode 100644 index 0000000..2977b34 --- /dev/null +++ b/gps+/GPS+.vcproj @@ -0,0 +1,247 @@ +<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="GPS+"
+ ProjectGUID="{DBE0F06C-207B-4F62-9A2B-6C32894ACC5A}"
+ RootNamespace="GPS"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GPS_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="\Coding\cplus\miranda_svn\miranda\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GPS_EXPORTS"
+ ExceptionHandling="1"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\gps.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\gps_class.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\options.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\services.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\common.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gps.h"
+ >
+ </File>
+ <File
+ RelativePath=".\gps_class.h"
+ >
+ </File>
+ <File
+ RelativePath=".\options.h"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\services.h"
+ >
+ </File>
+ <File
+ RelativePath=".\version.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\resource.rc"
+ >
+ </File>
+ <File
+ RelativePath=".\version.rc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/gps+/common.h b/gps+/common.h new file mode 100644 index 0000000..6438198 --- /dev/null +++ b/gps+/common.h @@ -0,0 +1,51 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#define MIRANDA_VER 0x0700
+
+#include <m_stdhdr.h>
+
+#include <windows.h>
+#include <stdio.h>
+#include <win2k.h>
+
+#include <newpluginapi.h>
+#include <m_plugins.h>
+#include <m_system.h>
+#include <m_database.h>
+#include <m_langpack.h>
+#include <m_utils.h>
+#include <m_options.h>
+#include <m_database.h>
+
+#include "version.h"
+#include "resource.h"
+#include "options.h"
+#include "gps_class.h"
+#include "gps.h"
+#include "services.h"
+
+#endif
\ No newline at end of file diff --git a/gps+/gps.cpp b/gps+/gps.cpp new file mode 100644 index 0000000..f5ae40d --- /dev/null +++ b/gps+/gps.cpp @@ -0,0 +1,34 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+GPSWorker gps;
+
+void InitGPS()
+{
+ gps.SetPort(DBGetContactSettingByte(NULL, "GPS+", "Port", 1));
+ gps.SetAutoDisconnect(DBGetContactSettingByte(NULL, "GPS+", "AutoDisconnect", 1) ? 5 : 0);
+ gps.SetCheckSum(DBGetContactSettingByte(NULL, "GPS+", "CheckSum", 1));
+ gps.Connect();
+}
\ No newline at end of file diff --git a/gps+/gps.h b/gps+/gps.h new file mode 100644 index 0000000..72f0401 --- /dev/null +++ b/gps+/gps.h @@ -0,0 +1,31 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef GPS_H
+#define GPS_H
+
+extern GPSWorker gps;
+void InitGPS();
+
+
+#endif
\ No newline at end of file diff --git a/gps+/gps_class.cpp b/gps+/gps_class.cpp new file mode 100644 index 0000000..9ab80a8 --- /dev/null +++ b/gps+/gps_class.cpp @@ -0,0 +1,337 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ Using of code in another IM projects forbidden without author write permission
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <windows.h>
+#include <stdio.h>
+
+#include "gps_class.h"
+
+GPSWorker::GPSWorker()
+{
+ InitializeCriticalSection(&csInfoAccess);
+
+ EnterCriticalSection(&csInfoAccess);
+ navInfo = new NavInfo;
+ gpsInfo = new GPSInfo;
+ LeaveCriticalSection(&csInfoAccess);
+
+ hPortReader = INVALID_HANDLE_VALUE;
+ hPort = INVALID_HANDLE_VALUE;
+}
+
+GPSWorker::~GPSWorker()
+{
+ if(hPortReader != INVALID_HANDLE_VALUE) Disconnect();
+
+ EnterCriticalSection(&csInfoAccess);
+ delete navInfo;
+ delete gpsInfo;
+ LeaveCriticalSection(&csInfoAccess);
+
+ DeleteCriticalSection(&csInfoAccess);
+}
+
+void GPSWorker::SetPort(int nPortN)
+{
+ if (nPortN > 0 && nPortN < 255)
+ {
+ char PortN[10];
+ iPortN = nPortN;
+
+ _ltoa(iPortN, PortN, 10);
+ strcpy(Port, "\\\\.\\COM");
+ strcat(Port, PortN);
+ }
+}
+
+int GPSWorker::GetPort()
+{
+ return iPortN;
+}
+
+void GPSWorker::GetPortStr(char * PortStr)
+{
+ strcpy(PortStr, Port);
+}
+
+void GPSWorker::GetNavInfo(NavInfo* retNavInfo)
+{
+ EnterCriticalSection(&csInfoAccess);
+ memcpy(retNavInfo, navInfo, sizeof(NavInfo));
+ LeaveCriticalSection(&csInfoAccess);
+}
+
+void GPSWorker::GetGPSInfo(GPSInfo* retGPSInfo)
+{
+ EnterCriticalSection(&csInfoAccess);
+ memcpy(retGPSInfo, gpsInfo, sizeof(GPSInfo));
+ LeaveCriticalSection(&csInfoAccess);
+}
+
+/*
+//Return tokens count
+int explode(char* sourceStr, char sep, char** tokens)
+{
+ int i;
+ char buf[255];
+ buf[0] = 0;
+ for(i = 0; i < strlen(sourceStr); i++){
+ if(sourceStr[i] != sep){
+
+ }
+ }
+}
+*/
+
+float GeoCoordToDegrees(float geoCoord)
+{
+ float minutes = geoCoord - (int)(geoCoord / 100) * 100;
+ return ((int)(geoCoord / 100)) + (minutes / 60);
+}
+
+int ParseTime(float time)
+{
+ int hours, minutes;
+ float seconds;
+
+ hours = (int)(time / 1000);
+ minutes = (int)(time / 100) - hours * 100;
+ seconds = time - hours * 1000 - minutes * 100;
+
+ return hours * 60 * 60 * 1000 + minutes * 60 * 1000 + (int)(seconds * 1000);
+}
+
+int CheckCRC(char* infoStr)
+{
+ int recvCheckSum = 0, calcCheckSum = 0;
+ char checkStr[255];
+
+ sscanf(infoStr, "$%[1234567890,.QWERTYUIOPASDFGHJKLZXCVBNM-+]*%x", checkStr, &recvCheckSum);
+
+ for(int i = 0; i < strlen(checkStr); i++)
+ {
+ calcCheckSum ^= checkStr[i];
+ }
+ return !(calcCheckSum - recvCheckSum);
+}
+
+void GPSWorker::ParseInfo(char* infoStr)
+{
+ if(infoStr[0] != '$')
+ {
+ WrongMessage++;
+ return;
+ }
+ if(CheckSum){
+ if(!CheckCRC(infoStr)) {
+ return;
+ }
+ }
+
+ if(WrongMessage == DisconnectOn){
+ Disconnect();
+ }
+
+ WrongMessage = 0;
+
+ if(strstr(infoStr, "$GPRMC")){
+ float time = 0;
+ char valid = 0;
+ float latitude = 0;
+ char NorthSouth = 0;
+ float longtitude = 0;
+ char EastWest = 0;
+ float sog = 0;
+ float direction = 0;
+ int date = 0;
+ float magneticDeclination = 0;
+ char magneticEastWest = 0;
+ int checkSum = 0;
+
+ sscanf(infoStr, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,%f,%d,%f,%c*%x",
+ &time,
+ &valid,
+ &latitude,
+ &NorthSouth,
+ &longtitude,
+ &EastWest,
+ &sog,
+ &direction,
+ &date,
+ &magneticDeclination,
+ &magneticEastWest,
+ &checkSum);
+ EnterCriticalSection(&csInfoAccess);
+
+ navInfo->Latitude = (NorthSouth == 'N' ? 1 : -1) * GeoCoordToDegrees(latitude);
+ navInfo->Longtitude = (EastWest == 'E' ? 1 : -1) * GeoCoordToDegrees(longtitude);
+ navInfo->SOG = sog;
+ navInfo->Time = ParseTime(time);
+ navInfo->Direction = direction;
+ navInfo->MagneticDeclination = (magneticEastWest == 'E' ? 1 : -1) * magneticDeclination;
+ LeaveCriticalSection(&csInfoAccess);
+ }
+ if(strstr(infoStr, "$GPGGA")){
+ float time = 0;
+ float latitude = 0;
+ char NorthSouth = 0;
+ float longtitude = 0;
+ char EastWest = 0;
+ int quality = 0;
+ int satCount = 0;
+ float hdop = 0;
+
+ float altitude = 0;
+ char altMarker = 0;
+ float geoDiff = 0;
+ char geoDiffMarker = 0;
+
+ float diffDataAge = 0;
+ int stantionId = 0;
+ int checkSum = 0;
+
+ sscanf(infoStr, "$GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f,%c,%f,%c,%d,%d*%x",
+ &time,
+ &latitude,
+ &NorthSouth,
+ &longtitude,
+ &EastWest,
+ &quality,
+ &satCount,
+ &hdop,
+ &altitude,
+ &altMarker,
+ &geoDiff,
+ &geoDiffMarker,
+ &diffDataAge,
+ &stantionId,
+ &checkSum);
+
+
+ EnterCriticalSection(&csInfoAccess);
+
+ navInfo->Altitude = altitude;
+ navInfo->Latitude = (NorthSouth == 'N' ? 1 : -1) * GeoCoordToDegrees(latitude);
+ navInfo->Longtitude = (EastWest == 'E' ? 1 : -1) * GeoCoordToDegrees(longtitude);
+ navInfo->Quality = quality;
+ gpsInfo->SatCount = satCount;
+ navInfo->GeoDiff = geoDiff;
+ gpsInfo->HDOP = hdop;
+ navInfo->Time = ParseTime(time);
+
+ LeaveCriticalSection(&csInfoAccess);
+ }
+}
+
+DWORD __stdcall GPSWorker::PortReader(GPSWorker* th)
+{
+ char cBuf[2];
+ char infoStr[1024];
+ DWORD dwBytesRead;
+
+ while(1){
+ ReadFile(th->hPort, &cBuf, 1, &dwBytesRead, NULL);
+ cBuf[1] = 0;
+ if(dwBytesRead > 0){
+ strcat(infoStr, cBuf);
+ if(cBuf[0] == '\n'){
+ th->ParseInfo(infoStr);
+ infoStr[0] = 0;
+ }
+ }
+ }
+}
+
+int GPSWorker::Connect()
+{
+ if(hPortReader != INVALID_HANDLE_VALUE)
+ return 2;
+
+ WrongMessage = 0;
+
+ hPort = CreateFile(Port, GENERIC_READ | GENERIC_WRITE,
+ 0, NULL, OPEN_EXISTING, 0, NULL);
+
+ if (hPort == INVALID_HANDLE_VALUE)
+ return -1;
+
+ else
+ {
+ hPortReader = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&GPSWorker::PortReader,
+ (LPVOID)this, 0, 0);
+
+ DCB dcb;
+ GetCommState(hPort, &dcb);
+ dcb.BaudRate = CBR_4800;
+ dcb.ByteSize = 8;
+ dcb.Parity = NOPARITY;
+ dcb.StopBits = ONESTOPBIT;
+ if (!SetCommState(hPort, &dcb)){
+ TerminateThread(hPortReader, 0);
+ CloseHandle(hPort);
+
+ hPortReader = INVALID_HANDLE_VALUE;
+ hPort = INVALID_HANDLE_VALUE;
+
+ return -2;
+ }
+ }
+
+ return 1;
+}
+
+void GPSWorker::Disconnect()
+{
+ if(hPortReader != INVALID_HANDLE_VALUE){
+ EnterCriticalSection(&csInfoAccess);
+ TerminateThread(hPortReader, 0);
+ CloseHandle(hPort);
+ LeaveCriticalSection(&csInfoAccess);
+
+ hPortReader = INVALID_HANDLE_VALUE;
+ hPort = INVALID_HANDLE_VALUE;
+ }
+}
+
+int GPSWorker::ReConnect()
+{
+ Disconnect();
+ return Connect();
+}
+
+int GPSWorker::IsConnected()
+{
+ return hPortReader != INVALID_HANDLE_VALUE;
+}
+
+void GPSWorker::SetAutoDisconnect(int newDisconnOn)
+{
+ DisconnectOn = newDisconnOn;
+}
+
+void GPSWorker::SetCheckSum(int newCheck)
+{
+ CheckSum = newCheck;
+}
\ No newline at end of file diff --git a/gps+/gps_class.h b/gps+/gps_class.h new file mode 100644 index 0000000..ad03bdc --- /dev/null +++ b/gps+/gps_class.h @@ -0,0 +1,90 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef GPS_CLASS_H
+#define GPS_CLASS_H
+
+typedef struct {
+ float Latitude, Longtitude;
+
+ float Altitude;
+
+ float Speed, SOG;
+ float Direction;
+ float MagneticDeclination;
+
+ int Quality;
+
+ float GeoDiff;
+
+ int Time;
+} NavInfo;
+
+typedef struct {
+ float HDOP, PDOP, VDOP;
+ int Mode;
+ int SatCount;
+} GPSInfo;
+
+class GPSWorker
+{
+public:
+ GPSWorker();
+ ~GPSWorker();
+
+ int Connect();
+ int ReConnect();
+ void Disconnect();
+
+ //Thread-safe
+ void GetNavInfo(NavInfo* retNavInfo);
+ void GetGPSInfo(GPSInfo* retGPSInfo);
+
+ void SetPort(int nPortN);
+ int GetPort();
+ void GetPortStr(char* PortStr);
+
+ int IsConnected();
+
+ void SetCheckSum(int newCheck);
+ void SetAutoDisconnect(int newDisconnOn);
+private:
+ HANDLE hPort;
+ HANDLE hPortReader;
+
+ int iPortN;
+ char Port[10];
+
+ int DisconnectOn, CheckSum, WrongMessage;
+
+ NavInfo* navInfo;
+ GPSInfo* gpsInfo;
+
+ CRITICAL_SECTION csInfoAccess;
+
+ void ParseInfo(char* infoStr);
+
+ static DWORD __stdcall PortReader(GPSWorker* th);
+};
+
+#endif
\ No newline at end of file diff --git a/gps+/main.cpp b/gps+/main.cpp new file mode 100644 index 0000000..2f32480 --- /dev/null +++ b/gps+/main.cpp @@ -0,0 +1,88 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+struct MM_INTERFACE mmi;
+
+HINSTANCE hInst;
+PLUGINLINK *pluginLink;
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ "GPS+",
+ __VERSION_DWORD,
+ "Provides GPS position information from receiver and statuses support",
+ "persei",
+ "persei@miranda.im",
+ "© 2005-2008 persei",
+ "http://persei.miranda.im/",
+ UNICODE_AWARE,
+ 0, //doesn't replace anything built-in
+ // {E500A600-7046-4100-98F1-BEC395D555FB}
+ { 0xe500a600, 0x7046, 0x4100, { 0x98, 0xf1, 0xbe, 0xc3, 0x95, 0xd5, 0x55, 0xfb } }
+
+};
+// {563BC9A2-5264-409f-B890-155D07F905A7}
+#define MIID_NAV_INFO { 0x563bc9a2, 0x5264, 0x409f, { 0xb8, 0x90, 0x15, 0x5d, 0x7, 0xf9, 0x5, 0xa7 } }
+
+// {70F2DF68-317A-463d-8A2F-16205D7C73C6}
+#define MIID_GPS_INFO { 0x70f2df68, 0x317a, 0x463d, { 0x8a, 0x2f, 0x16, 0x20, 0x5d, 0x7c, 0x73, 0xc6 } }
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+static const MUUID interfaces[] = {MIID_NAV_INFO, MIID_GPS_INFO, MIID_LAST};
+
+extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ return interfaces;
+}
+
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+ pluginLink = link;
+ mir_getMMI( &mmi );
+
+ InitOptions();
+ InitGPS();
+ InitServices();
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ gps.Disconnect();
+ return 0;
+}
\ No newline at end of file diff --git a/gps+/options.cpp b/gps+/options.cpp new file mode 100644 index 0000000..c152fdd --- /dev/null +++ b/gps+/options.cpp @@ -0,0 +1,151 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+extern HINSTANCE hInst;
+
+BOOL CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ {
+ DWORD Ports_MemSize = 0;
+ DWORD Ports_Count = 0;
+ BYTE* lpPorts = NULL;
+
+ //Getting Ports_MemSize value...
+ EnumPorts(NULL,
+ 1,
+ lpPorts,
+ 0,
+ &Ports_MemSize,
+ &Ports_Count);
+
+
+ //Getting lpPorts...
+ lpPorts = new BYTE[Ports_MemSize];
+ EnumPorts(NULL,
+ 1,
+ lpPorts,
+ Ports_MemSize,
+ &Ports_MemSize,
+ &Ports_Count);
+
+ PORT_INFO_1 *pPortInfo;
+ pPortInfo = (PORT_INFO_1 *)lpPorts - 1;
+
+ for(int i = 0; i < Ports_Count; i++)
+ {
+ pPortInfo++;
+ if(!strstr(pPortInfo->pName, "COM")) continue;
+
+ pPortInfo->pName[strlen(pPortInfo->pName) - 1] = 0;
+
+ char COM_string[255];
+
+ sprintf_s(COM_string, 255, "\\\\.\\%s", pPortInfo->pName);
+
+ HANDLE h = CreateFile(COM_string, GENERIC_READ|GENERIC_WRITE, 0, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL);
+
+ if(h != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(h);
+ SendDlgItemMessage(hwndDlg, IDC_COMPORT, CB_ADDSTRING, 0, (LPARAM)pPortInfo->pName);
+ }
+ }
+
+
+ WORD wPort = DBGetContactSettingWord(NULL, "GPS+", "Port", 999);
+ if(wPort != 999){
+ char ComPort[255];
+ sprintf_s(ComPort, 255, "COM%d", wPort);
+ SetDlgItemText(hwndDlg, IDC_COMPORT, ComPort);
+ }
+
+ CheckDlgButton(hwndDlg, IDC_AUTODISCONNECT, DBGetContactSettingByte(NULL, "GPS+", "AutoDisconnect", 1));
+ CheckDlgButton(hwndDlg, IDC_CHECKSUM, DBGetContactSettingByte(NULL, "GPS+", "CheckSum", 1));
+
+ TranslateDialogDefault( hwndDlg );
+ return TRUE;
+ }
+ case WM_COMMAND:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ WORD wPort = 0;
+ char ComPort[255];
+ GetDlgItemText(hwndDlg, IDC_COMPORT, ComPort, 255);
+ sscanf(ComPort, "COM%d", &wPort);
+ if(wPort == 0){
+ MessageBox(0, Translate("Wrong port specified"), Translate("Error"), MB_OK);
+ }
+ else
+ {
+ gps.SetPort(wPort);
+ if(gps.ReConnect())
+ {
+ DBWriteContactSettingWord(NULL, "GPS+", "Port", wPort);
+ }
+ else
+ {
+ MessageBox(0, Translate("Unnable connect to specified port"), Translate("Error"), MB_OK);
+ }
+
+ }
+ DBWriteContactSettingByte(NULL, "GPS+", "CheckSum", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHECKSUM));
+ DBWriteContactSettingByte(NULL, "GPS+", "AutoDisconnect", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTODISCONNECT));
+ gps.SetAutoDisconnect(DBGetContactSettingByte(NULL, "GPS+", "AutoDisconnect", 1) ? 5 : 0);
+ gps.SetCheckSum(DBGetContactSettingByte(NULL, "GPS+", "CheckSum", 1));
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int OptionsInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp;
+
+ odp.cbSize = 60;
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pszTitle = Translate("GPS+");
+ odp.pszGroup = Translate("Services");
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOptions;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+
+
+void InitOptions()
+{
+ HookEvent(ME_OPT_INITIALISE, OptionsInit);
+}
\ No newline at end of file diff --git a/gps+/options.h b/gps+/options.h new file mode 100644 index 0000000..0ceec41 --- /dev/null +++ b/gps+/options.h @@ -0,0 +1,29 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef OPTIONS_H
+#define OPTIONS_H
+
+void InitOptions();
+
+#endif
\ No newline at end of file diff --git a/gps+/resource.h b/gps+/resource.h new file mode 100644 index 0000000..83e79ad --- /dev/null +++ b/gps+/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDD_OPTIONS 102
+#define IDC_COMPORT 1001
+#define IDC_CHECKSUM 1004
+#define IDC_CHECK2 1005
+#define IDC_AUTODISCONNECT 1005
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 103
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1006
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/gps+/resource.rc b/gps+/resource.rc new file mode 100644 index 0000000..e8ed9f6 --- /dev/null +++ b/gps+/resource.rc @@ -0,0 +1,111 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+#ifdef _WIN32
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPTIONS DIALOGEX 0, 0, 257, 182
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x0
+BEGIN
+ LTEXT "GPS receiver COM port",IDC_STATIC,59,70,74,8
+ COMBOBOX IDC_COMPORT,137,68,42,86,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Check control sum",IDC_CHECKSUM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,59,83,131,10
+ CONTROL "Disconnect after 5 non-GPS messages on port",IDC_AUTODISCONNECT,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,59,95,132,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPTIONS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 250
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 175
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/gps+/services.cpp b/gps+/services.cpp new file mode 100644 index 0000000..26571cf --- /dev/null +++ b/gps+/services.cpp @@ -0,0 +1,37 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+extern GPSWorker gps;
+
+int GetLocationInfo(WPARAM wParam, LPARAM lParam)
+{
+ gps.GetNavInfo((NavInfo*) wParam);
+ return gps.IsConnected();
+}
+
+void InitServices()
+{
+ CreateServiceFunction("Nav/GetLocationInfo", GetLocationInfo);
+}
\ No newline at end of file diff --git a/gps+/services.h b/gps+/services.h new file mode 100644 index 0000000..187b975 --- /dev/null +++ b/gps+/services.h @@ -0,0 +1,29 @@ +/*
+ GPS+: Service plugin for Miranda IM
+ Copyright 2007-2008 persei
+
+ persei@miranda.im
+ http://persei.miranda.im
+ http://svn.miranda.im/mainrepo/gps+
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef SERVICES_H
+#define SERVICES_H
+
+void InitServices();
+
+#endif
\ No newline at end of file diff --git a/gps+/version.h b/gps+/version.h new file mode 100644 index 0000000..88e1e08 --- /dev/null +++ b/gps+/version.h @@ -0,0 +1,3 @@ +#define __FILEVERSION_STRING 0,0,0,1
+#define __VERSION_STRING "0.0.0.1"
+#define __VERSION_DWORD 0x00000001
diff --git a/gps+/version.rc b/gps+/version.rc new file mode 100644 index 0000000..098e427 --- /dev/null +++ b/gps+/version.rc @@ -0,0 +1,43 @@ +
+#include <windows.h>
+#include "version.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "041904b0"
+ BEGIN
+ #if defined(UNICODE)
+ VALUE "FileDescription", "GPS+ (Unicode)"
+ #else
+ VALUE "FileDescription", "GPS+"
+ #endif
+ VALUE "FileVersion", __VERSION_STRING
+ VALUE "LegalCopyright", "Copyright © 2008 persei"
+ VALUE "OriginalFilename", "gps+.dll"
+ VALUE "ProductName", "GPS+"
+ VALUE "ProductVersion", __VERSION_STRING
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x419, 1200
+ END
+END
|