Add support for SetFolder in MAP client
Subsystems (2)
PATCH 1/4 Add support for SetFolder in MAP client
--- client/map.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/client-api.txt | 5 +++- 2 files changed, 60 insertions(+), 1 deletions(-)
client/map.c +56 -0
@@ -49,7 +49,63 @@ struct map_data {static DBusConnection *conn =NULL ; +static void simple_cb (GObex *obex,GError *err,GObexPacket *rsp, +gpointer user_data) +{ +DBusMessage *reply; +struct map_data *map = user_data; +guint8 err_code =g_obex_packet_get_operation (rsp,NULL ); + +if (err !=NULL ) + reply =g_dbus_create_error (map->msg, +"org.openobex.Error.Failed" , +"%s" , err->message); +else if (err_code !=G_OBEX_RSP_SUCCESS ) + reply =g_dbus_create_error (map->msg, +"org.openobex.Error.Failed" , +"%s (0x%02x)" , +g_obex_strerror (err_code), + err_code); +else + reply =dbus_message_new_method_return (map->msg); + +g_dbus_send_message (conn, reply); +dbus_message_unref (map->msg); +} + +static DBusMessage *map_setpath (DBusConnection *connection, +DBusMessage *message,void *user_data) +{ +struct map_data *map = user_data; +const char *folder; +GObex *obex; +GError *err =NULL ; + +if (dbus_message_get_args (message,NULL ,DBUS_TYPE_STRING , &folder, +DBUS_TYPE_INVALID ) == FALSE) +return g_dbus_create_error (message, +"org.openobex.Error.InvalidArguments" , +NULL ); + + obex =obc_session_get_obex (map->session); + +g_obex_setpath (obex, folder, simple_cb, map, &err); +if (err !=NULL ) { +DBusMessage *reply; + reply =g_dbus_create_error (message, +"org.openobex.Error.Failed" , +"%s" , err->message); +g_error_free (err); +return reply; + } + + map->msg =dbus_message_ref (message); + +return NULL ; +} +static GDBusMethodTable map_methods[] = { + {"SetFolder" ,"s" ,"" , map_setpath,G_DBUS_METHOD_FLAG_ASYNC }, { } };
doc/client-api.txt +4 -1
@@ -258,7 +258,10 @@ Service org.openobex.client Interface org.openobex.MessageAccess Object path [variable prefix]/{session0,session1,...} -Methods +Methods void SetFolder(string name) + + Set working directory for current session, *name* may + be the directory name or '..[/dir]'. Transfer hierarchy ==================
Signature · 1 line
1.7.4.1
PATCH 2/4 Add simple helper for MAP client
--- Makefile.am | 3 ++- test/map-client | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletions(-) create mode 100755 test/map-client
Makefile.am +2 -1
@@ -9,7 +9,8 @@ doc_files = doc/obexd-api.txt doc/agent-api.txt doc/client-api.txt test_files = test/simple-agent test/send-files \ test/pull-business-card test/exchange-business-cards \ - test/list-folders test/pbap-client test/ftp-client + test/list-folders test/pbap-client test/ftp-client \ + test/map-client gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/watch.c \ gdbus/object.c gdbus/polkit.c
test/map-client new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 3/4 Add basic support for MAP folder listing
In reply to Bartosz SzatkowskiFor now just basic functionality - returning whole listing as a string (no parsing for now) and no apparams handling.
--- client/map.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- test/map-client | 5 +++++ 2 files changed, 58 insertions(+), 1 deletions(-)
client/map.c +53 -1
@@ -104,8 +104,60 @@ static DBusMessage *map_setpath(DBusConnection *connection,return NULL ; } +static void buffer_cb (struct obc_session *session,GError *err, +void *user_data) +{ +struct obc_transfer *transfer =obc_session_get_transfer (session); +struct map_data *map = user_data; +DBusMessage *reply; +const char *buf; +int size; + +if (err !=NULL ) { + reply =g_dbus_create_error (map->msg, +"org.openobex.Error.Failed" , +"%s" , err->message); + goto done; + } + + buf =obc_transfer_get_buffer (transfer, &size); +if (size ==0 ) + buf ="" ; + + reply =g_dbus_create_reply (map->msg,DBUS_TYPE_STRING , &buf, +DBUS_TYPE_INVALID ); + +obc_transfer_clear_buffer (transfer); + +done: +g_dbus_send_message (conn, reply); +dbus_message_unref (map->msg); +obc_transfer_unregister (transfer); +} + +static DBusMessage *map_get_folder_listing (DBusConnection *connection, +DBusMessage *message,void *user_data) +{ +struct map_data *map = user_data; +int err; + + err =obc_session_get (map->session,"x-obex/folder-listing" , +NULL ,NULL ,NULL ,0 , + buffer_cb, map); +if (err <0 ) +return g_dbus_create_error (message,"org.openobex.Error.Failed" , +NULL ); + + map->msg =dbus_message_ref (message); + +return NULL ; +} +static GDBusMethodTable map_methods[] = { - {"SetFolder" ,"s" ,"" , map_setpath,G_DBUS_METHOD_FLAG_ASYNC }, + {"SetFolder" ,"s" ,"" , map_setpath, +G_DBUS_METHOD_FLAG_ASYNC }, + {"GetFolderListing" ,"a{ss}" ,"s" , map_get_folder_listing, +G_DBUS_METHOD_FLAG_ASYNC }, { } };
test/map-client +5 -0
@@ -11,6 +11,8 @@ def parse_options(): help="Device to connect", metavar="DEVICE") parser.add_option("-c", "--chdir", dest="new_dir", help="Change current directory to DIR", metavar="DIR") + parser.add_option("-l", "--lsdir", action="store_true", dest="ls_dir", + help="List folders in current directory") parser.add_option("-v", "--verbose", action="store_true", dest="verbose") return parser.parse_args()
@@ -49,4 +51,7 @@ if __name__ == '__main__': if options.new_dir: set_folder(map, options.new_dir) + if options.ls_dir: + print map.GetFolderListing(dict()) + mainloop.run()
Signature · 1 line
1.7.4.1
PATCH 4/4 Add support for PullMessagesListing in MAP client
In reply to Bartosz SzatkowskiJust basic functionality for now, returning whole listing as a string (no parsing) and no apparams handling.
--- client/map.c | 30 ++++++++++++++++++++++++++++++ test/map-client | 5 +++++ 2 files changed, 35 insertions(+), 0 deletions(-)
client/map.c +30 -0
@@ -153,11 +153,41 @@ static DBusMessage *map_get_folder_listing(DBusConnection *connection,return NULL ; } +static DBusMessage *map_get_messages_listing (DBusConnection *connection, +DBusMessage *message,void *user_data) +{ +struct map_data *map = user_data; +int err; +const char *folder; +DBusMessageIter msg_iter; + +dbus_message_iter_init (message, &msg_iter); + +if (dbus_message_iter_get_arg_type (&msg_iter) !=DBUS_TYPE_STRING ) +return g_dbus_create_error (message, +"org.openobex.Error.InvalidArguments" ,NULL ); + +dbus_message_iter_get_basic (&msg_iter, &folder); + + err =obc_session_get (map->session,"x-bt/MAP-msg-listing" , folder, +NULL ,NULL ,0 , + buffer_cb, map); +if (err <0 ) +return g_dbus_create_error (message,"org.openobex.Error.Failed" , +NULL ); + + map->msg =dbus_message_ref (message); + +return NULL ; +} +static GDBusMethodTable map_methods[] = { {"SetFolder" ,"s" ,"" , map_setpath,G_DBUS_METHOD_FLAG_ASYNC }, {"GetFolderListing" ,"a{ss}" ,"s" , map_get_folder_listing,G_DBUS_METHOD_FLAG_ASYNC }, + {"GetMessagesListing" ,"sa{ss}" ,"s" , map_get_messages_listing, +G_DBUS_METHOD_FLAG_ASYNC }, { } };
test/map-client +5 -0
@@ -14,6 +14,8 @@ def parse_options(): parser.add_option("-l", "--lsdir", action="store_true", dest="ls_dir", help="List folders in current directory") parser.add_option("-v", "--verbose", action="store_true", dest="verbose") + parser.add_option("-L", "--lsmsg", action="store", dest="ls_msg", + help="List messages in supplied CWD subdir") return parser.parse_args()
@@ -54,4 +56,7 @@ if __name__ == '__main__': if options.ls_dir: print map.GetFolderListing(dict()) + if options.ls_msg is not None: + print map.GetMessagesListing(options.ls_msg, dict()) + mainloop.run()
Signature · 1 line
1.7.4.1
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Hi Bartosz,
client/map.c static DBusMessage *map_get_folder_listing(DBusConnection *connection, · line 190
Quoted 2 lines · Bartosz Szatkowski
client/map.c +2
-0+ {"GetMessagesListing" ,"sa{ss}" ,"s" , map_get_messages_listing, + G_DBUS_METHOD_FLAG_ASYNC },
The name should be GetMessageListing and not GetMessagesListing (the latter isn't really proper english). I went ahead and changed it through a separate patch since I didn't notice before having already applied your patch. Also, all this seems to be missing from the API documentation (doc/*). Please send a patch for that.
Johan
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Hi,
Quoted 6 lines · Johan Hedberg
client/map.c static DBusMessage *map_get_folder_listing(DBusConnection *connection, · line 190
Quoted 2 lines · Bartosz Szatkowski
client/map.c +2
-0+ {"GetMessagesListing" ,"sa{ss}" ,"s" , map_get_messages_listing, + G_DBUS_METHOD_FLAG_ASYNC },The name should be GetMessageListing and not GetMessagesListing (the latter isn't really proper english).
And now I notice that the spec. actually uses the plural form (which still sounds to me like strange English). All this fuss could have been avoided if we had had a proper discussion of the API beforehand and had the documentation in place before these patches.
Johan
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Quoted 10 lines · Johan Hedberg
Hi,
Quoted 6 lines · Johan Hedberg
Quoted 2 lines · Bartosz Szatkowski
+ { "GetMessagesListing", "sa{ss}", "s", map_get_messages_listing,
+G_DBUS_METHOD_FLAG_ASYNC},The name should be GetMessageListing and not GetMessagesListing (the latter isn't really proper english).
Quoted 6 lines
And now I notice that the spec. actually uses the plural form (which still sounds to me like strange English). All this fuss could have been avoided if we had had a proper discussion of the API beforehand and had the documentation in place before these patches.
Johan
I've sent API before I've started to work on patches - only Luiz responded, and there was discussion on other matters ...
Signature · 2 lines
Pozdrowienia - Cheers, Bartosz Szatkowski
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Hi Bartosz,
Quoted 2 lines · Bartosz Szatkowski
I've sent API before I've started to work on patches - only Luiz responded, and there was discussion on other matters ...
It seems I've forgotten to apply the API patch then. Can you point me to the email subject so we can get this into the tree?
Johan
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Hi,
Quoted 6 lines · Johan Hedberg
Quoted 2 lines · Bartosz Szatkowski
I've sent API before I've started to work on patches - only Luiz responded, and there was discussion on other matters ...
It seems I've forgotten to apply the API patch then. Can you point me to the email subject so we can get this into the tree?
Nevermind. I noticed from your other email that there's no such patch (yet).
Johan
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
In reply to Johan HedbergQuoted 11 lines · Johan Hedberg
Hi Bartosz,
Quoted 2 lines · Bartosz Szatkowski
+ { "GetMessagesListing", "sa{ss}", "s", map_get_messages_listing,
+G_DBUS_METHOD_FLAG_ASYNC},The name should be GetMessageListing and not GetMessagesListing (the latter isn't really proper english). I went ahead and changed it through a separate patch since I didn't notice before having already applied your patch. Also, all this seems to be missing from the API documentation (doc/*). Please send a patch for that.
The function name is "GetMessagesListing" in spec.
There is no doc as at the moment there is no apparams handling and no xml parsing, so I'll send patch with doc when we reach full functionality.
Signature · 2 lines
Pozdrowienia - Cheers, Bartosz Szatkowski
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Hi Bartosz,
Quoted 10 lines · Bartosz Szatkowski
Quoted 5 lines
The name should be GetMessageListing and not GetMessagesListing (the latter isn't really proper english). I went ahead and changed it through a separate patch since I didn't notice before having already applied your patch. Also, all this seems to be missing from the API documentation (doc/*). Please send a patch for that.
The function name is "GetMessagesListing" in spec.
There is no doc as at the moment there is no apparams handling and no xml parsing, so I'll send patch with doc when we reach full functionality.
So the plan is to return something else than the raw XML that MAP provides? In that case I don't think it's necessary to hold on to the exact spec naming of these functions. E.g. GetMessages or GetMessageList might make more sense in the case that you return a pre-parsed list/structure of some kind.
Johan
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Quoted 14 lines · Johan Hedberg
Hi Bartosz,
Quoted 10 lines · Bartosz Szatkowski
Quoted 5 lines
The name should be GetMessageListing and not GetMessagesListing (the latter isn't really proper english). I went ahead and changed it through a separate patch since I didn't notice before having already applied your patch. Also, all this seems to be missing from the API documentation (doc/*). Please send a patch for that.
The function name is "GetMessagesListing" in spec.
There is no doc as at the moment there is no apparams handling and no xml parsing, so I'll send patch with doc when we reach full functionality.
Quoted 7 lines
So the plan is to return something else than the raw XML that MAP provides? In that case I don't think it's necessary to hold on to the exact spec naming of these functions. E.g. GetMessages or GetMessageList might make more sense in the case that you return a pre-parsed list/structure of some kind.
Johan
We planned to return dict {field: value}. Generally I don't care much about this name - we can go with GetMessageListing, as I seem to use both forms without noticing it anyway.
Signature · 2 lines
Pozdrowienia - Cheers, Bartosz Szatkowski
Luiz Augusto von Dentz
maintainerRe: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Hi Bartosz,
Quoted 7 lines · Bartosz Szatkowski
Quoted 7 lines
So the plan is to return something else than the raw XML that MAP provides? In that case I don't think it's necessary to hold on to the exact spec naming of these functions. E.g. GetMessages or GetMessageList might make more sense in the case that you return a pre-parsed list/structure of some kind.
Quoted 5 lines
Quoted 1 line
Johan
We planned to return dict {field: value}. Generally I don't care much about this name - we can go with GetMessageListing, as I seem to use both forms without noticing it anyway.
Are there still plans to continue this work? I would like to change this method to return a dictionary like we do for pbap and perhaps unify this in a single listing so we do folder + messages.
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH obexd 4/4] Add support for PullMessagesListing in MAP client
Quoted 16 lines · Luiz Augusto von Dentz
Hi Bartosz,
Quoted 7 lines · Bartosz Szatkowski
Quoted 7 lines
So the plan is to return something else than the raw XML that MAP provides? In that case I don't think it's necessary to hold on to the exact spec naming of these functions. E.g. GetMessages or GetMessageList might make more sense in the case that you return a pre-parsed list/structure of some kind.
Quoted 5 lines
Quoted 1 line
Johan
We planned to return dict {field: value}. Generally I don't care much about this name - we can go with GetMessageListing, as I seem to use both forms without noticing it anyway.
Quoted 7 lines
Are there still plans to continue this work? I would like to change this method to return a dictionary like we do for pbap and perhaps unify this in a single listing so we do folder + messages.
--
Luiz Augusto von Dentz
Hi Luiz,
since January I'm not longer Comarch employee - so you probably should ask Sławek/Radek/Łukasz whether they're planing to continue work on it.
Signature · 2 lines
Cheers, Bartosz Szatkowski
Hi Bartosz,
Quoted 4 lines · Bartosz Szatkowski
--- client/map.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/client-api.txt | 5 +++- 2 files changed, 60 insertions(+), 1 deletions(-)
All four patches have been applied. Thanks.
Johan