Only try to load wallpaper for iOS 4.0+

This commit is contained in:
Nikias Bassen
2010-07-09 17:34:12 +02:00
parent 445026e472
commit 113022dbed
4 changed files with 27 additions and 7 deletions
+18 -1
View File
@@ -47,7 +47,7 @@ void device_init()
device_domain = g_quark_from_string("libimobiledevice");
}
sbservices_client_t device_sbs_new(const char *uuid, GError **error)
sbservices_client_t device_sbs_new(const char *uuid, uint32_t *osversion, GError **error)
{
sbservices_client_t sbc = NULL;
idevice_t phone = NULL;
@@ -70,6 +70,23 @@ sbservices_client_t device_sbs_new(const char *uuid, GError **error)
goto leave_cleanup;
}
plist_t version = NULL;
if (osversion && lockdownd_get_value(client, NULL, "ProductVersion", &version) == LOCKDOWN_E_SUCCESS) {
if (plist_get_node_type(version) == PLIST_STRING) {
char *version_string = NULL;
plist_get_string_val(version, &version_string);
if (version_string) {
/* parse version */
int maj = 0;
int min = 0;
int rev = 0;
sscanf(version_string, "%d.%d.%d", &maj, &min, &rev);
free(version_string);
*osversion = ((maj & 0xFF) << 24) + ((min & 0xFF) << 16) + ((rev & 0xFF) << 8);
}
}
}
if ((lockdownd_start_service(client, "com.apple.springboardservices", &port) != LOCKDOWN_E_SUCCESS) || !port) {
if (error)
*error = g_error_new(device_domain, EIO, _("Could not start com.apple.springboardservices service! Remind that this feature is only supported in OS 3.1 and later!"));
+1 -1
View File
@@ -37,7 +37,7 @@ struct device_info_int {
typedef struct device_info_int *device_info_t;
void device_init();
sbservices_client_t device_sbs_new(const char *uuid, GError **error);
sbservices_client_t device_sbs_new(const char *uuid, uint32_t *osversion, GError **error);
void device_sbs_free(sbservices_client_t sbc);
gboolean device_sbs_get_iconstate(sbservices_client_t sbc, plist_t *iconstate, GError **error);
gboolean device_sbs_save_icon(sbservices_client_t sbc, char *display_identifier, char *filename, GError **error);
+7 -4
View File
@@ -1136,6 +1136,7 @@ static void gui_set_wallpaper(const char *wp)
static gboolean gui_pages_init_cb(gpointer user_data)
{
const char *uuid = (const char*)user_data;
uint32_t osversion = 0;
GError *error = NULL;
plist_t iconstate = NULL;
@@ -1147,7 +1148,7 @@ static gboolean gui_pages_init_cb(gpointer user_data)
/* connect to sbservices */
if (!sbc)
sbc = device_sbs_new(uuid, &error);
sbc = device_sbs_new(uuid, &osversion, &error);
if (error) {
g_printerr("%s", error->message);
@@ -1156,9 +1157,11 @@ static gboolean gui_pages_init_cb(gpointer user_data)
}
if (sbc) {
/* Load wallpaper if available */
if (device_sbs_save_wallpaper(sbc, "/tmp/wallpaper.png", &error)) {
gui_set_wallpaper("/tmp/wallpaper.png");
if (osversion >= 0x04000000) {
/* Load wallpaper if available */
if (device_sbs_save_wallpaper(sbc, "/tmp/wallpaper.png", &error)) {
gui_set_wallpaper("/tmp/wallpaper.png");
}
}
/* Load icon data */
+1 -1
View File
@@ -131,7 +131,7 @@ void sbmgr_save(const char *uuid)
GError *error = NULL;
sbservices_client_t sbc;
sbc = device_sbs_new(uuid, &error);
sbc = device_sbs_new(uuid, NULL, &error);
if (error) {
g_printerr("%s", error->message);