author | harlekin <harlekin> | 2002-06-20 18:37:19 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-20 18:37:19 (UTC) |
commit | e3b199e4b3ad71cb8d046e33e792402250a8faec (patch) (unidiff) | |
tree | 22bf9a5d7295819e09bd89adee8fff90a4fdfbdc | |
parent | 6b3a0f610d311ee6b1b44a3f20350b9ce63ba368 (diff) | |
download | opie-e3b199e4b3ad71cb8d046e33e792402250a8faec.zip opie-e3b199e4b3ad71cb8d046e33e792402250a8faec.tar.gz opie-e3b199e4b3ad71cb8d046e33e792402250a8faec.tar.bz2 |
available instead of connected - better naming
-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 8 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index c454588..fcd21f6 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc | |||
@@ -14,61 +14,61 @@ Manager::Manager( const QString& dev ) | |||
14 | m_sdp = 0; | 14 | m_sdp = 0; |
15 | } | 15 | } |
16 | Manager::Manager( Device* dev ) | 16 | Manager::Manager( Device* dev ) |
17 | : QObject() | 17 | : QObject() |
18 | { | 18 | { |
19 | m_hcitool = 0; | 19 | m_hcitool = 0; |
20 | m_sdp = 0; | 20 | m_sdp = 0; |
21 | } | 21 | } |
22 | Manager::Manager() | 22 | Manager::Manager() |
23 | : QObject() | 23 | : QObject() |
24 | { | 24 | { |
25 | m_hcitool = 0; | 25 | m_hcitool = 0; |
26 | m_sdp = 0; | 26 | m_sdp = 0; |
27 | } | 27 | } |
28 | Manager::~Manager(){ | 28 | Manager::~Manager(){ |
29 | delete m_hcitool; | 29 | delete m_hcitool; |
30 | delete m_sdp; | 30 | delete m_sdp; |
31 | } | 31 | } |
32 | void Manager::setDevice( const QString& dev ){ | 32 | void Manager::setDevice( const QString& dev ){ |
33 | m_device = dev; | 33 | m_device = dev; |
34 | } | 34 | } |
35 | void Manager::setDevice( Device* dev ){ | 35 | void Manager::setDevice( Device* dev ){ |
36 | 36 | ||
37 | } | 37 | } |
38 | void Manager::isConnected( const QString& device ){ | 38 | void Manager::isAvailable( const QString& device ){ |
39 | OProcess* l2ping = new OProcess(); | 39 | OProcess* l2ping = new OProcess(); |
40 | l2ping->setName( device.latin1() ); | 40 | l2ping->setName( device.latin1() ); |
41 | *l2ping << "l2ping" << "-c1" << device; | 41 | *l2ping << "l2ping" << "-c1" << device; |
42 | connect(l2ping, SIGNAL(processExited(OProcess* ) ), | 42 | connect(l2ping, SIGNAL(processExited(OProcess* ) ), |
43 | this, SLOT(slotProcessExited(OProcess*) ) ); | 43 | this, SLOT(slotProcessExited(OProcess*) ) ); |
44 | if (!l2ping->start() ) { | 44 | if (!l2ping->start() ) { |
45 | emit connected( device, false ); | 45 | emit available( device, false ); |
46 | delete l2ping; | 46 | delete l2ping; |
47 | } | 47 | } |
48 | 48 | ||
49 | } | 49 | } |
50 | void Manager::isConnected( Device* dev ){ | 50 | void Manager::isAvailable( Device* dev ){ |
51 | 51 | ||
52 | 52 | ||
53 | } | 53 | } |
54 | void Manager::searchDevices( const QString& device ){ | 54 | void Manager::searchDevices( const QString& device ){ |
55 | qWarning("search devices"); | 55 | qWarning("search devices"); |
56 | OProcess* hcitool = new OProcess(); | 56 | OProcess* hcitool = new OProcess(); |
57 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); | 57 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); |
58 | *hcitool << "hcitool" << "scan"; | 58 | *hcitool << "hcitool" << "scan"; |
59 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , | 59 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , |
60 | this, SLOT(slotHCIExited(OProcess* ) ) ); | 60 | this, SLOT(slotHCIExited(OProcess* ) ) ); |
61 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 61 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
62 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); | 62 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); |
63 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 63 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
64 | qWarning("could not start"); | 64 | qWarning("could not start"); |
65 | RemoteDevice::ValueList list; | 65 | RemoteDevice::ValueList list; |
66 | emit foundDevices( device, list ); | 66 | emit foundDevices( device, list ); |
67 | delete hcitool; | 67 | delete hcitool; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | void Manager::searchDevices(Device* d ){ | 71 | void Manager::searchDevices(Device* d ){ |
72 | 72 | ||
73 | 73 | ||
74 | } | 74 | } |
@@ -106,49 +106,49 @@ void Manager::searchServices( const QString& remDevice ){ | |||
106 | this, SLOT(slotSDPExited(OProcess* ) ) ); | 106 | this, SLOT(slotSDPExited(OProcess* ) ) ); |
107 | connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 107 | connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
108 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); | 108 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); |
109 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 109 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
110 | delete m_sdp; | 110 | delete m_sdp; |
111 | Services::ValueList list; | 111 | Services::ValueList list; |
112 | emit foundServices( remDevice, list ); | 112 | emit foundServices( remDevice, list ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | void Manager::searchServices( const RemoteDevice& dev){ | 115 | void Manager::searchServices( const RemoteDevice& dev){ |
116 | searchServices( dev.mac() ); | 116 | searchServices( dev.mac() ); |
117 | } | 117 | } |
118 | QString Manager::toDevice( const QString& mac ){ | 118 | QString Manager::toDevice( const QString& mac ){ |
119 | 119 | ||
120 | } | 120 | } |
121 | QString Manager::toMac( const QString &device ){ | 121 | QString Manager::toMac( const QString &device ){ |
122 | 122 | ||
123 | } | 123 | } |
124 | void Manager::slotProcessExited(OProcess* proc ) { | 124 | void Manager::slotProcessExited(OProcess* proc ) { |
125 | bool conn= false; | 125 | bool conn= false; |
126 | if (proc->normalExit() && proc->exitStatus() == 0 ) | 126 | if (proc->normalExit() && proc->exitStatus() == 0 ) |
127 | conn = true; | 127 | conn = true; |
128 | 128 | ||
129 | QString name = QString::fromLatin1(proc->name() ); | 129 | QString name = QString::fromLatin1(proc->name() ); |
130 | emit connected( name, conn ); | 130 | emit available( name, conn ); |
131 | delete proc; | 131 | delete proc; |
132 | } | 132 | } |
133 | void Manager::slotSDPOut(OProcess* proc, char* ch, int len) | 133 | void Manager::slotSDPOut(OProcess* proc, char* ch, int len) |
134 | { | 134 | { |
135 | QCString str(ch, len+1 ); | 135 | QCString str(ch, len+1 ); |
136 | QMap<QString, QString>::Iterator it; | 136 | QMap<QString, QString>::Iterator it; |
137 | it = m_out.find(proc->name() ); | 137 | it = m_out.find(proc->name() ); |
138 | if ( it != m_out.end() ) { | 138 | if ( it != m_out.end() ) { |
139 | QString string = it.data(); | 139 | QString string = it.data(); |
140 | string.append( str ); | 140 | string.append( str ); |
141 | m_out.replace( proc->name(), string ); | 141 | m_out.replace( proc->name(), string ); |
142 | } | 142 | } |
143 | 143 | ||
144 | } | 144 | } |
145 | void Manager::slotSDPExited( OProcess* proc) | 145 | void Manager::slotSDPExited( OProcess* proc) |
146 | { | 146 | { |
147 | Services::ValueList list; | 147 | Services::ValueList list; |
148 | if (proc->normalExit() ) { | 148 | if (proc->normalExit() ) { |
149 | QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); | 149 | QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); |
150 | if ( it != m_out.end() ) { | 150 | if ( it != m_out.end() ) { |
151 | list = parseSDPOutput( it.data() ); | 151 | list = parseSDPOutput( it.data() ); |
152 | m_out.remove( it ); | 152 | m_out.remove( it ); |
153 | } | 153 | } |
154 | } | 154 | } |
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index aba70f7..415ec72 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h | |||
@@ -32,100 +32,100 @@ Q_OBJECT | |||
32 | */ | 32 | */ |
33 | Manager( Device* dev ); | 33 | Manager( Device* dev ); |
34 | /** | 34 | /** |
35 | * c'tor | 35 | * c'tor |
36 | */ | 36 | */ |
37 | Manager(); | 37 | Manager(); |
38 | ~Manager(); | 38 | ~Manager(); |
39 | 39 | ||
40 | /** Set the manager to control a new device | 40 | /** Set the manager to control a new device |
41 | * @param device the new device to control (hci0 ) | 41 | * @param device the new device to control (hci0 ) |
42 | */ | 42 | */ |
43 | void setDevice( const QString& device ); | 43 | void setDevice( const QString& device ); |
44 | /** | 44 | /** |
45 | * Convience functions for setting a new device | 45 | * Convience functions for setting a new device |
46 | */ | 46 | */ |
47 | void setDevice( Device *dev ); | 47 | void setDevice( Device *dev ); |
48 | /** | 48 | /** |
49 | * Wether or not a device is connected. The function | 49 | * Wether or not a device is connected. The function |
50 | * is asynchron | 50 | * is asynchron |
51 | * If device is empty it will take the currently managed | 51 | * If device is empty it will take the currently managed |
52 | * device and see if it's up | 52 | * device and see if it's up |
53 | * for Remote devices it will ping and see. | 53 | * for Remote devices it will ping and see. |
54 | * @param either mac or hciX | 54 | * @param either mac or hciX |
55 | */ | 55 | */ |
56 | void isConnected(const QString& device= QString::null ); | 56 | void isAvailable(const QString& device= QString::null ); |
57 | /** | 57 | /** |
58 | * same as above | 58 | * same as above |
59 | */ | 59 | */ |
60 | void isConnected(Device *dev ); | 60 | void isAvailable(Device *dev ); |
61 | 61 | ||
62 | /** this searchs for devices reachable from the | 62 | /** this searchs for devices reachable from the |
63 | * currently managed device | 63 | * currently managed device |
64 | * or from device if @param device is not empty | 64 | * or from device if @param device is not empty |
65 | */ | 65 | */ |
66 | void searchDevices(const QString& device= QString::null ); | 66 | void searchDevices(const QString& device= QString::null ); |
67 | /** same as above | 67 | /** same as above |
68 | * | 68 | * |
69 | */ | 69 | */ |
70 | void searchDevices(Device *d ); | 70 | void searchDevices(Device *d ); |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * This will add the service @param name | 73 | * This will add the service @param name |
74 | * to the sdpd daemon | 74 | * to the sdpd daemon |
75 | * It will start the daemon if necessary | 75 | * It will start the daemon if necessary |
76 | */ | 76 | */ |
77 | void addService(const QString &name ); | 77 | void addService(const QString &name ); |
78 | /** | 78 | /** |
79 | * This will add the services @param names | 79 | * This will add the services @param names |
80 | * to the sdpd daemon | 80 | * to the sdpd daemon |
81 | * It will start the daemon if necessary | 81 | * It will start the daemon if necessary |
82 | */ | 82 | */ |
83 | void addServices( const QStringList& names ); | 83 | void addServices( const QStringList& names ); |
84 | /** | 84 | /** |
85 | * This removes a service from the sdps | 85 | * This removes a service from the sdps |
86 | */ | 86 | */ |
87 | void removeService(const QString &name ); | 87 | void removeService(const QString &name ); |
88 | /** | 88 | /** |
89 | * Removes a list from the sdpd | 89 | * Removes a list from the sdpd |
90 | */ | 90 | */ |
91 | void removeServices(const QStringList& ); | 91 | void removeServices(const QStringList& ); |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * search for services on a remote device | 94 | * search for services on a remote device |
95 | * | 95 | * |
96 | */ | 96 | */ |
97 | void searchServices( const QString& remDevice ); | 97 | void searchServices( const QString& remDevice ); |
98 | /** | 98 | /** |
99 | * search for services on a remote device | 99 | * search for services on a remote device |
100 | */ | 100 | */ |
101 | void searchServices( const RemoteDevice& ); | 101 | void searchServices( const RemoteDevice& ); |
102 | /*static*/ QString toDevice( const QString& mac ); | 102 | /*static*/ QString toDevice( const QString& mac ); |
103 | /*static*/ QString toMac( const QString &device ); | 103 | /*static*/ QString toMac( const QString &device ); |
104 | 104 | ||
105 | signals: | 105 | signals: |
106 | // device either mac or dev name | 106 | // device either mac or dev name |
107 | // the first device is the device which you access | 107 | // the first device is the device which you access |
108 | void connected( const QString& device, bool connected ); | 108 | void available( const QString& device, bool connected ); |
109 | void addedService( const QString& service, bool added ); | 109 | void addedService( const QString& service, bool added ); |
110 | void removedService( const QString& service, bool removed ); | 110 | void removedService( const QString& service, bool removed ); |
111 | void foundServices( const QString& device, Services::ValueList ); | 111 | void foundServices( const QString& device, Services::ValueList ); |
112 | void foundDevices( const QString& device, RemoteDevice::ValueList ); | 112 | void foundDevices( const QString& device, RemoteDevice::ValueList ); |
113 | 113 | ||
114 | private slots: | 114 | private slots: |
115 | void slotProcessExited(OProcess* ); | 115 | void slotProcessExited(OProcess* ); |
116 | void slotSDPExited(OProcess*); | 116 | void slotSDPExited(OProcess*); |
117 | void slotSDPOut(OProcess*, char*, int); | 117 | void slotSDPOut(OProcess*, char*, int); |
118 | void slotHCIExited(OProcess* ); | 118 | void slotHCIExited(OProcess* ); |
119 | void slotHCIOut(OProcess*, char*, int ); | 119 | void slotHCIOut(OProcess*, char*, int ); |
120 | private: | 120 | private: |
121 | Services::ValueList parseSDPOutput( const QString& ); | 121 | Services::ValueList parseSDPOutput( const QString& ); |
122 | RemoteDevice::ValueList parseHCIOutput( const QString& ); | 122 | RemoteDevice::ValueList parseHCIOutput( const QString& ); |
123 | OProcess *m_hcitool; | 123 | OProcess *m_hcitool; |
124 | OProcess *m_sdp; // not only one | 124 | OProcess *m_sdp; // not only one |
125 | QString m_device; | 125 | QString m_device; |
126 | QMap<QString, QString> m_out; | 126 | QMap<QString, QString> m_out; |
127 | QMap<QString, QString> m_devices; | 127 | QMap<QString, QString> m_devices; |
128 | }; | 128 | }; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | #endif | 131 | #endif |