home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / IrDA / IrIAS.h < prev    next >
C/C++ Source or Header  |  2000-06-05  |  3KB  |  130 lines

  1. //
  2. // $Id: IrIAS.h,v 1.2 2000/06/04 23:23:40 sergey Exp $
  3. //
  4.  
  5. #ifndef _IrIAS_h_
  6. #define _IrIAS_h_
  7.  
  8. #include "IrConstants.h"
  9.  
  10.  
  11. namespace IrDA
  12. {
  13.     class IasParameter;
  14.  
  15.  
  16.     //==============================================================================
  17.     // IasQueryBuffer class
  18.     //==============================================================================
  19.  
  20.     class IasQueryBuffer
  21.     {
  22.     public:
  23.         IasQueryBuffer();
  24.         IasQueryBuffer(const IasQueryBuffer& other);
  25.         IasQueryBuffer& operator =(const IasQueryBuffer& other);
  26.  
  27.     // operation
  28.  
  29.         void init(const char* className, const char* attributeName);
  30.         void reset() { _size = 0; }
  31.         IasQueryBuffer& append(const char* piece);
  32.  
  33.     // attributes
  34.  
  35.         const Byte* data() const { return _buffer; }
  36.         int size() const { return _size; }
  37.  
  38.         char* toString(char* str) const;
  39.  
  40.     private:
  41.         Byte _buffer[IR_MAX_QUERY_LEN];
  42.         int _size;
  43.     };
  44.  
  45.  
  46.     //==============================================================================
  47.     // IasAttributeName class
  48.     //==============================================================================
  49.  
  50.     class IasAttributeName
  51.     {
  52.     public:
  53.         IasAttributeName();
  54.         IasAttributeName(const char* protocol, const char* attribute);
  55.  
  56.         IasAttributeName(const IasAttributeName& other);
  57.         IasAttributeName& operator =(const IasAttributeName& other);
  58.  
  59.     // operation
  60.  
  61.         void reset() { _name[0] = 0; }
  62.         IasAttributeName& append(const char* piece);
  63.  
  64.     // attributes
  65.  
  66.         operator const char*() const { return _name; }
  67.  
  68.     private:
  69.         char _name[IR_MAX_IAS_NAME+1];
  70.     };
  71.  
  72.  
  73.     //==============================================================================
  74.     //  IasQuery class
  75.     //==============================================================================
  76.  
  77.     class IasQuery
  78.     {
  79.     public:
  80.         IasQuery(Word refNum);
  81.         ~IasQuery();
  82.  
  83.     private:
  84.         IasQuery(const IasQuery&);
  85.         IasQuery& operator =(const IasQuery&);
  86.  
  87.     // operations
  88.     public:
  89.         bool getRemoteLsap(IrClassType classType, IrProtocolType protocolType, Byte& remoteLsap) const;
  90.         bool getRemoteDeviceName(char* buffer) const;
  91.         bool getRemoteInstanceName(char* buffer) const;
  92.         bool getRemoteParameter(IasParameter& remoteParameter) const;
  93.  
  94.     // utilities
  95.  
  96.         static const char* classTypeName(IrClassType classType);
  97.         static const char* protocolTypeName(IrProtocolType protocolType);
  98.  
  99.     // implementation
  100.     private:
  101.         bool execute(const char* className, const char* attributeName) const;
  102.         bool waitForResult(int expectedResultType) const;
  103.         bool checkResultType(int resultType) const;
  104.         bool getResultUserString(char* buffer) const;
  105.  
  106.         static void queryCallback(IrStatus status);
  107.  
  108.     // data members
  109.     private:
  110.         static const IasQuery* _this;
  111.  
  112.         Word _refNum;
  113.  
  114.         enum ResultState
  115.         {
  116.             ResultNotReady,
  117.             ResultReady,
  118.             ErrorResult,
  119.         };
  120.         mutable ResultState _resultState;
  121.  
  122.         mutable IrIasQuery _query;
  123.         mutable IasQueryBuffer _queryBuffer;
  124.         mutable Byte _resultBuffer[IR_MAX_IAS_ATTR_SIZE];
  125.     };
  126. }
  127. // namespace IrDA
  128.  
  129. #endif  // _IrIAS_h_
  130.