libiphone 1.0 API cleanup
-
Nikias Bassen
That all sounds reasonable, however I'd like to know what in your opinion is not good with the NotificationProxy interface, perhaps we can improve it.
I designed it to be as simple as possible ;) -
Martin S.
@nikias: As talked about, only exposing a callback way to grab notifications seems more elegant.
For lockdownd_ we might as well go straight with the request type of API:
All other public methods would be gone. :)lockdownd_client_t lockdownd_new_client(iphone_device_t phone); iphone_error_t lockdownd_recv(lockdownd_client_t client, plist_tplist) iphone_error_t lockdownd_send(lockdownd_client_t client, plist_t plist) iphone_error_t lockdownd_free_client(lockdownd_client_t client) iphone_error_t lockdownd_query_type(lockdownd_client_t client) iphone_error_t lockdownd_get_value(lockdownd_client_t client, char domain, char key, plist_t value) iphone_error_t lockdownd_set_value(lockdownd_client_t client, char domain, char key, plist_t value) iphone_error_t lockdownd_remove_value(lockdownd_client_t client, char domain, char key) iphone_error_t lockdownd_enter_recovery(lockdownd_client_t client) iphone_error_t lockdownd_goodbye(lockdownd_client_t client) iphone_error_t lockdownd_start_service(lockdownd_client_t client, const char service, int port) iphone_error_t lockdownd_start_session(lockdownd_client_t client, char *session_id) iphone_error_t lockdownd_stop_session(lockdownd_client_t client, char session_id)
iphone_error_t lockdownd_pair(lockdownd_client_t client, char device_id, char host_id) iphone_error_t lockdownd_unpair(lockdownd_client_t client, char device_id, char host_id) iphone_error_t lockdownd_validate_pair(lockdownd_client_t client, char device_id, char host_id) ? TBD iphone_error_t lockdownd_activate() ? TBD iphone_error_t lockdownd_deactivate()
Convenience: iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t client, char uid) iphone_error_t lockdownd_get_device_name(iphone_lckd_client_t client, char device_name)
I'll see to cook some patches once everything else is pushed to Matt's repo. -
Nikias Bassen
- State changed from new to open
Here are two patches for AFC and NotificationProxy that make them API 1.0 compatible. As stated above by Martin a little rework of AFC was needed; I did that already, see ticket #55 [PATCH] afc cleanup + full (sym)link support + special files.
All patches attached have to be applied after applying the patches from Ticket #55 [PATCH] afc cleanup + full (sym)link support + special files
As the name says, 0004-iFuse-adaption-to-AFC-API-change.patch is to make iFuse work with the new API.
-
Nikias Bassen
The iFuse patch is not working for some strange reason; here it is again.
-
Matt Colyer
These are pretty large changes, do they look good to everyone else before I apply them?
-
Jonathan Beck
Shouldn't we keep libiphone/libiphone.h a meta-headers thats includes all protocols (and move error definitions to libiphone/errors.h) ?
Other than that those patches are ok to me.
-
Martin S.
Yes, all fine and working.
I've rewrote/cleaned up the lockdown API as explained above, too.
Some changes:
- rename functions to further stick to the request protocol
- move common request result checking code into helper (thanks Nikias)
- update tools and iFuse to use the new API
- expose the lockdown API within own header
- fix doc comments
- fix some compiler warnings
Please apply to libiphone and iFuse after the patches from Nikias.
-
Martin S.
Reposted patches for above comment due to issues with lighthouse. Patches for mobilesync coming...
-
Martin S.
Further patch for libiphone to make use of the new plist_copy() function and remove the workaround/hack.
-
Martin S.
Below the last patch to cleanup the MobileSync API, too.
Changes:
- Update API, expose it with own header and update SWIG bindings accordingly
- Do not expose get_all_contacts(), move it into msyncclient for now (it was rather a testing function)
Last bits that need work/discussion:
- Error codes: Like the individual service API's it appears we have also error codes from different domains (usbmux, iphone_device, lockdownd, afc, ...). Those should be moved and maintained within the individual service header instead. This is of particular interest for the AFC API since we could handle errors more elegantly for the consumer (now there is this errno conversion hack and unspecific IPHONE_E_AFC_ERROR). There might be better programming patterns for error handling, feedback welcome.
- libiphone.h: This might better be called "device.h" as it basically manages the device struct. What might be missing is a function to get all connected uuid's so consumers (like iphone_id for instance) would not have to use/know usbmuxd.h and simply go ahead with what's provided by libiphone.
- *_new_client(): Do the constructors really require a dst_port parameter? How about if they do the lockdownd_start_service() on their own and return errors/success instead of the consumer having to handle starting the service?
- @Jonathan: "keep libiphone/libiphone.h a meta-headers ... move error definitions to libiphone/errors.h", once the API is cleaned up, we might as well put everything in one header like before. However, considering the architecture talks/model, individual headers have their benefits in the longterm.
- I would propose moving "distributable/working/useful" tools (iphone_id, iphoneinfo, iphonesyslog, ...) into libiphone/tools/, make them installed by default and keep testing tools in libiphone/dev strictly as "noinst_*".
Once things get pushed to Matt's repo we'll be really close to 1.0 I guess and I'll focus on two-way mobilesync... :)
-
Martin S.
Further consecutive attached patch adds the following lockdownd request protocol API functions:
- lockdownd_set_value(): Sets values or full preference plists
- lockdownd_remove_value(): Removes values or preference node trees from the device
- lockdownd_enter_recovery(): Makes the device enter recovery mode (with the iTunes cable plug displayed)
-
Matt Colyer
- State changed from open to resolved
(from [0be7debdc3b08e07b7f8bc2e32fed6aed587e09d]) Implement lockdown set_value, remove_value and enter_recovery request API
[#46 libiphone 1.0 API cleanup state:resolved]
Signed-off-by: Matt Colyer matt@colyer.name
http://github.com/MattColyer/libiphone/commit/0be7debdc3b08e07b7f8b... -
Martin S.
- State changed from resolved to open
Sorry, have to reopen as some stuff is not quite right yet.
Patches below address:
- iphoneinfo now uses less code due to lockdownd_get_value()
- The mobilesync API update was missing a header
I'll also supply last patches to divide the tools into distributed and noinst_* ones and to fix the error system.
Also as Jonathan noted, the plist dependency must be bumped to at least 0.13.
Then the API should be fresh and clean (and possible to keep it like that past 1.0+). :) -
Nikias Bassen
Here's another patch for AFC for afc_lock_file. As only non-blocking locks are supported, I defined a type afc_lock_op_t with all allowed lock operations.
-
teuf
Not sure at all this belongs here, but libiphone git with these patches applied misses a prototype for iphone_get_uuid in libiphone.h (either that, or this function isn't needed and can be removed). Sorry for the noise if this is not the right ticket to mention this issue.
-
Martin S.
@teuf: Right bug for this. :)
However I am preparing a huge changeset (172kb), currently splitting it into small commits. Got your issue handled there and exposing it as iphone_device_get_uuid().
-
Martin S.
As noted before I splitted out the error code definitions among services now.
Services return an error type in their own domain now, e.g.: mobilesync_error_tDue to looking into the errors I was also able to fix the AFC error code chain.
Now iFuse should be able to report more accurate AFC errors aswell.I also updated all affected tools/consumers and improved error reporting overall.
See the following posts for details.
-
Martin S.
libiphone changes:
- Update README structure, URLs and made requirements less Ubuntu specific
- Add missing copyright info to headers
- Add --debug option to afccheck
- Add new NP_ITDBPREP_DID_END notification signaling music db refresh
- Rename iphone_set_debug() to iphone_set_debug_level() and update code using it
- Add missing macro preventing cyclic includes in notification proxy header
- Remove DBGMASK_USBMUX as it is obsolete since the libusbmuxd code merge
- Improve debug output messages by using func everywhere and adjust wording
- Use iphone_device_get_uuid() instead of lockdown_get_device_uuid() for less overhead where possible
- Define remaining unknown AFC operations; SUCCESS is actually a DATA operation
- Fix build Python bindings due to signature change of iphone_device_get_uuid()
- Fix includes of utils
- Improve API of userpref system
- Update MobileSync API and introduce mobilesync error codes
- Update NotificationProxy API and introduce new error codes
- Update lockdown API and introduce new error codes
- Follow glib style and rename iphone_free_device to iphone_device_free
- Rename iphone_get_device_handle to iphone_device_get_handle and update tools
- Update AFC API and use error codes from the STATUS operation response
- Remove AFC to errno conversion and make afc_receive_data() return AFC errors
- Implement afc_file_tell() and adjust afc_receive_data() to handle it
teuf's patch is skipped as this was already implemented.
-
Martin S.
iFuse changes:
- Improve error message text when connecting to lockdown fails
- Add --debug command line option
- Update code to compile with latest libiphone error API changes
- Add a mapping from AFC error codes to errno and return errno codes where possible
-
Martin S.
Please test/review/commit. That should be the last API change for a 1.0. :)
All changes (incl. Nikias's afc lock code) are also pushed into the "martin" branch, if you prefer to pull, from here:
http://cgit.sukimashita.com/libiphone.git/ -
Matt Colyer
- State changed from open to resolved
(from [eea538c94f01f8054f69f059614f19400187a472]) Merge commit 'martin-s/martin'
[#46 libiphone 1.0 API cleanup state:resolved] http://github.com/MattColyer/libiphone/commit/eea538c94f01f8054f69f...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
