home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / DB / AddressAppInfo.cc next >
C/C++ Source or Header  |  2000-06-10  |  1KB  |  74 lines

  1. //
  2. //  $Id: AddressAppInfo.cc,v 1.1 2000/06/10 00:19:56 sergey Exp $
  3. //
  4.  
  5. #include <Pilot.h>
  6. #include "AddressAppInfo.h"
  7. #include "Util/Assert.h"
  8.  
  9.  
  10. namespace DB
  11. {
  12.     // constants
  13.  
  14.     // From palm-link package:
  15.  
  16.     const int BASE_APP_INFO_SIZE        = 278;
  17.     const int LABEL_COUNT               = 22;
  18.  
  19.     // construction
  20.  
  21.     AddressAppInfo::AddressAppInfo()
  22.     {
  23.         clearData();
  24.     }
  25.  
  26.     AddressAppInfo::~AddressAppInfo()
  27.     {}
  28.  
  29.     // operations
  30.  
  31.     bool AddressAppInfo::restore(const void* buffer)
  32.     {
  33.         clearData();
  34.  
  35.         if (buffer != 0)
  36.         {
  37.             unsigned char* ptr = (unsigned char*)buffer+BASE_APP_INFO_SIZE;
  38.  
  39.             char labels[LABEL_COUNT][LABEL_SIZE];
  40.             MemMove(labels, ptr+4, sizeof(labels));
  41.  
  42.             int i;
  43.             for (i = 3; i < 8; i++)
  44.                 StrCopy(_phoneLabels[i-3], labels[i]);
  45.  
  46.             for (i = 19; i < 22; i++)
  47.                 StrCopy(_phoneLabels[i-14], labels[i]);
  48.  
  49.             return true;
  50.         }
  51.  
  52.         return false;
  53.     }
  54.  
  55.     // attributes
  56.  
  57.     const char* AddressAppInfo::phoneLabel(int index) const
  58.     {
  59.         if (0 <= index && index < PHONE_LABEL_COUNT)
  60.             return _phoneLabels[index];
  61.  
  62.         assert(false);
  63.         return "";
  64.     }
  65.  
  66.     // implementation
  67.  
  68.     void AddressAppInfo::clearData()
  69.     {
  70.         MemSet(_phoneLabels, sizeof(_phoneLabels), 0);
  71.     }
  72. }
  73. // namespace DB
  74.