kpilot/lib

pilotSysInfo.h

00001 #ifndef _KPILOT_SYSINFO_H
00002 #define _KPILOT_SYSINFO_H
00003 /* sysInfo.h            KPilot
00004 **
00005 ** Copyright (C) 2003 by Reinhold Kainhofer
00006 **
00007 ** Wrapper for pilot-link's SysInfo Structure
00008 */
00009 
00010 /*
00011 ** This program is free software; you can redistribute it and/or modify
00012 ** it under the terms of the GNU Lesser General Public License as published by
00013 ** the Free Software Foundation; either version 2.1 of the License, or
00014 ** (at your option) any later version.
00015 **
00016 ** This program is distributed in the hope that it will be useful,
00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 ** GNU Lesser General Public License for more details.
00020 **
00021 ** You should have received a copy of the GNU Lesser General Public License
00022 ** along with this program in a file called COPYING; if not, write to
00023 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 ** MA 02110-1301, USA.
00025 */
00026 
00027 /*
00028 ** Bug reports and questions can be sent to kde-pim@kde.org
00029 */
00030 
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <time.h>
00034 
00035 #include <pi-version.h>
00036 #include <pi-dlp.h>
00037 
00038 
00039 
00040 class KPilotSysInfo
00041 {
00042 public:
00043     KPilotSysInfo() { ::memset(&fSysInfo,0,sizeof(struct SysInfo)); }
00044     KPilotSysInfo(const SysInfo* sys_info) { fSysInfo = *sys_info; }
00045 
00046     SysInfo *sysInfo() { return &fSysInfo; }
00047 
00052     void boundsCheck()
00053     {
00054     }
00055 
00056     const unsigned long getRomVersion() const {return fSysInfo.romVersion;}
00057     void setRomVersion(unsigned long newval)  {fSysInfo.romVersion=newval;}
00058 
00059     const unsigned long getLocale() const {return fSysInfo.locale;}
00060     void setLocale(unsigned long newval)  {fSysInfo.locale=newval;}
00061 
00062 #if ( PILOT_LINK_VERSION < 1 ) && ( PILOT_LINK_MAJOR < 11 )
00063 // Older pilot-link versions < 0.11.x don't have prodID, but name instead,
00064 // and they also do not have the *Version members.
00065     const int getProductIDLength() const { return fSysInfo.nameLength; }
00066     const char* getProductID()
00067     {
00068         fSysInfo.name[fSysInfo.nameLength]='\0';
00069         return fSysInfo.name;
00070     }
00071     void setProductID(char* prodid)
00072     {
00073         strlcpy(fSysInfo.name, prodid, sizeof(fSysInfo.name));
00074         boundsCheck();
00075         fSysInfo.nameLength = strlen(fSysInfo.name);
00076     }
00077 
00078     const unsigned short getMajorVersion() const {return 0;}
00079     const unsigned short getMinorVersion() const {return 0;}
00080     const unsigned short getCompatMajorVersion() const {return 0;}
00081     const unsigned short getCompatMinorVersion() const {return 0;}
00082     const unsigned short getMaxRecSize() const {return 0;}
00083 #else
00084 // Newer pilot-link versions have these fields, so use them:
00085     const int getProductIDLength() const { return fSysInfo.prodIDLength; }
00086     const char* getProductID()
00087     {
00088         fSysInfo.prodID[fSysInfo.prodIDLength]='\0';
00089         return fSysInfo.prodID;
00090     }
00091     void setProductID(char* prodid)
00092     {
00093         strlcpy(fSysInfo.prodID, prodid, sizeof(fSysInfo.prodID));
00094         boundsCheck();
00095         fSysInfo.prodIDLength = strlen(fSysInfo.prodID);
00096     }
00097 
00098     const unsigned short getMajorVersion() const {return fSysInfo.dlpMajorVersion;}
00099     const unsigned short getMinorVersion() const {return fSysInfo.dlpMinorVersion;}
00100     const unsigned short getCompatMajorVersion() const {return fSysInfo.compatMajorVersion;}
00101     const unsigned short getCompatMinorVersion() const {return fSysInfo.compatMinorVersion;}
00102     const unsigned short getMaxRecSize() const {return fSysInfo.maxRecSize;}
00103 #endif
00104 
00105 private:
00106     struct SysInfo fSysInfo;
00107 };
00108 
00109 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys