summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2009-04-20 22:04:45 +0200
committerGravatar Matt Colyer2009-04-23 19:17:02 -0700
commit7a93c3469de1063e48c8b946fa9ed9019de6934c (patch)
treea77a38675e90088629819d153ec76fb8dda71f6b
parentbda6ddc5b9eeb2e56e0c1a6a94cdf20ced4dab78 (diff)
downloadlibimobiledevice-7a93c3469de1063e48c8b946fa9ed9019de6934c.tar.gz
libimobiledevice-7a93c3469de1063e48c8b946fa9ed9019de6934c.tar.bz2
Show information about installed applications and refactor iphoneinfo a bit
[#30 state:resolved] Signed-off-by: Matt Colyer <matt@colyer.name>
-rw-r--r--dev/iphoneinfo.c141
1 files changed, 91 insertions, 50 deletions
diff --git a/dev/iphoneinfo.c b/dev/iphoneinfo.c
index a58ec42..4c887ac 100644
--- a/dev/iphoneinfo.c
+++ b/dev/iphoneinfo.c
@@ -28,6 +28,8 @@
28 28
29void print_usage(int argc, char **argv); 29void print_usage(int argc, char **argv);
30void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, const char *request, const char *key); 30void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, const char *request, const char *key);
31void plist_node_to_string(plist_t *node);
32void plist_children_to_string(plist_t *node);
31 33
32int main(int argc, char *argv[]) 34int main(int argc, char *argv[])
33{ 35{
@@ -82,11 +84,18 @@ int main(int argc, char *argv[])
82 } 84 }
83 85
84 /* dump all information we can retrieve */ 86 /* dump all information we can retrieve */
87 printf("# general\n");
85 print_lckd_request_info(control, NULL, "GetValue", NULL); 88 print_lckd_request_info(control, NULL, "GetValue", NULL);
86 print_lckd_request_info(control, "com.apple.disk_usage", "GetValue", NULL); 89 print_lckd_request_info(control, "com.apple.disk_usage", "GetValue", NULL);
87 print_lckd_request_info(control, "com.apple.mobile.battery", "GetValue", NULL); 90 print_lckd_request_info(control, "com.apple.mobile.battery", "GetValue", NULL);
91 /* FIXME: For some reason lockdownd segfaults on this, works sometimes though
92 print_lckd_request_info(control, "com.apple.mobile.debug", "GetValue", NULL);
93 */
94 print_lckd_request_info(control, "com.apple.xcode.developerdomain", "GetValue", NULL);
88 print_lckd_request_info(control, "com.apple.international", "GetValue", NULL); 95 print_lckd_request_info(control, "com.apple.international", "GetValue", NULL);
89 print_lckd_request_info(control, "com.apple.mobile.sync_data_class", "GetValue", NULL); 96 print_lckd_request_info(control, "com.apple.mobile.sync_data_class", "GetValue", NULL);
97 print_lckd_request_info(control, "com.apple.iTunes", "GetValue", NULL);
98 print_lckd_request_info(control, "com.apple.mobile.iTunes.store", "GetValue", NULL);
90 99
91 iphone_lckd_free_client(control); 100 iphone_lckd_free_client(control);
92 iphone_free_device(phone); 101 iphone_free_device(phone);
@@ -104,14 +113,91 @@ void print_usage(int argc, char **argv)
104 printf("\n"); 113 printf("\n");
105} 114}
106 115
107void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, const char *request, const char *key) { 116void plist_node_to_string(plist_t *node)
108 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; 117{
118 char *s = NULL;
119 double d;
120 uint8_t b;
121
122 uint64_t u = 0;
123
109 plist_type t; 124 plist_type t;
110 125
126 if (!node)
127 return;
128
129 t = plist_get_node_type(node);
130
131 switch (t) {
132 case PLIST_BOOLEAN:
133 plist_get_bool_val(node, &b);
134 printf("%s\n", (b ? "true" : "false"));
135 break;
136
137 case PLIST_UINT:
138 plist_get_uint_val(node, &u);
139 printf("%llu\n", u);
140 break;
141
142 case PLIST_REAL:
143 plist_get_real_val(node, &d);
144 printf("%f\n", d);
145 break;
146
147 case PLIST_STRING:
148 plist_get_string_val(node, &s);
149 printf("%s\n", s);
150 free(s);
151 break;
152
153 case PLIST_UNICODE:
154 plist_get_unicode_val(node, &s);
155 printf("%s\n", s);
156 free(s);
157 break;
158
159 case PLIST_KEY:
160 plist_get_key_val(node, &s);
161 printf("%s: ", s);
162 free(s);
163 break;
164
165 case PLIST_DATA:
166 printf("\n");
167 break;
168 case PLIST_DATE:
169 printf("\n");
170 break;
171 case PLIST_ARRAY:
172 case PLIST_DICT:
173 printf("\n");
174 plist_children_to_string(node);
175 break;
176 default:
177 break;
178 }
179}
180
181void plist_children_to_string(plist_t *node)
182{
183 /* iterate over key/value pairs */
184 for (
185 node = plist_get_first_child(node);
186 node != NULL;
187 node = plist_get_next_sibling(node)
188 ) {
189 plist_node_to_string(node);
190 }
191}
192
193void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, const char *request, const char *key) {
194 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
195
111 plist_t node = plist_new_dict(); 196 plist_t node = plist_new_dict();
112 if (domain) { 197 if (domain) {
113 plist_add_sub_key_el(node, "Domain"); 198 plist_add_sub_key_el(node, "Domain");
114 plist_add_sub_string_el(node, domain); 199 plist_add_sub_string_el(node, domain);
200 printf("# %s\n", domain);
115 } 201 }
116 if (key) { 202 if (key) {
117 plist_add_sub_key_el(node, "Key"); 203 plist_add_sub_key_el(node, "Key");
@@ -129,57 +215,12 @@ void print_lckd_request_info(iphone_lckd_client_t control, const char *domain, c
129 /* seek to first dict node */ 215 /* seek to first dict node */
130 for ( 216 for (
131 node = plist_get_first_child(node); 217 node = plist_get_first_child(node);
132 (node != NULL) && (plist_get_node_type(node) != PLIST_DICT); 218 node && (plist_get_node_type(node) != PLIST_DICT);
133 node = plist_get_next_sibling(node)
134 ) {
135 }
136
137 /* iterate over key/value pairs */
138 for (
139 node = plist_get_first_child(node);
140 node;
141 node = plist_get_next_sibling(node) 219 node = plist_get_next_sibling(node)
142 ) { 220 ) {
143 char *s = NULL;
144 uint8_t b;
145
146 t = plist_get_node_type(node);
147 if (t == PLIST_KEY) {
148 plist_get_key_val(node, &s);
149 node = plist_get_next_sibling(node);
150 t = plist_get_node_type(node);
151 /* only print string nodes for now */
152 if ((t != PLIST_STRING) &&
153 (t != PLIST_BOOLEAN) &&
154 (t != PLIST_UINT) &&
155 (t != PLIST_DICT)
156 ) {
157 free(s);
158 continue;
159 }
160 printf("%s: ", s);
161 }
162 uint64_t u = 0;
163 switch(t) {
164 case PLIST_DICT:
165 printf("<dict/>\n");
166 break;
167 case PLIST_UINT:
168 plist_get_uint_val(node, &u);
169 printf("%llu\n", u);
170 break;
171 case PLIST_STRING:
172 plist_get_string_val(node, &s);
173 printf("%s\n", s);
174 free(s);
175 break;
176 case PLIST_BOOLEAN:
177 plist_get_bool_val(node, &b);
178 printf("%s\n", (b ? "true" : "false"));
179 default:
180 continue;
181 }
182 } 221 }
222 if(plist_get_first_child(node))
223 plist_children_to_string(node);
183 } 224 }
184 } 225 }
185 if (node) 226 if (node)