License.h

Go to the documentation of this file.
00001 #ifndef __LICENSE_H__
00002 #define __LICENSE_H__
00003 
00004 /*
00005 
00006 $Header$
00007 
00008 */
00009 
00010 #include <time.h>
00011 
00012 #include "Object.h"
00013 #include "Singleton.h"
00014 
00015 // Messages.
00016 static const char *const MSG_LICENSE_INVALID = "Invalid license.";
00017 
00018 static const char *const LICENSE_IF_NAME   = "eth0";
00019 static const char *const LICENSE_FILE_PATH = "/tmp/license.dat";
00020 
00021 static const unsigned int LICENSE_MAC_ADDRESS_SIZE = 6;
00022 static const unsigned int LICENSE_LIMIT_SIZE = 256;
00023 
00024 static const unsigned int LICENSE_MAGIC_TIME = 1111111111;
00025 static const char LICENSE_MAGIC_MAC[] = { 0x00, 0x0F, 0x44, 0x00, 0x00, 0x01 };
00026 
00027 static const char *const LICENSE_MSG =
00028 "\n\
00029  #######################################################################\n\
00030  # Your license is not valid or expired. Please contact UniPhone, Inc. #\n\
00031  #######################################################################\n\
00032 \n";
00033 
00034 static const unsigned int LICENSE_MSG_DELAY = 2;
00035 
00036 using namespace std;
00037 
00038 class License;
00039 
00040 License *LICENSE();
00041 
00042 class License : public Object,
00043                 public Singleton<License>
00044 {
00045 
00046 friend class Singleton<License>;
00047 
00048   PYLON_OBJECT
00049 
00050 public:
00051 
00052   int check(const String &license);
00053   int check();
00054   int checkWithMsg();
00055 
00056   String mac() const;
00057   time_t expirationTime() const;
00058 
00059   int generate(const String &mac, const time_t expirationTime, String &license);
00060 
00061 private:
00062 
00063   License();
00064   virtual ~License();
00065 
00066   int mac(String &mac);
00067   int encode(char *encodedData, const char *data, const unsigned int size);
00068   int decode(char *dencodedData, const char *data, const unsigned int size);
00069   unsigned char crc(const char *data, const unsigned int size);
00070 
00071 #ifdef DEBUG_MODE
00072   int test();
00073 #endif
00074 
00075   time_t _expirationTime;
00076   String _mac;
00077 };
00078 
00079 #endif

Generated on Thu Sep 6 20:11:25 2007 for Pylon Application Platform by  doxygen 1.5.1