author | erik <erik> | 2007-01-31 22:23:27 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-31 22:23:27 (UTC) |
commit | 73edac572d9ac9cfd18cc1254fc2019563d55f16 (patch) (unidiff) | |
tree | a420b341ce2bcb4a049c76935544b8bce2a0a853 | |
parent | ed5fba8cdb27174427b2e7780508bafa05536ca1 (diff) | |
download | opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.zip opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.tar.gz opie-73edac572d9ac9cfd18cc1254fc2019563d55f16.tar.bz2 |
A few files that dereference pointers w/out checking that the pointer is
valid.
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 35 | ||||
-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.cpp | 2 |
3 files changed, 14 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 678ebdf..780d705 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp | |||
@@ -1,211 +1,196 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "playlistselection.h" | 20 | #include "playlistselection.h" |
21 | 21 | ||
22 | /* OPIE */ | 22 | /* OPIE */ |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qheader.h> | 27 | #include <qheader.h> |
28 | 28 | ||
29 | /* STD */ | 29 | /* STD */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | class PlayListSelectionItem : public QListViewItem { | 32 | class PlayListSelectionItem : public QListViewItem { |
33 | public: | 33 | public: |
34 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 34 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
35 | setText( 0, f->name() ); | 35 | setText( 0, f->name() ); |
36 | setPixmap( 0, f->pixmap() ); | 36 | setPixmap( 0, f->pixmap() ); |
37 | } | 37 | } |
38 | 38 | ||
39 | ~PlayListSelectionItem() { | 39 | ~PlayListSelectionItem() { |
40 | }; | 40 | }; |
41 | 41 | ||
42 | const DocLnk *file() const { return fl; } | 42 | const DocLnk *file() const { return fl; } |
43 | 43 | ||
44 | private: | 44 | private: |
45 | const DocLnk *fl; | 45 | const DocLnk *fl; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | 48 | ||
49 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 49 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
50 | : QListView( parent, name ) | 50 | : QListView( parent, name ) |
51 | { | 51 | { |
52 | // odebug << "starting playlistselector" << oendl; | 52 | // odebug << "starting playlistselector" << oendl; |
53 | // #ifdef USE_PLAYLIST_BACKGROUND | ||
54 | // setStaticBackground( TRUE ); | ||
55 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | ||
56 | |||
57 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | ||
58 | // #endif | ||
59 | // addColumn("Title",236); | ||
60 | // setAllColumnsShowFocus( TRUE ); | ||
61 | addColumn( tr( "Playlist Selection" ) ); | 53 | addColumn( tr( "Playlist Selection" ) ); |
62 | header()->hide(); | 54 | header()->hide(); |
63 | setSorting( -1, FALSE ); | 55 | setSorting( -1, FALSE ); |
64 | } | 56 | } |
65 | 57 | ||
66 | 58 | ||
67 | PlayListSelection::~PlayListSelection() { | 59 | PlayListSelection::~PlayListSelection() { |
68 | } | 60 | } |
69 | 61 | ||
70 | 62 | ||
71 | // #ifdef USE_PLAYLIST_BACKGROUND | ||
72 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 63 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
73 | // odebug << "drawBackground" << oendl; | 64 | // odebug << "drawBackground" << oendl; |
74 | p->fillRect( r, QBrush( white ) ); | 65 | p->fillRect( r, QBrush( white ) ); |
75 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | ||
76 | // if ( !logo.isNull() ) | ||
77 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | ||
78 | } | 66 | } |
79 | // #endif | ||
80 | 67 | ||
81 | 68 | ||
82 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 69 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
83 | if ( event->state() == QMouseEvent::LeftButton ) { | 70 | if ( event->state() == QMouseEvent::LeftButton ) { |
84 | QListViewItem *currentItem = selectedItem(); | 71 | QListViewItem *currentItem = selectedItem(); |
85 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 72 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
86 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 73 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
87 | moveSelectedUp(); | 74 | moveSelectedUp(); |
88 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 75 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
89 | moveSelectedDown(); | 76 | moveSelectedDown(); |
90 | } | 77 | } |
91 | } | 78 | } |
92 | 79 | ||
93 | 80 | ||
94 | const DocLnk *PlayListSelection::current() { | 81 | const DocLnk *PlayListSelection::current() { |
95 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 82 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
96 | if ( item ) | 83 | if ( item ) |
97 | return item->file(); | 84 | return item->file(); |
98 | return NULL; | 85 | return NULL; |
99 | } | 86 | } |
100 | 87 | ||
101 | 88 | ||
102 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 89 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
103 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 90 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
104 | QListViewItem *current = selectedItem(); | 91 | QListViewItem *current = selectedItem(); |
105 | if ( current ) | 92 | if ( current ) |
106 | item->moveItem( current ); | 93 | item->moveItem( current ); |
107 | setSelected( item, TRUE ); | 94 | setSelected( item, TRUE ); |
108 | ensureItemVisible( selectedItem() ); | 95 | ensureItemVisible( selectedItem() ); |
109 | } | 96 | } |
110 | 97 | ||
111 | 98 | ||
112 | void PlayListSelection::removeSelected() { | 99 | void PlayListSelection::removeSelected() { |
113 | QListViewItem *item = selectedItem(); | 100 | QListViewItem *item = selectedItem(); |
114 | delete item; | 101 | delete item; |
115 | setSelected( currentItem(), TRUE ); | 102 | setSelected( currentItem(), TRUE ); |
116 | ensureItemVisible( selectedItem() ); | 103 | ensureItemVisible( selectedItem() ); |
117 | } | 104 | } |
118 | 105 | ||
119 | 106 | ||
120 | void PlayListSelection::moveSelectedUp() { | 107 | void PlayListSelection::moveSelectedUp() { |
121 | QListViewItem *item = selectedItem(); | 108 | QListViewItem *item = selectedItem(); |
122 | if ( item && item->itemAbove() ) | 109 | if ( item && item->itemAbove() ) |
123 | item->itemAbove()->moveItem( item ); | 110 | item->itemAbove()->moveItem( item ); |
124 | ensureItemVisible( selectedItem() ); | 111 | ensureItemVisible( selectedItem() ); |
125 | } | 112 | } |
126 | 113 | ||
127 | 114 | ||
128 | void PlayListSelection::moveSelectedDown() { | 115 | void PlayListSelection::moveSelectedDown() { |
129 | QListViewItem *item = selectedItem(); | 116 | QListViewItem *item = selectedItem(); |
130 | if ( item && item->itemBelow() ) | 117 | if ( item && item->itemBelow() ) |
131 | item->moveItem( item->itemBelow() ); | 118 | item->moveItem( item->itemBelow() ); |
132 | ensureItemVisible( selectedItem() ); | 119 | ensureItemVisible( selectedItem() ); |
133 | } | 120 | } |
134 | 121 | ||
135 | 122 | ||
136 | bool PlayListSelection::prev() { | 123 | bool PlayListSelection::prev() { |
137 | QListViewItem *item = selectedItem(); | 124 | QListViewItem *item = selectedItem(); |
138 | if ( item && item->itemAbove() ) | 125 | if ( item && item->itemAbove() ) |
139 | setSelected( item->itemAbove(), TRUE ); | 126 | setSelected( item->itemAbove(), TRUE ); |
140 | else | 127 | else |
141 | return FALSE; | 128 | return FALSE; |
142 | ensureItemVisible( selectedItem() ); | 129 | ensureItemVisible( selectedItem() ); |
143 | return TRUE; | 130 | return TRUE; |
144 | } | 131 | } |
145 | 132 | ||
146 | bool PlayListSelection::next() { | 133 | bool PlayListSelection::next() { |
147 | QListViewItem *item = selectedItem(); | 134 | QListViewItem *item = selectedItem(); |
148 | if ( item && item->itemBelow() ) | 135 | if ( item && item->itemBelow() ) |
149 | setSelected( item->itemBelow(), TRUE ); | 136 | setSelected( item->itemBelow(), TRUE ); |
150 | else | 137 | else |
151 | return FALSE; | 138 | return FALSE; |
152 | ensureItemVisible( selectedItem() ); | 139 | ensureItemVisible( selectedItem() ); |
153 | return TRUE; | 140 | return TRUE; |
154 | } | 141 | } |
155 | 142 | ||
156 | 143 | ||
157 | bool PlayListSelection::first() { | 144 | bool PlayListSelection::first() { |
158 | QListViewItem *item = firstChild(); | 145 | QListViewItem *item = firstChild(); |
159 | if ( item ) | 146 | if ( item ) |
160 | setSelected( item, TRUE ); | 147 | setSelected( item, TRUE ); |
161 | else | 148 | else |
162 | return FALSE; | 149 | return FALSE; |
163 | ensureItemVisible( selectedItem() ); | 150 | ensureItemVisible( selectedItem() ); |
164 | return TRUE; | 151 | return TRUE; |
165 | } | 152 | } |
166 | 153 | ||
167 | 154 | ||
168 | bool PlayListSelection::last() { | 155 | bool PlayListSelection::last() { |
169 | QListViewItem *prevItem = NULL; | 156 | QListViewItem *prevItem = NULL; |
170 | QListViewItem *item = firstChild(); | 157 | QListViewItem *item = firstChild(); |
171 | while ( ( item = item->nextSibling() ) ) | 158 | while ( ( item = item->nextSibling() ) ) |
172 | prevItem = item; | 159 | prevItem = item; |
173 | if ( prevItem ) | 160 | if ( prevItem ) |
174 | setSelected( prevItem, TRUE ); | 161 | setSelected( prevItem, TRUE ); |
175 | else | 162 | else |
176 | return FALSE; | 163 | return FALSE; |
177 | ensureItemVisible( selectedItem() ); | 164 | ensureItemVisible( selectedItem() ); |
178 | return TRUE; | 165 | return TRUE; |
179 | } | 166 | } |
180 | 167 | ||
181 | void PlayListSelection::unSelect() | 168 | void PlayListSelection::unSelect() |
182 | { | 169 | { |
183 | //QListViewItem *item = selectedItem(); | ||
184 | setSelected( currentItem(), FALSE); | 170 | setSelected( currentItem(), FALSE); |
185 | } | 171 | } |
186 | 172 | ||
187 | void PlayListSelection::writeCurrent( Config& cfg ) { | 173 | void PlayListSelection::writeCurrent( Config& cfg ) { |
188 | cfg.setGroup("PlayList"); | 174 | cfg.setGroup("PlayList"); |
189 | QListViewItem *item = selectedItem(); | 175 | QListViewItem *item = selectedItem(); |
190 | if ( item ) | 176 | if ( item ) { |
191 | cfg.writeEntry("current", item->text(0) ); | 177 | cfg.writeEntry("current", item->text(0) ); |
192 | odebug << item->text(0) << oendl; | 178 | odebug << item->text(0) << oendl; |
179 | } | ||
193 | 180 | ||
194 | } | 181 | } |
195 | 182 | ||
196 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 183 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
197 | 184 | ||
198 | unSelect(); | 185 | unSelect(); |
199 | QListViewItemIterator it( this ); | 186 | QListViewItemIterator it( this ); |
200 | for ( ; it.current(); ++it ) { | 187 | for ( ; it.current(); ++it ) { |
201 | // odebug << it.current()->text(0) << oendl; | 188 | // odebug << it.current()->text(0) << oendl; |
202 | if( strk == it.current()->text(0)) { | 189 | if( strk == it.current()->text(0)) { |
203 | // odebug << "We have a match "+strk << oendl; | 190 | // odebug << "We have a match "+strk << oendl; |
204 | setSelected( it.current(), TRUE); | 191 | setSelected( it.current(), TRUE); |
205 | ensureItemVisible( it.current() ); | 192 | ensureItemVisible( it.current() ); |
206 | return; | 193 | return; |
207 | } | 194 | } |
208 | } | 195 | } |
209 | // setSelected( item, TRUE ); | ||
210 | // ensureItemVisible( selectedItem() ); | ||
211 | } | 196 | } |
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index a9bef65..d948fb9 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp | |||
@@ -120,262 +120,263 @@ NetworkSetup * EditNetworkSetup::getTmpCollection( void ) { | |||
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | TmpCollection.clear(); | 123 | TmpCollection.clear(); |
124 | if( SelectedNodes ) { | 124 | if( SelectedNodes ) { |
125 | // initialize like original | 125 | // initialize like original |
126 | TmpCollection.copyFrom( *SelectedNodes ); | 126 | TmpCollection.copyFrom( *SelectedNodes ); |
127 | } | 127 | } |
128 | 128 | ||
129 | // update content | 129 | // update content |
130 | QListViewItem * it = Nodes_LV->firstChild(); | 130 | QListViewItem * it = Nodes_LV->firstChild(); |
131 | ANetNode * NN; | 131 | ANetNode * NN; |
132 | 132 | ||
133 | // start iter (if there is a collection) | 133 | // start iter (if there is a collection) |
134 | /* | 134 | /* |
135 | 135 | ||
136 | a node collection is sorted from the toplevel | 136 | a node collection is sorted from the toplevel |
137 | node to the deepest node | 137 | node to the deepest node |
138 | 138 | ||
139 | */ | 139 | */ |
140 | ANetNodeInstance * NNI = | 140 | ANetNodeInstance * NNI = |
141 | (SelectedNodes) ? SelectedNodes->first() : 0 ; | 141 | (SelectedNodes) ? SelectedNodes->first() : 0 ; |
142 | 142 | ||
143 | TmpCollection.setModified( 0 ); | 143 | TmpCollection.setModified( 0 ); |
144 | 144 | ||
145 | // the listview always starts with the toplevel | 145 | // the listview always starts with the toplevel |
146 | // hierarchy. This is always a controller item | 146 | // hierarchy. This is always a controller item |
147 | while ( it ) { | 147 | while ( it ) { |
148 | NN = (*Mapping)[it]; | 148 | NN = (*Mapping)[it]; |
149 | if( NN == 0 ) { | 149 | if( NN == 0 ) { |
150 | // this item is a controller -> | 150 | // this item is a controller -> |
151 | // has radio items as children -> | 151 | // has radio items as children -> |
152 | // find selected one | 152 | // find selected one |
153 | it = it->firstChild(); | 153 | it = it->firstChild(); |
154 | while( it ) { | 154 | while( it ) { |
155 | if( ((QCheckListItem *)it)->isOn() ) { | 155 | if( ((QCheckListItem *)it)->isOn() ) { |
156 | // this radio is selected -> go deeper | 156 | // this radio is selected -> go deeper |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | it = it->nextSibling(); | 159 | it = it->nextSibling(); |
160 | } | 160 | } |
161 | 161 | ||
162 | if( ! it ) { | 162 | if( ! it ) { |
163 | TmpIsValid = 0; | 163 | TmpIsValid = 0; |
164 | return 0; | 164 | return 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | // it now contains selected radio | 167 | // it now contains selected radio |
168 | NN = (*Mapping)[it]; | 168 | NN = (*Mapping)[it]; |
169 | } | 169 | } |
170 | 170 | ||
171 | // NN here contains the netnode of the | 171 | // NN here contains the netnode of the |
172 | // current item -> this node needs to | 172 | // current item -> this node needs to |
173 | // be stored in the collection | 173 | // be stored in the collection |
174 | if( NNI == 0 || | 174 | if( NNI == 0 || |
175 | it->text(0) != NNI->nodeClass()->name() ) { | 175 | it->text(0) != NNI->nodeClass()->name() ) { |
176 | // new item not in previous collection | 176 | // new item not in previous collection |
177 | ANetNodeInstance * NNI = NN->createInstance(); | 177 | ANetNodeInstance * NNI = NN->createInstance(); |
178 | NNI->initialize(); | 178 | NNI->initialize(); |
179 | // this node type not in collection | 179 | // this node type not in collection |
180 | TmpCollection.append( NNI ); | 180 | TmpCollection.append( NNI ); |
181 | // master collection changed because new item in it | 181 | // master collection changed because new item in it |
182 | TmpCollection.setModified( 1 ); | 182 | TmpCollection.setModified( 1 ); |
183 | // no more valid items in old list | 183 | // no more valid items in old list |
184 | NNI = 0; | 184 | NNI = 0; |
185 | } else { | 185 | } else { |
186 | // already in list -> copy pointer | 186 | // already in list -> copy pointer |
187 | TmpCollection.append( NNI ); | 187 | TmpCollection.append( NNI ); |
188 | NNI = SelectedNodes->next(); | 188 | NNI = SelectedNodes->next(); |
189 | } | 189 | } |
190 | 190 | ||
191 | // go deeper to next level | 191 | // go deeper to next level |
192 | // this level is can be a new controller | 192 | // this level is can be a new controller |
193 | // or an item | 193 | // or an item |
194 | it = it->firstChild(); | 194 | it = it->firstChild(); |
195 | } | 195 | } |
196 | 196 | ||
197 | TmpIsValid = 1; | 197 | TmpIsValid = 1; |
198 | return &(TmpCollection); | 198 | return &(TmpCollection); |
199 | } | 199 | } |
200 | 200 | ||
201 | // pass a NetworkSetup NetworkSetup to be edited | 201 | // pass a NetworkSetup NetworkSetup to be edited |
202 | void EditNetworkSetup::setNetworkSetup( NetworkSetup * NC ) { | 202 | void EditNetworkSetup::setNetworkSetup( NetworkSetup * NC ) { |
203 | ANetNodeInstance * NNI; | 203 | ANetNodeInstance * NNI; |
204 | ANetNode * NN; | 204 | ANetNode * NN; |
205 | 205 | ||
206 | SelectedNodes = NC; | 206 | SelectedNodes = NC; |
207 | Name_LE->setText( NC->name() ); | 207 | Name_LE->setText( NC->name() ); |
208 | NNI = NC->first(); | 208 | NNI = NC->first(); |
209 | 209 | ||
210 | // show configure tabl | 210 | // show configure tabl |
211 | Tab_TB->setCurrentPage( 1 ); | 211 | Tab_TB->setCurrentPage( 1 ); |
212 | 212 | ||
213 | // valid colledction | 213 | // valid colledction |
214 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); | 214 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); |
215 | Setup_FRM->setEnabled( FALSE ); | 215 | Setup_FRM->setEnabled( FALSE ); |
216 | 216 | ||
217 | // select items in collection | 217 | // select items in collection |
218 | QListViewItem * it = Nodes_LV->firstChild(); | 218 | QListViewItem * it = Nodes_LV->firstChild(); |
219 | bool Found; | 219 | bool Found; |
220 | 220 | ||
221 | TmpIsValid = 0; | 221 | TmpIsValid = 0; |
222 | 222 | ||
223 | while ( it ) { | 223 | while ( it ) { |
224 | NN = (*Mapping)[it]; | 224 | NN = (*Mapping)[it]; |
225 | if( NN == 0 ) { | 225 | if( NN == 0 ) { |
226 | // this item is a controller -> | 226 | // this item is a controller -> |
227 | // has radio items as children -> | 227 | // has radio items as children -> |
228 | // find selected one | 228 | // find selected one |
229 | it = it->firstChild(); | 229 | it = it->firstChild(); |
230 | Found = 0; | 230 | Found = 0; |
231 | while( it ) { | 231 | while( it ) { |
232 | if( NNI && it->text(0) == NNI->nodeClass()->name() ) { | 232 | if( NNI && it->text(0) == NNI->nodeClass()->name() ) { |
233 | // this radio is part of the collection | 233 | // this radio is part of the collection |
234 | ((QCheckListItem *)it)->setOn( 1 ); | 234 | ((QCheckListItem *)it)->setOn( 1 ); |
235 | updateGUI( it, NNI->nodeClass() ); | 235 | updateGUI( it, NNI->nodeClass() ); |
236 | // check its children | 236 | // check its children |
237 | Found = 1; | 237 | Found = 1; |
238 | it = it->firstChild(); | 238 | it = it->firstChild(); |
239 | NNI = SelectedNodes->next(); | 239 | NNI = SelectedNodes->next(); |
240 | // do not bother to check other items | 240 | // do not bother to check other items |
241 | break; | 241 | break; |
242 | } | 242 | } |
243 | it = it->nextSibling(); | 243 | it = it->nextSibling(); |
244 | } | 244 | } |
245 | 245 | ||
246 | if( ! Found ) { | 246 | if( ! Found ) { |
247 | // this means that this level is NOT present in collection | 247 | // this means that this level is NOT present in collection |
248 | // probably INCOMPATIBEL collection OR Missing plugin | 248 | // probably INCOMPATIBLE collection OR Missing plugin |
249 | QString pluginName = NNI ? NNI->nodeClass()->name() : ""; | ||
249 | QMessageBox::warning( | 250 | QMessageBox::warning( |
250 | 0, | 251 | 0, |
251 | tr( "Error presentig NetworkSetup" ), | 252 | tr( "Error presentig NetworkSetup" ), |
252 | tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). | 253 | tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). |
253 | arg(NNI->nodeClass()->name()) ); | 254 | arg(pluginName) ); |
254 | return; | 255 | return; |
255 | } | 256 | } |
256 | 257 | ||
257 | // it now contains selected radio | 258 | // it now contains selected radio |
258 | NN = (*Mapping)[it]; | 259 | NN = (*Mapping)[it]; |
259 | } else { | 260 | } else { |
260 | // automatic selection | 261 | // automatic selection |
261 | if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { | 262 | if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { |
262 | // should exist and be the same | 263 | // should exist and be the same |
263 | if( NNI ) { | 264 | if( NNI ) { |
264 | QMessageBox::warning( | 265 | QMessageBox::warning( |
265 | 0, | 266 | 0, |
266 | tr( "Error presentig NetworkSetup" ), | 267 | tr( "Error presentig NetworkSetup" ), |
267 | tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). | 268 | tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). |
268 | arg(NNI->nodeClass()->name()) ); | 269 | arg(NNI->nodeClass()->name()) ); |
269 | } else { | 270 | } else { |
270 | QMessageBox::warning( | 271 | QMessageBox::warning( |
271 | 0, | 272 | 0, |
272 | tr( "Error presentig NetworkSetup" ), | 273 | tr( "Error presentig NetworkSetup" ), |
273 | tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ). | 274 | tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ). |
274 | arg(it->text(0)) ); | 275 | arg(it->text(0)) ); |
275 | } | 276 | } |
276 | return; | 277 | return; |
277 | } | 278 | } |
278 | it = it->firstChild(); | 279 | it = it->firstChild(); |
279 | } | 280 | } |
280 | } | 281 | } |
281 | } | 282 | } |
282 | 283 | ||
283 | // get result of editing (either new OR updated collection | 284 | // get result of editing (either new OR updated collection |
284 | NetworkSetup * EditNetworkSetup::networkSetup( void ) { | 285 | NetworkSetup * EditNetworkSetup::networkSetup( void ) { |
285 | 286 | ||
286 | if( SelectedNodes == 0 ) { | 287 | if( SelectedNodes == 0 ) { |
287 | // new collection | 288 | // new collection |
288 | SelectedNodes = new NetworkSetup; | 289 | SelectedNodes = new NetworkSetup; |
289 | } | 290 | } |
290 | 291 | ||
291 | // clean out old entries | 292 | // clean out old entries |
292 | SelectedNodes->clear(); | 293 | SelectedNodes->clear(); |
293 | 294 | ||
294 | // transfer | 295 | // transfer |
295 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 296 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
296 | it.current(); | 297 | it.current(); |
297 | ++it ) { | 298 | ++it ) { |
298 | SelectedNodes->append( it.current() ); | 299 | SelectedNodes->append( it.current() ); |
299 | } | 300 | } |
300 | 301 | ||
301 | if( TmpCollection.isModified() ) | 302 | if( TmpCollection.isModified() ) |
302 | SelectedNodes->setModified( 1 ); | 303 | SelectedNodes->setModified( 1 ); |
303 | 304 | ||
304 | if( SelectedNodes->name() != Name_LE->text() ) { | 305 | if( SelectedNodes->name() != Name_LE->text() ) { |
305 | SelectedNodes->setName( Name_LE->text() ); | 306 | SelectedNodes->setName( Name_LE->text() ); |
306 | SelectedNodes->setModified( 1 ); | 307 | SelectedNodes->setModified( 1 ); |
307 | } | 308 | } |
308 | 309 | ||
309 | return SelectedNodes; | 310 | return SelectedNodes; |
310 | } | 311 | } |
311 | 312 | ||
312 | // Build device tree -> start | 313 | // Build device tree -> start |
313 | void EditNetworkSetup::buildFullTree( void ) { | 314 | void EditNetworkSetup::buildFullTree( void ) { |
314 | ANetNode * NN; | 315 | ANetNode * NN; |
315 | 316 | ||
316 | // toplevel item | 317 | // toplevel item |
317 | MyQCheckListItem * TheTop = new MyQCheckListItem( | 318 | MyQCheckListItem * TheTop = new MyQCheckListItem( |
318 | Nodes_LV, | 319 | Nodes_LV, |
319 | NSResources->netNode2Name("fullsetup"), | 320 | NSResources->netNode2Name("fullsetup"), |
320 | QCheckListItem::Controller ); | 321 | QCheckListItem::Controller ); |
321 | TheTop->setOpen( TRUE ); | 322 | TheTop->setOpen( TRUE ); |
322 | Description_LBL->setText( | 323 | Description_LBL->setText( |
323 | NSResources->netNode2Description( "fullsetup" ) ); | 324 | NSResources->netNode2Description( "fullsetup" ) ); |
324 | Nodes_LV->setSelected( TheTop, TRUE ); | 325 | Nodes_LV->setSelected( TheTop, TRUE ); |
325 | 326 | ||
326 | // find all Nodes that are toplevel nodes -> ie provide | 327 | // find all Nodes that are toplevel nodes -> ie provide |
327 | // TCP/IP NetworkSetup | 328 | // TCP/IP NetworkSetup |
328 | for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); | 329 | for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); |
329 | Iter.current(); | 330 | Iter.current(); |
330 | ++Iter ) { | 331 | ++Iter ) { |
331 | NN = Iter.current(); | 332 | NN = Iter.current(); |
332 | 333 | ||
333 | if( ! NN->isToplevel() ) { | 334 | if( ! NN->isToplevel() ) { |
334 | continue; | 335 | continue; |
335 | } | 336 | } |
336 | 337 | ||
337 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, | 338 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, |
338 | NN->name(), | 339 | NN->name(), |
339 | QCheckListItem::RadioButton ); | 340 | QCheckListItem::RadioButton ); |
340 | it->setPixmap( 0, | 341 | it->setPixmap( 0, |
341 | NSResources->getPixmap( NN->pixmapName() ) | 342 | NSResources->getPixmap( NN->pixmapName() ) |
342 | ); | 343 | ); |
343 | // remember that this node maps to this listitem | 344 | // remember that this node maps to this listitem |
344 | Mapping->insert( it, NN ); | 345 | Mapping->insert( it, NN ); |
345 | buildSubTree( it, NN ); | 346 | buildSubTree( it, NN ); |
346 | } | 347 | } |
347 | } | 348 | } |
348 | 349 | ||
349 | // Build device tree -> help function | 350 | // Build device tree -> help function |
350 | void EditNetworkSetup::buildSubTree( QListViewItem * it, ANetNode *NN ) { | 351 | void EditNetworkSetup::buildSubTree( QListViewItem * it, ANetNode *NN ) { |
351 | ANetNode::NetNodeList & NNL = NN->alternatives(); | 352 | ANetNode::NetNodeList & NNL = NN->alternatives(); |
352 | 353 | ||
353 | if( NNL.size() > 1 ) { | 354 | if( NNL.size() > 1 ) { |
354 | // this node has alternatives -> needs radio buttons | 355 | // this node has alternatives -> needs radio buttons |
355 | it = new MyQCheckListItem( | 356 | it = new MyQCheckListItem( |
356 | it, | 357 | it, |
357 | NSResources->netNode2Name(NN->needs()[0]), | 358 | NSResources->netNode2Name(NN->needs()[0]), |
358 | QCheckListItem::Controller ); | 359 | QCheckListItem::Controller ); |
359 | it->setSelectable( FALSE ); | 360 | it->setSelectable( FALSE ); |
360 | } | 361 | } |
361 | 362 | ||
362 | for ( unsigned int i=0; i < NNL.size(); i++ ) { | 363 | for ( unsigned int i=0; i < NNL.size(); i++ ) { |
363 | QListViewItem * CI; | 364 | QListViewItem * CI; |
364 | if( NNL.size() > 1 ) { | 365 | if( NNL.size() > 1 ) { |
365 | // generate radio buttons | 366 | // generate radio buttons |
366 | CI = new MyQCheckListItem( | 367 | CI = new MyQCheckListItem( |
367 | (QCheckListItem *)it, | 368 | (QCheckListItem *)it, |
368 | NNL[i]->name(), QCheckListItem::RadioButton ); | 369 | NNL[i]->name(), QCheckListItem::RadioButton ); |
369 | // remember that this node maps to this listitem | 370 | // remember that this node maps to this listitem |
370 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); | 371 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); |
371 | Mapping->insert( CI, NNL[i] ); | 372 | Mapping->insert( CI, NNL[i] ); |
372 | CI->setSelectable( FALSE ); | 373 | CI->setSelectable( FALSE ); |
373 | } else { | 374 | } else { |
374 | // Single item | 375 | // Single item |
375 | CI = new MyQListViewItem( it, NNL[i]->name() ); | 376 | CI = new MyQListViewItem( it, NNL[i]->name() ); |
376 | // remember that this node maps to this listitem | 377 | // remember that this node maps to this listitem |
377 | Mapping->insert( CI, NNL[i] ); | 378 | Mapping->insert( CI, NNL[i] ); |
378 | CI->setSelectable( FALSE ); | 379 | CI->setSelectable( FALSE ); |
379 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); | 380 | CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); |
380 | } | 381 | } |
381 | buildSubTree( CI, NNL[i] ); | 382 | buildSubTree( CI, NNL[i] ); |
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index fc30bf8..e23fc9c 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp | |||
@@ -319,257 +319,257 @@ OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : | |||
319 | // put name | 319 | // put name |
320 | it->setText( 0, P->name() ); | 320 | it->setText( 0, P->name() ); |
321 | } else { | 321 | } else { |
322 | // unknown | 322 | // unknown |
323 | it->setText( 0, Keys[i].from().toString() ); | 323 | it->setText( 0, Keys[i].from().toString() ); |
324 | } | 324 | } |
325 | 325 | ||
326 | // and put address as sub | 326 | // and put address as sub |
327 | QListViewItem * Sub = new QListViewItem( it ); | 327 | QListViewItem * Sub = new QListViewItem( it ); |
328 | Sub->setText( 0, Keys[i].from().toString() ); | 328 | Sub->setText( 0, Keys[i].from().toString() ); |
329 | Sub->setText( 1, D->address().toString() ); | 329 | Sub->setText( 1, D->address().toString() ); |
330 | } else { | 330 | } else { |
331 | // nor source nor destination -> unknown | 331 | // nor source nor destination -> unknown |
332 | it->setText( 0, Keys[i].from().toString() ); | 332 | it->setText( 0, Keys[i].from().toString() ); |
333 | it->setText( 1, Keys[i].to().toString() ); | 333 | it->setText( 1, Keys[i].to().toString() ); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | OTPairing::~OTPairing() { | 340 | OTPairing::~OTPairing() { |
341 | if( MyIcons ) | 341 | if( MyIcons ) |
342 | delete Icons; | 342 | delete Icons; |
343 | OTGateway::releaseOTGateway(); | 343 | OTGateway::releaseOTGateway(); |
344 | } | 344 | } |
345 | 345 | ||
346 | void OTPairing::SLOT_Unpair( ) { | 346 | void OTPairing::SLOT_Unpair( ) { |
347 | // find selected pair | 347 | // find selected pair |
348 | 348 | ||
349 | QListViewItem * it = Pairs_LV->firstChild(); | 349 | QListViewItem * it = Pairs_LV->firstChild(); |
350 | while( it ) { | 350 | while( it ) { |
351 | if( it->isSelected() ) { | 351 | if( it->isSelected() ) { |
352 | // confirm ? | 352 | // confirm ? |
353 | if( QMessageBox::warning(0, | 353 | if( QMessageBox::warning(0, |
354 | tr("Break pairing"), | 354 | tr("Break pairing"), |
355 | tr("Sure ?"), | 355 | tr("Sure ?"), |
356 | tr("Yes, break"), | 356 | tr("Yes, break"), |
357 | tr("No, don't break") ) == 0 ) { | 357 | tr("No, don't break") ) == 0 ) { |
358 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; | 358 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; |
359 | // break | 359 | // break |
360 | OT->removeLinkKey( KPIt->index() ); | 360 | OT->removeLinkKey( KPIt->index() ); |
361 | delete KPIt; | 361 | delete KPIt; |
362 | } | 362 | } |
363 | return; | 363 | return; |
364 | } | 364 | } |
365 | it= it->nextSibling(); | 365 | it= it->nextSibling(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | // | 369 | // |
370 | // | 370 | // |
371 | // | 371 | // |
372 | // | 372 | // |
373 | // | 373 | // |
374 | 374 | ||
375 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : | 375 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : |
376 | OTScanGUI( parent ), Filter() { | 376 | OTScanGUI( parent ), Filter() { |
377 | 377 | ||
378 | OT = OTGateway::getOTGateway(); | 378 | OT = OTGateway::getOTGateway(); |
379 | 379 | ||
380 | Icons = (_IC ) ? _IC : new OTIcons(); | 380 | Icons = (_IC ) ? _IC : new OTIcons(); |
381 | MyIcons = (_IC == 0 ); | 381 | MyIcons = (_IC == 0 ); |
382 | DetectedPeers_LV->header()->hide(); | 382 | DetectedPeers_LV->header()->hide(); |
383 | Current = 0; | 383 | Current = 0; |
384 | SelectedPeer = 0; | 384 | SelectedPeer = 0; |
385 | SelectedChannel = 0; | 385 | SelectedChannel = 0; |
386 | 386 | ||
387 | StrengthTimer = new QTimer( this ); | 387 | StrengthTimer = new QTimer( this ); |
388 | connect( StrengthTimer, | 388 | connect( StrengthTimer, |
389 | SIGNAL( timeout()), | 389 | SIGNAL( timeout()), |
390 | this, | 390 | this, |
391 | SLOT( SLOT_UpdateStrength()) | 391 | SLOT( SLOT_UpdateStrength()) |
392 | ); | 392 | ); |
393 | 393 | ||
394 | connect( OT, | 394 | connect( OT, |
395 | SIGNAL( detectedPeer( OTPeer *, bool )), | 395 | SIGNAL( detectedPeer( OTPeer *, bool )), |
396 | this, | 396 | this, |
397 | SLOT( SLOT_NewPeer( OTPeer *, bool )) | 397 | SLOT( SLOT_NewPeer( OTPeer *, bool )) |
398 | ); | 398 | ); |
399 | connect( OT, | 399 | connect( OT, |
400 | SIGNAL( finishedDetecting()), | 400 | SIGNAL( finishedDetecting()), |
401 | this, | 401 | this, |
402 | SLOT( SLOT_FinishedDetecting()) | 402 | SLOT( SLOT_FinishedDetecting()) |
403 | ); | 403 | ); |
404 | 404 | ||
405 | // populate with peers we already know about | 405 | // populate with peers we already know about |
406 | const PeerVector & P = OT->peers(); | 406 | const PeerVector & P = OT->peers(); |
407 | for( unsigned int i = 0; | 407 | for( unsigned int i = 0; |
408 | i < P.count(); | 408 | i < P.count(); |
409 | i ++ ) { | 409 | i ++ ) { |
410 | SLOT_NewPeer( P[i], TRUE ); | 410 | SLOT_NewPeer( P[i], TRUE ); |
411 | } | 411 | } |
412 | 412 | ||
413 | // populate State fram | 413 | // populate State fram |
414 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); | 414 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); |
415 | 415 | ||
416 | Paired_Led = new OLedBox( green, State_Frm ); | 416 | Paired_Led = new OLedBox( green, State_Frm ); |
417 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); | 417 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); |
418 | 418 | ||
419 | H->addWidget( Paired_Led ); | 419 | H->addWidget( Paired_Led ); |
420 | H->addWidget( L1 ); | 420 | H->addWidget( L1 ); |
421 | H->addStretch( 1 ); | 421 | H->addStretch( 1 ); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | OTScan::~OTScan() { | 425 | OTScan::~OTScan() { |
426 | if( MyIcons ) | 426 | if( MyIcons ) |
427 | delete Icons; | 427 | delete Icons; |
428 | OTGateway::releaseOTGateway(); | 428 | OTGateway::releaseOTGateway(); |
429 | 429 | ||
430 | // send all peers that we do not care about states | 430 | // send all peers that we do not care about states |
431 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 431 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
432 | while( Lit ) { | 432 | while( Lit ) { |
433 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); | 433 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); |
434 | Lit = Lit->nextSibling(); | 434 | Lit = Lit->nextSibling(); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
438 | // static scan dialog function | 438 | // static scan dialog function |
439 | int OTScan::getDevice( OTPeer *& Peer, | 439 | int OTScan::getDevice( OTPeer *& Peer, |
440 | int & Channel, | 440 | int & Channel, |
441 | OTGateway * OT, | 441 | OTGateway * OT, |
442 | const UUIDVector & Filter, | 442 | const UUIDVector & Filter, |
443 | QWidget* Parent ) { | 443 | QWidget* Parent ) { |
444 | bool IsUp = 0; | 444 | bool IsUp = 0; |
445 | unsigned int i; | 445 | unsigned int i; |
446 | 446 | ||
447 | if( ! OT->isEnabled() ) { | 447 | if( ! OT || ! OT->isEnabled() ) { |
448 | QMessageBox::warning( 0, | 448 | QMessageBox::warning( 0, |
449 | tr("Scanning problem"), | 449 | tr("Scanning problem"), |
450 | tr("Bluetooth not enabled" ) | 450 | tr("Bluetooth not enabled" ) |
451 | ); | 451 | ); |
452 | return QDialog::Rejected; | 452 | return QDialog::Rejected; |
453 | } | 453 | } |
454 | 454 | ||
455 | // check if bluetooth is up | 455 | // check if bluetooth is up |
456 | OTDriverList & DL = OT->getDriverList(); | 456 | OTDriverList & DL = OT->getDriverList(); |
457 | for( i = 0; | 457 | for( i = 0; |
458 | i < DL.count(); | 458 | i < DL.count(); |
459 | i ++ ) { | 459 | i ++ ) { |
460 | if( DL[i]->isUp() ) { | 460 | if( DL[i]->isUp() ) { |
461 | // one device that is up found | 461 | // one device that is up found |
462 | IsUp = 1; | 462 | IsUp = 1; |
463 | break; | 463 | break; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | // use this driver | 467 | // use this driver |
468 | OT->setScanWith( OT->driver(i) ); | 468 | OT->setScanWith( OT->driver(i) ); |
469 | 469 | ||
470 | // create dialog | 470 | // create dialog |
471 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); | 471 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); |
472 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 472 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
473 | OTScan * Scn = new OTScan( Dlg ); | 473 | OTScan * Scn = new OTScan( Dlg ); |
474 | 474 | ||
475 | connect( Scn, | 475 | connect( Scn, |
476 | SIGNAL( selected() ), | 476 | SIGNAL( selected() ), |
477 | Dlg, | 477 | Dlg, |
478 | SLOT( accept() ) | 478 | SLOT( accept() ) |
479 | ); | 479 | ); |
480 | 480 | ||
481 | if( Filter ) { | 481 | if( Filter ) { |
482 | Scn->setScanFilter( Filter ); | 482 | Scn->setScanFilter( Filter ); |
483 | } | 483 | } |
484 | 484 | ||
485 | V->addWidget( Scn ); | 485 | V->addWidget( Scn ); |
486 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); | 486 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); |
487 | Dlg->showMaximized(); | 487 | Dlg->showMaximized(); |
488 | int rv = Dlg->exec(); | 488 | int rv = Dlg->exec(); |
489 | 489 | ||
490 | if( rv == QDialog::Accepted ) { | 490 | if( rv == QDialog::Accepted ) { |
491 | // get peer | 491 | // get peer |
492 | Peer = Scn->selectedPeer(); | 492 | Peer = Scn->selectedPeer(); |
493 | if( Peer == 0 ) { | 493 | if( Peer == 0 ) { |
494 | // no peer selected | 494 | // no peer selected |
495 | rv = QDialog::Rejected; | 495 | rv = QDialog::Rejected; |
496 | } else { | 496 | } else { |
497 | Channel = Scn->selectedChannel(); | 497 | Channel = Scn->selectedChannel(); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | delete Dlg; | 501 | delete Dlg; |
502 | 502 | ||
503 | return rv; | 503 | return rv; |
504 | } | 504 | } |
505 | 505 | ||
506 | void OTScan::setScanFilter( const UUIDVector & V ) { | 506 | void OTScan::setScanFilter( const UUIDVector & V ) { |
507 | Filter = V; | 507 | Filter = V; |
508 | } | 508 | } |
509 | 509 | ||
510 | void OTScan::resetScanFilter( void ) { | 510 | void OTScan::resetScanFilter( void ) { |
511 | Filter.truncate(0); | 511 | Filter.truncate(0); |
512 | } | 512 | } |
513 | 513 | ||
514 | void OTScan::SLOT_DoScan( bool DoIt ) { | 514 | void OTScan::SLOT_DoScan( bool DoIt ) { |
515 | if( DoIt ) { | 515 | if( DoIt ) { |
516 | OT->scanNeighbourhood(); | 516 | OT->scanNeighbourhood(); |
517 | } else { | 517 | } else { |
518 | OT->stopScanOfNeighbourhood(); | 518 | OT->stopScanOfNeighbourhood(); |
519 | } | 519 | } |
520 | 520 | ||
521 | scanMode( DoIt ); | 521 | scanMode( DoIt ); |
522 | } | 522 | } |
523 | 523 | ||
524 | // double clicked on a device | 524 | // double clicked on a device |
525 | void OTScan::SLOT_Selected( QListViewItem * it ) { | 525 | void OTScan::SLOT_Selected( QListViewItem * it ) { |
526 | if( ! it ) | 526 | if( ! it ) |
527 | return; | 527 | return; |
528 | 528 | ||
529 | if( Filter.count() > 0 ) { | 529 | if( Filter.count() > 0 ) { |
530 | // filter on service | 530 | // filter on service |
531 | if( it->depth() == 0 ) { | 531 | if( it->depth() == 0 ) { |
532 | // select a service and not a device | 532 | // select a service and not a device |
533 | return; | 533 | return; |
534 | } | 534 | } |
535 | 535 | ||
536 | // store result | 536 | // store result |
537 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); | 537 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); |
538 | SelectedChannel = ((ChannelLVI *)it)->channel(); | 538 | SelectedChannel = ((ChannelLVI *)it)->channel(); |
539 | } else { | 539 | } else { |
540 | // click on device | 540 | // click on device |
541 | if( it->depth() != 0 ) { | 541 | if( it->depth() != 0 ) { |
542 | return; | 542 | return; |
543 | } | 543 | } |
544 | 544 | ||
545 | SelectedPeer = ((PeerLVI *)it)->peer(); | 545 | SelectedPeer = ((PeerLVI *)it)->peer(); |
546 | SelectedChannel = 0; | 546 | SelectedChannel = 0; |
547 | } | 547 | } |
548 | odebug << "Selected " << SelectedPeer->address().toString() << | 548 | odebug << "Selected " << SelectedPeer->address().toString() << |
549 | " Channel " << SelectedChannel << oendl; | 549 | " Channel " << SelectedChannel << oendl; |
550 | emit selected(); | 550 | emit selected(); |
551 | } | 551 | } |
552 | 552 | ||
553 | void OTScan::SLOT_FinishedDetecting( ) { | 553 | void OTScan::SLOT_FinishedDetecting( ) { |
554 | scanMode( false ); | 554 | scanMode( false ); |
555 | } | 555 | } |
556 | 556 | ||
557 | void OTScan::SLOT_CleanupOld( ) { | 557 | void OTScan::SLOT_CleanupOld( ) { |
558 | 558 | ||
559 | // iterate over all peers and find those that | 559 | // iterate over all peers and find those that |
560 | // are down and have no pairing info | 560 | // are down and have no pairing info |
561 | OTPeer * TheP; | 561 | OTPeer * TheP; |
562 | const LinkKeyArray & Keys = OT->getLinkKeys(); | 562 | const LinkKeyArray & Keys = OT->getLinkKeys(); |
563 | 563 | ||
564 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 564 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
565 | while( Lit ) { | 565 | while( Lit ) { |
566 | TheP = ((PeerLVI *)Lit)->peer(); | 566 | TheP = ((PeerLVI *)Lit)->peer(); |
567 | if( TheP->state() == OTPeer::Peer_Down ) { | 567 | if( TheP->state() == OTPeer::Peer_Down ) { |
568 | unsigned int k; | 568 | unsigned int k; |
569 | 569 | ||
570 | // what about linkkeys ? | 570 | // what about linkkeys ? |
571 | for( k = 0; k < Keys.count(); k ++ ) { | 571 | for( k = 0; k < Keys.count(); k ++ ) { |
572 | if( TheP->address() == Keys[k].to() || | 572 | if( TheP->address() == Keys[k].to() || |
573 | TheP->address() == Keys[k].from() | 573 | TheP->address() == Keys[k].from() |
574 | ) { | 574 | ) { |
575 | // part of linkkey | 575 | // part of linkkey |