Changeset 34
- Timestamp:
- 09/05/07 15:09:23 (15 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
ChangeLog (modified) (1 diff)
-
fuse/obexautofs.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r33 r34 1 1 2007-09-05 Christian W. Zuckschwerdt <zany@triq.net> 2 2 3 * Removing Bluez dependency 3 4 * Switching ObexFTP to pkg-config 4 5 -
trunk/fuse/obexautofs.c
r32 r34 47 47 #include <sys/socket.h> 48 48 49 #include <bluetooth/bluetooth.h>50 #include <bluetooth/hci.h>51 #include <bluetooth/hci_lib.h>52 53 49 #include <obexftp/obexftp.h> 54 50 #include <obexftp/client.h> … … 136 132 static int discover_bt(void) 137 133 { 138 inquiry_info *info = NULL; 139 bdaddr_t bdswap; 140 char name[248], *bastr; 141 int dev_id = 0; 142 int num_rsp = 10; 143 int flags = 0; 144 int length = 8; 145 int dd, i; 134 char *hci = NULL; 135 char **devs, **dev, *name; 146 136 connection_t *conn; 147 137 148 138 DEBUG("Scanning ...\n"); 149 num_rsp = hci_inquiry(dev_id, length, num_rsp, NULL, &info, flags);150 151 if( num_rsp < 0) {139 devs = obexftp_discover_bt_src(hci); 140 141 if(!devs) { 152 142 perror("Inquiry failed."); 153 143 return -1; 154 144 } 155 156 if ((dd = hci_open_dev(dev_id)) < 0) {157 perror("HCI device open failed");158 free(info);159 return -1;160 }161 145 162 for(i = 0; i < num_rsp; i++) { 163 memset(name, 0, sizeof(name)); 164 165 baswap(&bdswap, &(info+i)->bdaddr); 166 bastr = batostr(&bdswap); 167 168 if(hci_read_remote_name(dd, &(info+i)->bdaddr, sizeof(name), name, 10000) < 0) { 169 strcpy(name, bastr); 170 } 171 146 for(dev = devs; dev && *dev; dev++) { 172 147 for (conn = connections; conn; conn = conn->next) { 173 if (!strcmp(conn->addr, bastr)) {148 if (!strcmp(conn->addr, *dev)) { 174 149 conn->recent++; 175 150 break; … … 178 153 179 154 if (!conn) { 180 DEBUG("Adding\t%s\t%s\n", bastr, name); 155 name = obexftp_bt_name_src(*dev, hci); 156 DEBUG("Adding\t%s\t%s\n", *dev, name); 181 157 conn = calloc(1, sizeof(connection_t)); 182 158 if (!conn) 183 159 return -1; 184 conn->alias = strdup(name);160 conn->alias = name; 185 161 conn->transport = OBEX_TRANS_BLUETOOTH; 186 conn->addr = bastr;162 conn->addr = *dev; 187 163 conn->channel = obexftp_browse_bt_ftp(conn->addr); 188 //conn->cli = cli_open(OBEX_TRANS_BLUETOOTH, batostr(&bdswap), 5);164 //conn->cli = cli_open(OBEX_TRANS_BLUETOOTH, conn->addr, conn->channel); 189 165 conn->recent++; 190 166 conn->next = connections; 191 167 connections = conn; 192 168 } else 193 free( bastr);169 free(*dev); 194 170 } 195 171 196 close(dd); 197 free(info); 198 172 free(devs); 199 173 return 0; 200 174 }
