kpilot

DeviceCommThread Class Reference

Class that handles all device communications. More...

#include <kpilotdevicelinkPrivate.h>

Inheritance diagram for DeviceCommThread:

List of all members.


Public Member Functions

 DeviceCommThread (KPilotDeviceLink *d)
virtual void run ()
void setDone (bool b)
virtual ~DeviceCommThread ()

Protected Slots

void acceptDevice ()
void openDevice ()
void workaroundUSB ()

Protected Member Functions

void close ()
bool open (const QString &device=QString::null)
void reset ()

Detailed Description

Class that handles all device communications.

We do this in a different thread so that we do not block the main Qt Event thread (similar to Swing's AWT event dispatch thread).

Definition at line 214 of file kpilotdevicelinkPrivate.h.


Constructor & Destructor Documentation

DeviceCommThread::DeviceCommThread ( KPilotDeviceLink d  ) 

Definition at line 85 of file kpilotdevicelink.cc.

DeviceCommThread::~DeviceCommThread (  )  [virtual]

Definition at line 101 of file kpilotdevicelink.cc.


Member Function Documentation

void DeviceCommThread::acceptDevice (  )  [protected, slot]

Called when the device is opened *and* activity occurs on the device.

We've been notified by our QSocketNotifier that we have data available on the socket.

This indicates the beginning of a hotsync.

Try to go through the remaining steps of the connnection process. Note: If we return at all from this before the very end without a successful connection, we need to make sure we restart our connection open timer, otherwise it won't be restarted.

Our socket notifier should be the only reason that we end up here. If we're here without him being active, we have a problem. Try to clean up and get out.

Definition at line 339 of file kpilotdevicelink.cc.

void DeviceCommThread::close (  )  [protected]

Definition at line 108 of file kpilotdevicelink.cc.

bool DeviceCommThread::open ( const QString device = QString::null  )  [protected]

Does the low-level opening of the device and handles the pilot-link library initialisation.

We _always_ want to set a maximum amount of time that we will wait for the sync process to start. In the case where our user has told us that he has a funky USB device, set the workaround timeout for shorter than normal.

Definition at line 222 of file kpilotdevicelink.cc.

void DeviceCommThread::openDevice (  )  [protected, slot]

Attempt to open the device.

This is an asyncronous process.

Called regularly to check if the device exists (to handle USB-style devices).

We try to create a socket with the Palm and then bind to it (in open()). If we're able to do those 2 things, then we do 2 things: we set a timeout timer (which will tell us that X amount of time has transpired before we get into the meat of the sync transaction), and we also set up a QSocketNotifier, which will tell us when data is available to be read from the Palm socket. If we were unable to create a socket and/or bind to the Palm in this method, we'll start our timer again.

Definition at line 170 of file kpilotdevicelink.cc.

void DeviceCommThread::reset (  )  [protected]

Definition at line 141 of file kpilotdevicelink.cc.

void DeviceCommThread::run (  )  [virtual]

Reimplemented from QThread.

Definition at line 508 of file kpilotdevicelink.cc.

void DeviceCommThread::setDone ( bool  b  )  [inline]

Definition at line 226 of file kpilotdevicelinkPrivate.h.

void DeviceCommThread::workaroundUSB (  )  [protected, slot]

This slot fires whenever we've been trying to establish a hotsync with the device for longer than a given amount of time.

When this slot is fired, we will tear down the communications process and start over again.

Definition at line 501 of file kpilotdevicelink.cc.


The documentation for this class was generated from the following files: