home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / IrDA / IrOutputStream.cc < prev    next >
C/C++ Source or Header  |  2000-06-07  |  1KB  |  56 lines

  1. //
  2. //  $Id: IrOutputStream.cc,v 1.4 2000/06/07 06:53:11 sergey Exp $
  3. //
  4.  
  5. #include <Pilot.h>
  6. #include "IrOutputStream.h"
  7.  
  8.  
  9. namespace IrDA
  10. {
  11.     // operations
  12.  
  13.     bool IrOutputStream::open()
  14.     {
  15.         // without callback in this version
  16.         if (_port.open(0))
  17.             return _port.connect();
  18.  
  19.         return false;
  20.     }
  21.  
  22.     bool IrOutputStream::open(Callback& callback)
  23.     {
  24.         if (_port.open(&callback))
  25.             return _port.connect();
  26.  
  27.         return false;
  28.     }
  29.  
  30.     void IrOutputStream::close()
  31.     {
  32.         _port.close();
  33.     }
  34.  
  35.     // OutputStream interface
  36.  
  37.     void IrOutputStream::writeData(const void* data, int size)
  38.     {
  39.         if (_port.isConnected())
  40.         {
  41.             int off = 0;
  42.             do
  43.             {
  44.                 int txSize = size-off;
  45.                 if (txSize > _port.getMaxTxSize())
  46.                     txSize = _port.getMaxTxSize(); // couldn't send more then a MaxSize bytes
  47.  
  48.                 _port.blockingSendData((const Byte*)data+off, txSize);
  49.                 off += txSize;
  50.             }
  51.             while(off < size);
  52.         }
  53.     }
  54. }
  55. // namespace IrDA
  56.