3 /// USB Blackberry detection routines
7 Copyright (C) 2005-2010, 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__
34 struct BXEXPORT ProbeResult
36 Usb::DeviceIDType m_dev
;
37 unsigned char m_interface
;
39 Usb::EndpointPair m_ep
;
40 Usb::EndpointPair m_epModem
;
41 uint8_t m_zeroSocketSequence
;
42 std::string m_description
;
44 // data from a possible ConfigFile (filled in automatically by
45 // the probe code if available)
46 std::string m_cfgDeviceName
;
49 : m_dev(0), m_interface(0), m_pin(0), m_zeroSocketSequence(0)
51 void DumpAll(std::ostream
&os
) const;
52 bool HasIpModem() const { return m_epModem
.IsComplete(); }
54 bool operator==(const Barry::Pin
&pin
) const
60 BXEXPORT
std::ostream
& operator<< (std::ostream
&os
, const ProbeResult
&pr
);
66 typedef std::vector
<ProbeResult
> Results
;
71 std::vector
<std::string
> m_fail_msgs
;
75 Usb::EndpointPair m_epp
;
77 BXLOCAL
bool CheckSize(const Data
&data
, unsigned int required
);
78 BXLOCAL
bool ParsePIN(const Data
&data
, uint32_t &pin
);
79 BXLOCAL
bool ParseDesc(const Data
&data
, std::string
&desc
);
82 void ProbeMatching(int vendor
, int product
,
83 const char *busname
, const char *devname
);
84 void ProbeDevice(Usb::DeviceIDType devid
);
85 bool ProbePair(Usb::Device
&dev
, const Usb::EndpointPair
&ep
,
86 uint32_t &pin
, std::string
&desc
, uint8_t &zeroSocketSequence
);
87 bool ProbeModem(Usb::Device
&dev
, const Usb::EndpointPair
&ep
);
90 Probe(const char *busname
= 0, const char *devname
= 0,
91 const Usb::EndpointPair
*epp
= 0);
93 const Results
& GetResults() const { return m_results
; }
95 int GetCount() const { return m_results
.size(); }
96 int GetFailCount() const { return m_fail_count
; }
98 const std::string
& GetFailMsg(int index
) const { return m_fail_msgs
[index
]; }
99 const ProbeResult
& Get(int index
) const { return m_results
[index
]; }
101 int FindActive(Barry::Pin pin
= 0) const; // returns -1 if pin not found
103 static int FindActive(const Results
&results
, Barry::Pin pin
= 0);
104 static int Find(const Results
&results
, Barry::Pin pin
= 0);