-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 6e5ee82..94e29c7 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -52,43 +52,41 @@ namespace OpieTooth { | |||
52 | setFixedHeight( 18 ); | 52 | setFixedHeight( 18 ); |
53 | setFixedWidth( 14 ); | 53 | setFixedWidth( 14 ); |
54 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); | 54 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); |
55 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); | 55 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); |
56 | // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); | 56 | // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); |
57 | startTimer(5000); | 57 | startTimer(5000); |
58 | timerEvent(NULL); | 58 | btDevice = 0; |
59 | |||
59 | } | 60 | } |
60 | 61 | ||
61 | BluezApplet::~BluezApplet() { | 62 | BluezApplet::~BluezApplet() { |
62 | } | 63 | } |
63 | 64 | ||
64 | int BluezApplet::checkBluezStatus() { | 65 | int BluezApplet::checkBluezStatus() { |
65 | if (btDevice) { | 66 | if (btDevice) { |
66 | if (btDevice->isLoaded() ) { | 67 | if (btDevice->isLoaded() ) { |
67 | return 1; | 68 | return 1; |
69 | } else { | ||
70 | return 0; | ||
71 | } | ||
68 | } else { | 72 | } else { |
69 | return 0; | 73 | return 0; |
70 | } | 74 | } |
71 | } else { | ||
72 | return 0; | ||
73 | } | ||
74 | } | 75 | } |
75 | 76 | ||
76 | int BluezApplet::setBluezStatus(int c) { | 77 | int BluezApplet::setBluezStatus(int c) { |
77 | 78 | ||
78 | if (c == 1) { | 79 | if (c == 1) { |
79 | btDevice = new Device("/dev/ttySB0", "csr" ); | 80 | btDevice = new Device("/dev/ttySB0", "csr" ); |
80 | // system("hciattach /dev/ttySB0 csr"); | ||
81 | //system("hcid"); | ||
82 | } else { | 81 | } else { |
83 | if (btDevice) { | 82 | if (btDevice) { |
84 | delete btDevice; | 83 | delete btDevice; |
84 | btDevice = 0; | ||
85 | } | 85 | } |
86 | //system("killall hciattach"); | 86 | } |
87 | //system("killall hcid"); | ||
88 | } | ||
89 | return 0; | 87 | return 0; |
90 | } | 88 | } |
91 | 89 | ||
92 | int BluezApplet::checkBluezDiscoveryStatus() { | 90 | int BluezApplet::checkBluezDiscoveryStatus() { |
93 | } | 91 | } |
94 | 92 | ||
@@ -119,44 +117,40 @@ namespace OpieTooth { | |||
119 | 117 | ||
120 | if (bluezDiscoveryActive) { | 118 | if (bluezDiscoveryActive) { |
121 | menu->insertItem( tr("Disable discovery"), 3 ); | 119 | menu->insertItem( tr("Disable discovery"), 3 ); |
122 | } else { | 120 | } else { |
123 | menu->insertItem( tr("Enable discovery"), 4 ); | 121 | menu->insertItem( tr("Enable discovery"), 4 ); |
124 | } | 122 | } |
125 | //menu->insertItem( tr("More..."), 7 ) | 123 | |
126 | 124 | ||
127 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | 125 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); |
128 | ret = menu->exec(p, 0); | 126 | ret = menu->exec(p, 0); |
129 | 127 | ||
130 | // qDebug("ret was %d\n", ret); | ||
131 | |||
132 | switch(ret) { | 128 | switch(ret) { |
133 | case 0: | 129 | case 0: |
134 | setBluezStatus(0); | 130 | setBluezStatus(0); |
135 | timerEvent(NULL); | ||
136 | break; | 131 | break; |
137 | case 1: | 132 | case 1: |
138 | setBluezStatus(1); | 133 | setBluezStatus(1); |
139 | timerEvent(NULL); | ||
140 | break; | 134 | break; |
141 | case 2: | 135 | case 2: |
142 | // start bluetoothmanager | 136 | // start bluetoothmanager |
143 | launchManager(); | 137 | launchManager(); |
144 | timerEvent(NULL); | ||
145 | break; | 138 | break; |
146 | case 3: | 139 | case 3: |
147 | setBluezDiscoveryStatus(0); | 140 | setBluezDiscoveryStatus(0); |
148 | timerEvent(NULL); | ||
149 | break; | 141 | break; |
150 | case 4: | 142 | case 4: |
151 | setBluezDiscoveryStatus(1); | 143 | setBluezDiscoveryStatus(1); |
152 | timerEvent(NULL); | ||
153 | break; | 144 | break; |
154 | //case 7: | 145 | //case 7: |
155 | // With table of currently-detected devices. | 146 | // With table of currently-detected devices. |
156 | } | 147 | } |
148 | |||
149 | timerEvent(NULL); | ||
150 | delete signal; | ||
157 | delete menu; | 151 | delete menu; |
158 | } | 152 | } |
159 | 153 | ||
160 | 154 | ||
161 | /** | 155 | /** |
162 | * Launches the bluetooth manager | 156 | * Launches the bluetooth manager |