@@ -100,6 +100,7 @@ struct iwdp_iport_struct {
100
100
// null if the device is detached
101
101
iwdp_iwi_t iwi ;
102
102
};
103
+
103
104
typedef struct iwdp_iport_struct * iwdp_iport_t ;
104
105
iwdp_iport_t iwdp_iport_new ();
105
106
void iwdp_iport_free (iwdp_iport_t iport );
@@ -119,12 +120,14 @@ struct iwdp_iwi_struct {
119
120
char * connection_id ;
120
121
121
122
rpc_t rpc ; // plist parser
123
+ rpc_app_t app ;
122
124
123
125
bool connected ;
124
126
uint32_t max_page_num ; // > 0
125
127
ht_t app_id_to_true ; // set of app_ids
126
128
ht_t page_num_to_ipage ;
127
129
};
130
+
128
131
iwdp_iwi_t iwdp_iwi_new (bool is_sim , bool * is_debug );
129
132
void iwdp_iwi_free (iwdp_iwi_t iwi );
130
133
@@ -175,6 +178,7 @@ struct iwdp_ifs_struct {
175
178
// static server
176
179
int fs_fd ;
177
180
};
181
+
178
182
iwdp_ifs_t iwdp_ifs_new ();
179
183
void iwdp_ifs_free (iwdp_ifs_t ifs );
180
184
@@ -196,6 +200,7 @@ struct iwdp_ipage_struct {
196
200
// owner is iport->ws_id_to_iws
197
201
iwdp_iws_t iws ;
198
202
};
203
+
199
204
iwdp_ipage_t iwdp_ipage_new ();
200
205
void iwdp_ipage_free (iwdp_ipage_t ipage );
201
206
int iwdp_ipage_cmp (const void * a , const void * b );
@@ -255,6 +260,8 @@ void iwdp_log_disconnect(iwdp_iport_t iport) {
255
260
}
256
261
}
257
262
263
+ #define SAFARI_NAME "Safari"
264
+
258
265
//
259
266
// device_listener
260
267
//
@@ -473,6 +480,7 @@ iwdp_status iwdp_iport_accept(iwdp_t self, iwdp_iport_t iport, int ws_fd,
473
480
* to_iws = iws ;
474
481
return IWDP_SUCCESS ;
475
482
}
483
+
476
484
iwdp_status iwdp_on_accept (iwdp_t self , int s_fd , void * value ,
477
485
int fd , void * * to_value ) {
478
486
int type = ((iwdp_type_t )value )-> type ;
@@ -1165,6 +1173,12 @@ rpc_status iwdp_add_app_id(rpc_t rpc, const char *app_id) {
1165
1173
}
1166
1174
1167
1175
rpc_status iwdp_on_applicationConnected (rpc_t rpc , const rpc_app_t app ) {
1176
+ if (!strcmp (app -> app_name , SAFARI_NAME )) {
1177
+ iwdp_iwi_t iwi = (iwdp_iwi_t )rpc -> state ;
1178
+ rpc_app_t to_app = NULL ;
1179
+ rpc_copy_app (app , & to_app );
1180
+ iwi -> app = to_app ;
1181
+ }
1168
1182
return iwdp_add_app_id (rpc , app -> app_id );
1169
1183
}
1170
1184
@@ -1264,6 +1278,7 @@ rpc_status iwdp_remove_app_id(rpc_t rpc, const char *app_id) {
1264
1278
free (old_app_id );
1265
1279
return RPC_SUCCESS ;
1266
1280
}
1281
+
1267
1282
rpc_status iwdp_on_applicationDisconnected (rpc_t rpc , const rpc_app_t app ) {
1268
1283
return iwdp_remove_app_id (rpc , app -> app_id );
1269
1284
}
@@ -1305,6 +1320,11 @@ rpc_status iwdp_on_applicationSentListing(rpc_t rpc,
1305
1320
return RPC_ERROR ; // Inspector closed?
1306
1321
}
1307
1322
if (!ht_get_value (iwi -> app_id_to_true , app_id )) {
1323
+ iwdp_iwi_t iwi = (iwdp_iwi_t )rpc -> state ;
1324
+ rpc_app_t app = iwi -> app ;
1325
+ if (app && !strcmp (app -> app_name , SAFARI_NAME )) {
1326
+ return rpc -> send_forwardGetListing (rpc , iwi -> connection_id , app -> app_id );
1327
+ }
1308
1328
return self -> on_error (self , "Unknown app_id %s" , app_id );
1309
1329
}
1310
1330
ht_t ipage_ht = iwi -> page_num_to_ipage ;
@@ -1411,6 +1431,7 @@ void iwdp_free(iwdp_t self) {
1411
1431
free (self );
1412
1432
}
1413
1433
}
1434
+
1414
1435
iwdp_t iwdp_new (const char * frontend ) {
1415
1436
iwdp_t self = (iwdp_t )malloc (sizeof (struct iwdp_struct ));
1416
1437
iwdp_private_t my = (iwdp_private_t )malloc (sizeof (struct iwdp_private ));
@@ -1442,6 +1463,7 @@ void iwdp_idl_free(iwdp_idl_t idl) {
1442
1463
free (idl );
1443
1464
}
1444
1465
}
1466
+
1445
1467
iwdp_idl_t iwdp_idl_new () {
1446
1468
iwdp_idl_t idl = (iwdp_idl_t )malloc (sizeof (struct iwdp_idl_struct ));
1447
1469
dl_t dl = dl_new ();
@@ -1468,6 +1490,7 @@ void iwdp_iport_free(iwdp_iport_t iport) {
1468
1490
free (iport );
1469
1491
}
1470
1492
}
1493
+
1471
1494
iwdp_iport_t iwdp_iport_new () {
1472
1495
iwdp_iport_t iport = (iwdp_iport_t )malloc (sizeof (struct iwdp_iport_struct ));
1473
1496
if (!iport ) {
@@ -1493,6 +1516,7 @@ int iwdp_iport_cmp(const void *a, const void *b) {
1493
1516
uint32_t pb = ipb -> port ;
1494
1517
return (pa == pb ? 0 : pa < pb ? -1 : 1 );
1495
1518
}
1519
+
1496
1520
char * iwdp_iports_to_text (iwdp_iport_t * iports , bool want_json ,
1497
1521
const char * host ) {
1498
1522
// count ports
@@ -1583,6 +1607,7 @@ void iwdp_iwi_free(iwdp_iwi_t iwi) {
1583
1607
if (iwi ) {
1584
1608
wi_free (iwi -> wi );
1585
1609
rpc_free (iwi -> rpc );
1610
+ rpc_free_app (iwi -> app );
1586
1611
// TODO free ht_values?
1587
1612
free (iwi -> connection_id );
1588
1613
ht_free (iwi -> app_id_to_true );
@@ -1591,6 +1616,7 @@ void iwdp_iwi_free(iwdp_iwi_t iwi) {
1591
1616
free (iwi );
1592
1617
}
1593
1618
}
1619
+
1594
1620
iwdp_iwi_t iwdp_iwi_new (bool is_sim , bool * is_debug ) {
1595
1621
iwdp_iwi_t iwi = (iwdp_iwi_t )malloc (sizeof (struct iwdp_iwi_struct ));
1596
1622
if (!iwi ) {
@@ -1633,6 +1659,7 @@ void iwdp_iws_free(iwdp_iws_t iws) {
1633
1659
free (iws );
1634
1660
}
1635
1661
}
1662
+
1636
1663
iwdp_iws_t iwdp_iws_new (bool * is_debug ) {
1637
1664
iwdp_iws_t iws = (iwdp_iws_t )malloc (sizeof (struct iwdp_iws_struct ));
1638
1665
if (!iws ) {
@@ -1664,6 +1691,7 @@ void iwdp_ifs_free(iwdp_ifs_t ifs) {
1664
1691
free (ifs );
1665
1692
}
1666
1693
}
1694
+
1667
1695
iwdp_ifs_t iwdp_ifs_new () {
1668
1696
iwdp_ifs_t ifs = (iwdp_ifs_t )malloc (sizeof (struct iwdp_ifs_struct ));
1669
1697
if (ifs ) {
@@ -1684,6 +1712,7 @@ void iwdp_ipage_free(iwdp_ipage_t ipage) {
1684
1712
free (ipage );
1685
1713
}
1686
1714
}
1715
+
1687
1716
iwdp_ipage_t iwdp_ipage_new () {
1688
1717
iwdp_ipage_t ipage = (iwdp_ipage_t )malloc (sizeof (struct iwdp_ipage_struct ));
1689
1718
if (ipage ) {
0 commit comments