probe.h

Go to the documentation of this file.
00001 ///
00002 /// \file       probe.h
00003 ///             USB Blackberry detection routines
00004 ///
00005 
00006 /*
00007     Copyright (C) 2005-2008, Net Direct Inc. (http://www.netdirect.ca/)
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #ifndef __BARRY_PROBE_H__
00023 #define __BARRY_PROBE_H__
00024 
00025 #include "dll.h"
00026 #include "usbwrap.h"
00027 #include <vector>
00028 #include <iosfwd>
00029 #include <stdint.h>
00030 
00031 namespace Barry {
00032 
00033 struct BXEXPORT ProbeResult
00034 {
00035         Usb::DeviceIDType m_dev;
00036         unsigned char m_interface;
00037         uint32_t m_pin;
00038         Usb::EndpointPair m_ep;
00039         Usb::EndpointPair m_epModem;
00040         uint8_t m_zeroSocketSequence;
00041         std::string m_description;
00042 
00043         ProbeResult()
00044                 : m_dev(0), m_interface(0), m_pin(0), m_zeroSocketSequence(0)
00045                 {}
00046         void DumpAll(std::ostream &os) const;
00047         bool HasIpModem() const { return m_epModem.IsComplete(); }
00048 };
00049 
00050 BXEXPORT std::ostream& operator<< (std::ostream &os, const ProbeResult &pr);
00051 
00052 
00053 class BXEXPORT Probe
00054 {
00055         std::vector<ProbeResult> m_results;
00056 
00057         std::vector<std::string> m_fail_msgs;
00058         int m_fail_count;
00059 
00060         BXLOCAL bool CheckSize(const Data &data, unsigned int required);
00061         BXLOCAL bool ParsePIN(const Data &data, uint32_t &pin);
00062         BXLOCAL bool ParseDesc(const Data &data, std::string &desc);
00063 
00064 protected:
00065         void ProbeMatching(int vendor, int product,
00066                 const char *busname, const char *devname);
00067         void ProbeDevice(Usb::DeviceIDType devid);
00068         bool ProbePair(Usb::Device &dev, const Usb::EndpointPair &ep,
00069                 uint32_t &pin, std::string &desc, uint8_t &zeroSocketSequence);
00070         bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep);
00071 
00072 public:
00073         Probe(const char *busname = 0, const char *devname = 0);
00074 
00075         int GetCount() const { return m_results.size(); }
00076         int GetFailCount() const { return m_fail_count; }
00077 
00078         const std::string& GetFailMsg(int index) const { return m_fail_msgs[index]; }
00079         const ProbeResult& Get(int index) const { return m_results[index]; }
00080 
00081         int FindActive(uint32_t pin = 0) const; // returns -1 if pin not found
00082                                                 // or if no devices
00083 };
00084 
00085 
00086 } // namespace Barry
00087 
00088 #endif
00089 

Generated on Wed Sep 24 21:27:32 2008 for Barry by  doxygen 1.5.1