I need it to properly implement the applet (which is where I
tested this code, BTW).
Let me know if the code is OK so that I can commit it to the
repository.
Index: src/amora.c
===================================================================
--- src/amora.c (revision 676)
+++ src/amora.c (working copy)
@@ -289,8 +289,7 @@
loop_remove(client_socket);
close(client_socket);
if (amora->disconn_callback)
- /* TODO: store device name during the first connection! */
- amora->disconn_callback(NULL);
+ amora->disconn_callback(amora->client_name);
return 0;
}
@@ -314,11 +313,12 @@
" exiting...");
else {
client_bluetooth_id(&rem_addr, buffer);
+ client_bluetooth_name(amora->device_socket, &rem_addr, amora->client_name);
log_message(FIL, amora->log, "Accepted connection. Client"
- " is %s", buffer);
+ " is %s [%s]", amora->client_name, buffer);
if (amora->conn_callback)
- amora->conn_callback(buffer);
+ amora->conn_callback(amora->client_name);
loop_add(client_socket, context, client_socket_cb);
}
@@ -382,7 +382,7 @@
/* Socket creation */
result->sd->hci_id = hci_device;
result->server_socket = build_bluetooth_socket(result->channel,
- result->sd);
+ result->sd, &(result->device_socket));
if (result->server_socket == -1) {
log_message(FIL|OUT, result->log, "Failed creating bluetooth "
"conn! Exiting...");
Index: src/linux.c
===================================================================
--- src/linux.c (revision 676)
+++ src/linux.c (working copy)
@@ -50,7 +50,6 @@
#include <fcntl.h>
#include <errno.h>
-
/** Linux sendfile is failing (probably I'm not using it correctly). */
#define STRANGE_BUG
@@ -83,7 +82,7 @@
}
}
-int build_bluetooth_socket(unsigned int channel, struct service_description *sd)
+int build_bluetooth_socket(unsigned int channel, struct service_description *sd,
+ int *device_socket)
{
struct sockaddr_rc loc_addr;
int s, res;
@@ -94,7 +93,7 @@
if (sd->hci_id == -1)
goto error;
- if (hci_open_dev(sd->hci_id) < 0)
+ if ((*device_socket = hci_open_dev(sd->hci_id)) < 0)
goto error;
else
hci_close_dev(sd->hci_id);
@@ -239,5 +239,14 @@
if (buffer)
ba2str(&(ptr->rc_bdaddr), buffer);
+}
+void client_bluetooth_name(int sock, struct sockaddr *client_address,
+ char *buffer)
+{
+ struct sockaddr_rc *ptr;
+ ptr = (struct sockaddr_rc*) client_address;
+
+ if (hci_read_remote_name(sock, &(ptr->rc_bdaddr), 256, buffer, 0) < 0) {
+ strcpy(buffer, "[unknown]");
+ }
}
Index: src/amora.h
===================================================================
--- src/amora.h (revision 676)
+++ src/amora.h (working copy)
@@ -30,8 +30,12 @@
int server_socket;
/** Client socket */
int client_socket;
+ /** Client name */
+ char client_name[256];
/** Default channel used by amora */
int channel;
+ /** Bluetooth device socket */
+ int device_socket;
/** Connection function callback */
void (*conn_callback) (const char *device_name);
/** Disconnectoin function callback */
@@ -167,5 +171,4 @@
void amora_disconnection_callback(struct amora_s *context,
void (*conn_cb) (const char *device_name));
-
#endif
Index: src/bluecode.h
===================================================================
--- src/bluecode.h (revision 676)
+++ src/bluecode.h (working copy)
@@ -117,11 +117,12 @@
*
* @param channel Number of channel to be used to export the server service.
* @param sd Service description structure pointer.
+ * @param device_socket Bluetooth Device socket
*
* @return Socket in success, -1 otherwise.
*/
int build_bluetooth_socket(unsigned int channel,
- struct service_description *sd);
+ struct service_description *sd, int *device_socket);
/** This functions talks with bluetooth daemon and registers the service
@@ -146,6 +147,15 @@
void client_bluetooth_id(struct sockaddr *client_address, char *buffer);
+/** Remote client name (human readable)
+ *
+ * @param sock Device Socket
+ * @param client_address Socket address peer socket pointer.
+ * @param buffer A string buffer to hold the device name (up to 256 chars)
+ */
+void client_bluetooth_name(int sock, struct sockaddr *client_address, char *name);
+
+
/** Copy a file content over other (use it to copy a file to a remote client
* socket).
*
--
Ademar de Souza Reis Jr. <ade...@ademar.org>
http://www.ademar.org/ || http://blog.ademar.org/
^[:wq!
BTW, amora-applet (wip branch) from my git repository is working fine
with this code, tests are also welcome:
http://git.ademar.org/gitweb.cgi?p=amora-applet.git
Cheers,
- Ademar
--
Ademar de Souza Reis Jr.
http://www.ademar.org/ || http://blog.ademar.org/
^[:wq!
On Fri, Mar 19, 2010 at 12:29:27PM -0200, Ademar de Souza Reis Jr. wrote:
> BTW, amora-applet (wip branch) from my git repository is working fine
> with this code, tests are also welcome:
> http://git.ademar.org/gitweb.cgi?p=amora-applet.git
Works fine for me, too.
I was only surprised that error messages looked like on Windows. But
this is probably Qt. ;-)
I though stumbled over an older issue already documented in the
sourcecode: It always tries to save amora-screenshot.png in the
current directory. This fails if the current directory is not
writable. (Started a not installed version of amorad-gui under some
test user because my default user has no panel to test with. :-)
As written in the source code we should use /tmp and mktemp(3) or so
for that. I'll have a look into that.
Regards, Axel
--
Axel Beckert - a...@deuxchevaux.org, a...@noone.org - http://noone.org/abe/
I've tested the patch and everything seems ok. Ship it!
:-)
Regards
Adenilson
On Fri, Mar 19, 2010 at 10:29 AM, Ademar de Souza Reis Jr.
> --
> You received this message because you are subscribed to the Google Groups "Amora Developers" group.
> To post to this group, send email to amora...@googlegroups.com.
> To unsubscribe from this group, send email to amora-devel...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/amora-devel?hl=en.
>
>
I just committed the fix for an old todo, since I ran into it because
of the current directory not being writable: The screenshot files are
now saved into /tmp/amora-XXXXXX/screenshot.png whereas XXXXXX is
filled with random stuff.
They're also cleaned up afterwards now.
On Fri, Mar 19, 2010 at 12:29:27PM -0200, Ademar de Souza Reis Jr. wrote:
> I'm attaching the patch to ease the testing by whoever is interested in.
I found two minor issues with the cli client:
a) It now shows only the name, but no more the MAC address. Would be
happy to (optionally) see both.
b) I see "Client is: ..." on both, connects and disconnects, but I
can't distinguish them at that point. I think we should prefix this
with "Connect:" and "Disconnect:" or so.
P.S.: Google Code seems to have quite some issues with SVN currently.
Had to do workarounds like "until svn up; do sleep 10; done" and the
like...
On Fri, Mar 19, 2010 at 12:29:27PM -0200, Ademar de Souza Reis Jr. wrote:
> BTW, amora-applet (wip branch) from my git repository is working fine
> with this code, tests are also welcome:
> http://git.ademar.org/gitweb.cgi?p=amora-applet.git
You seem to have committed more or less what was in the WIP branch and
according to the README it's usable and publishable.
So I would like to package the version currently in SVN and upload it
to Debian after a few basic tests. In your opinion: Is it ready for a
broader user base? At least for me it looked fine.
It will have to go through the NEW queue since from the formerly one
binary package, there will be now two binary packages, i.e. at least
one new package name. Hopefully it will go through faster than the
last time.
On Sat, Mar 20, 2010 at 08:07:54PM +0100, Axel Beckert wrote:
> On Fri, Mar 19, 2010 at 12:29:27PM -0200, Ademar de Souza Reis Jr. wrote:
> > BTW, amora-applet (wip branch) from my git repository is working fine
> > with this code, tests are also welcome:
> > http://git.ademar.org/gitweb.cgi?p=amora-applet.git
>
> You seem to have committed more or less what was in the WIP branch and
> according to the README it's usable and publishable.
>
> So I would like to package the version currently in SVN and upload it
> to Debian after a few basic tests. In your opinion: Is it ready for a
> broader user base? At least for me it looked fine.
One thing: The version number seems to be (yet) missing:
$ ./amorad-gui -v
amora-applet (unspecified version)
Yes, it's ready for a broader audience. I don't have anything in my
TODO right now which is specific to the applet.
Cheers,
- Ademar
--
Unfortunately the library doesn't provide its version
programatically... So -v is actually a placeholder (which may be
worth removing if there are no plans to add this to libamora).
Cheers,
- Ademar
--
I see... libamora callback should include two parameters: the name
and bt-address. The callback was documented as returning the name
but was sending the address. By fixing the TODO entry I broke a
mis-feature :-)
>
> b) I see "Client is: ..." on both, connects and disconnects, but I
> can't distinguish them at that point. I think we should prefix this
> with "Connect:" and "Disconnect:" or so.
I commited an improvement for that, but it was just a
trivial change. Maybe it would be worth investing some time
refining the messages (in particular, it shows this message on
stderr, which is wrong, IMO).
>
> P.S.: Google Code seems to have quite some issues with SVN currently.
> Had to do workarounds like "until svn up; do sleep 10; done" and the
> like...
Time to move to git? :-)
Cheers,
- Ademar
--