Minor whitespace and usage text fix in upldif.cc
[barry/pauldeden.git] / src / probe.h
blobd1242852cc725ea8f1c344aebf0ced83413dbc94
1 ///
2 /// \file probe.h
3 /// USB Blackberry detection routines
4 ///
6 /*
7 Copyright (C) 2005-2008, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_PROBE_H__
23 #define __BARRY_PROBE_H__
25 #include "dll.h"
26 #include "usbwrap.h"
27 #include <vector>
28 #include <iosfwd>
29 #include <stdint.h>
31 namespace Barry {
33 struct BXEXPORT ProbeResult
35 Usb::DeviceIDType m_dev;
36 unsigned char m_interface;
37 uint32_t m_pin;
38 Usb::EndpointPair m_ep;
39 Usb::EndpointPair m_epModem;
40 uint8_t m_zeroSocketSequence;
41 std::string m_description;
43 ProbeResult()
44 : m_dev(0), m_interface(0), m_pin(0), m_zeroSocketSequence(0)
46 void DumpAll(std::ostream &os) const;
47 bool HasIpModem() const { return m_epModem.IsComplete(); }
50 BXEXPORT std::ostream& operator<< (std::ostream &os, const ProbeResult &pr);
53 class BXEXPORT Probe
55 std::vector<ProbeResult> m_results;
57 std::vector<std::string> m_fail_msgs;
58 int m_fail_count;
60 BXLOCAL bool CheckSize(const Data &data, unsigned int required);
61 BXLOCAL bool ParsePIN(const Data &data, uint32_t &pin);
62 BXLOCAL bool ParseDesc(const Data &data, std::string &desc);
64 protected:
65 void ProbeMatching(int vendor, int product,
66 const char *busname, const char *devname);
67 void ProbeDevice(Usb::DeviceIDType devid);
68 bool ProbePair(Usb::Device &dev, const Usb::EndpointPair &ep,
69 uint32_t &pin, std::string &desc, uint8_t &zeroSocketSequence);
70 bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep);
72 public:
73 Probe(const char *busname = 0, const char *devname = 0);
75 int GetCount() const { return m_results.size(); }
76 int GetFailCount() const { return m_fail_count; }
78 const std::string& GetFailMsg(int index) const { return m_fail_msgs[index]; }
79 const ProbeResult& Get(int index) const { return m_results[index]; }
81 int FindActive(uint32_t pin = 0) const; // returns -1 if pin not found
82 // or if no devices
86 } // namespace Barry
88 #endif