home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / happydays-src-1.37.tar.gz / happydays-src-1.37.tar / happydays-1.37 / address.h < prev    next >
C/C++ Source or Header  |  2000-04-01  |  8KB  |  223 lines

  1. /*
  2. HappyDays - A Birthdate displayer for the PalmPilot
  3. Copyright (C) 1999-2000 JaeMok Jeong
  4.  
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. */
  19.  
  20. #ifndef __ADDRESS_H__
  21. #define __ADDRESS_H__
  22.  
  23. #include "birthdate.h"
  24.  
  25. #define shortenedFieldString              "\205"
  26. #define shortenedFieldLength              1
  27. #define fieldSeparatorString              ", "
  28. #define fieldSeparatorLength              2
  29. #define spaceBetweenNamesAndPhoneNumbers  4
  30. #define addrLabelLength                   16
  31. #define addrNumFields                     19
  32. #define PhoneColumnWidth                  90
  33.  
  34. typedef union {
  35.     struct {
  36.         unsigned reserved    :13;
  37.         unsigned note        :1;    /* set if record contains a note handle */
  38.         unsigned custom4     :1;    /* set if record contains a custom4 */
  39.         unsigned custom3     :1;    /* set if record contains a custom3 */
  40.         unsigned custom2     :1;    /* set if record contains a custom2 */
  41.         unsigned custom1     :1;    /* set if record contains a custom1 */
  42.         unsigned title       :1;    /* set if record contains a title */
  43.         unsigned country     :1;    /* set if record contains a birthday */
  44.         unsigned zipCode     :1;    /* set if record contains a birthday */
  45.         unsigned state       :1;    /* set if record contains a birthday */
  46.         unsigned city        :1;    /* set if record contains a birthday */
  47.         unsigned address     :1;    /* set if record contains a address */
  48.         unsigned phone5      :1;    /* set if record contains a phone5 */
  49.         unsigned phone4      :1;    /* set if record contains a phone4 */
  50.         unsigned phone3      :1;    /* set if record contains a phone3 */
  51.         unsigned phone2      :1;    /* set if record contains a phone2 */
  52.         unsigned phone1      :1;    /* set if record contains a phone1 */
  53.         unsigned company     :1;    /* set if record contains a company */
  54.         unsigned firstName   :1;    /* set if record contains a firstName */
  55.         unsigned name        :1;    /* set if record contains a name (bit 0) */
  56.     } bits;
  57.     UInt32 allBits;
  58. } AddrDBRecordFlags;
  59.  
  60. typedef struct {
  61.     unsigned reserved       :7;
  62.     unsigned sortByCompany  :1;
  63. } AddrDBMisc;
  64.  
  65. typedef enum {
  66.     name,
  67.     firstName,
  68.     company,
  69.     phone1,
  70.     phone2,
  71.     phone3,
  72.     phone4,
  73.     phone5,
  74.     address,
  75.     city,
  76.     state,
  77.     zipCode,
  78.     country,
  79.     title,
  80.     custom1,
  81.     custom2,
  82.     custom3,
  83.     custom4,
  84.     note,            /* This field is assumed to be < 4K */
  85.     addressFieldsCount
  86. } AddressFields;
  87.  
  88. typedef enum {
  89.     workLabel,
  90.     homeLabel,
  91.     faxLabel,
  92.     otherLabel,
  93.     emailLabel,
  94.     mainLabel,
  95.     pagerLabel,
  96.     mobileLabel
  97. } AddressPhoneLabels;
  98.  
  99. #define firstAddressField name
  100. #define firstPhoneField phone1
  101. #define lastPhoneField phone5
  102. #define numPhoneLabels 8
  103. #define numPhoneFields (lastPhoneField - firstPhoneField + 1)
  104. #define numPhoneLabelsStoredFirst numPhoneFields
  105. #define numPhoneLabelsStoredSecond (numPhoneLabels - numPhoneLabelsStoredFirst)
  106. #define firstRenameableLabel custom1
  107. #define lastRenameableLabel custom4
  108. #define lastLabel (addressFieldsCount + numPhoneLabelsStoredSecond)
  109.  
  110. typedef union {
  111.     struct {
  112.         unsigned reserved:8;
  113.         /* The phone displayed for the list view 0 - 4 */
  114.         unsigned displayPhoneForList:4;
  115.         /* Which phone (home, work, car, ...) */
  116.         unsigned phone5:4;
  117.         unsigned phone4:4;
  118.         unsigned phone3:4;
  119.         unsigned phone2:4;
  120.         unsigned phone1:4;
  121.     } phones;
  122.     UInt32 phoneBits;
  123. } AddrOptionsType;
  124.  
  125. /*
  126.  * AddrDBRecord.
  127.  *
  128.  * This is the unpacked record form as used by the app.  Pointers are 
  129.  * either NULL or point to strings elsewhere on the card.  All strings 
  130.  * are null character terminated.
  131.  */
  132. typedef struct {
  133.     AddrOptionsType options; /* Display by company or by name */
  134.     Char * fields[addressFieldsCount];
  135. } AddrDBRecordType;
  136.  
  137. typedef AddrDBRecordType * AddrDBRecordPtr;
  138.  
  139. /*
  140.  * The following structure doesn't really exist.  The first field
  141.  * varies depending on the data present.  However, it is convient
  142.  * (and less error prone) to use when accessing the other information.
  143.  */
  144. typedef struct {
  145.     AddrOptionsType options; /* Display by company or by name */
  146.     AddrDBRecordFlags flags;
  147.     unsigned char companyFieldOffset; /* Offset from firstField */
  148.     char firstField;
  149. } AddrPackedDBRecord;
  150.  
  151. typedef union {
  152.     struct {
  153.         unsigned reserved    :10;
  154.         unsigned phone8      :1;    /* set if phone8 label is dirty */
  155.         unsigned phone7      :1;    /* set if phone7 label is dirty */
  156.         unsigned phone6      :1;    /* set if phone6 label is dirty */
  157.         unsigned note        :1;    /* set if note label is dirty */
  158.         unsigned custom4     :1;    /* set if custom4 label is dirty */
  159.         unsigned custom3     :1;    /* set if custom3 label is dirty */
  160.         unsigned custom2     :1;    /* set if custom2 label is dirty */
  161.         unsigned custom1     :1;    /* set if custom1 label is dirty */
  162.         unsigned title       :1;    /* set if title label is dirty */
  163.         unsigned country     :1;    /* set if country label is dirty */
  164.         unsigned zipCode     :1;    /* set if zipCode label is dirty */
  165.         unsigned state         :1;  /* set if state label is dirty */
  166.         unsigned city         :1;   /* set if city label is dirty */
  167.         unsigned address     :1;    /* set if address label is dirty */
  168.         unsigned phone5      :1;    /* set if phone5 label is dirty */
  169.         unsigned phone4      :1;    /* set if phone4 label is dirty */
  170.         unsigned phone3      :1;    /* set if phone3 label is dirty */
  171.         unsigned phone2      :1;    /* set if phone2 label is dirty */
  172.         unsigned phone1      :1;    /* set if phone1 label is dirty */
  173.         unsigned company     :1;    /* set if company label is dirty */
  174.         unsigned firstName   :1;    /* set if firstName label is dirty */
  175.         unsigned name        :1;    /* set if name label is dirty (bit 0) */
  176.     } bits;
  177.     UInt32 allBits;
  178. } AddrDBFieldLabelsDirtyFlags;
  179.  
  180. /*
  181.  * The labels for phone fields are stored specially.  Each phone field
  182.  * can use one of eight labels.  Part of those eight labels are stored
  183.  * where the phone field labels are.  The remainder (phoneLabelsStoredAtEnd)
  184.  * are stored after the labels for all the fields.
  185.  */
  186.  
  187. typedef char addressLabel[addrLabelLength];
  188.  
  189. typedef struct {
  190.     UInt16 renamedCategories;    /* bitfield of categories with a different name */
  191.     char categoryLabels[dmRecNumCategories][dmCategoryLength];
  192.     UInt8 categoryUniqIDs[dmRecNumCategories];
  193.     UInt8 lastUniqID; /* Uniq IDs generated by the device are between */
  194.                      /* 0 - 127.  Those from the PC are 128 - 255. */
  195.     UInt8 reserved1; /* from the compiler word aligning things */
  196.     UInt16 reserved2;
  197.     AddrDBFieldLabelsDirtyFlags dirtyFieldLabels;
  198.     addressLabel fieldLabels[addrNumFields + numPhoneLabelsStoredSecond];
  199.     CountryType country; /* Country the database (labels) is formatted for */
  200.     AddrDBMisc misc;
  201. } AddrAppInfoType;
  202.  
  203. typedef AddrAppInfoType * AddrAppInfoPtr;
  204.  
  205. #define GetPhoneLabel(r, p) (((r)->options.phoneBits >> (((p) - firstPhoneField) << 2)) & 0xF)
  206.  
  207. /*
  208.  * Function prototypes
  209.  */
  210. extern void AddrUnpack(AddrPackedDBRecord *src, AddrDBRecordPtr dest);
  211. extern Int16 GotoAddress(Int16 index);
  212. extern Boolean DetermineRecordName(AddrDBRecordPtr recordP, 
  213.                            Boolean sortByCompany,
  214.                            Char **name1,
  215.                            Char **name2);
  216. extern void DrawRecordName(char* name1, char* name2,
  217.                            UInt16 nameExtent, Int16 *x, Int16 y,
  218.                            Boolean center, Boolean priorityIsName1);
  219.  
  220. extern char *UnnamedRecordStringPtr;
  221.  
  222. #endif __ADDRESS_H__
  223.