Skip to content

Commit 8803b75

Browse files
committed
Merge pull request #103 from jchuong/upstream
Merging my changes to upstream
2 parents 93ffa67 + 070f760 commit 8803b75

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

include/rpc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ struct rpc_struct {
107107
const char *app_id, const char *dest_id,
108108
const char *data, size_t length);
109109

110+
rpc_status (*on_applicationUpdated)(rpc_t self,
111+
const char *app_id, const char *dest_id);
112+
110113
// For internal use only:
111114
rpc_status (*on_error)(rpc_t self, const char *format, ...);
112115
};

src/ios_webkit_debug_proxy.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,9 @@ rpc_status iwdp_on_applicationDisconnected(rpc_t rpc, const rpc_app_t app) {
12711271
rpc_status iwdp_on_reportConnectedApplicationList(rpc_t rpc, const rpc_app_t *apps) {
12721272
iwdp_iwi_t iwi = (iwdp_iwi_t)rpc->state;
12731273
ht_t app_id_ht = iwi->app_id_to_true;
1274+
if (*apps == NULL) {
1275+
return RPC_SUCCESS;
1276+
}
12741277

12751278
// remove old apps
12761279
char **old_app_ids = (char **)ht_keys(app_id_ht);
@@ -1381,6 +1384,16 @@ rpc_status iwdp_on_applicationSentData(rpc_t rpc,
13811384
data, length);
13821385
}
13831386

1387+
rpc_status iwdp_on_applicationUpdated(rpc_t rpc,
1388+
const char *app_id, const char *dest_id) {
1389+
rpc_status result = iwdp_remove_app_id(rpc, app_id);
1390+
if (result) {
1391+
// Error removing app_id
1392+
return result;
1393+
}
1394+
return iwdp_add_app_id(rpc, dest_id);
1395+
}
1396+
13841397
//
13851398
// STRUCTS
13861399
//
@@ -1600,6 +1613,7 @@ iwdp_iwi_t iwdp_iwi_new(bool is_sim, bool *is_debug) {
16001613
rpc->on_applicationDisconnected = iwdp_on_applicationDisconnected;
16011614
rpc->on_applicationSentListing = iwdp_on_applicationSentListing;
16021615
rpc->on_applicationSentData = iwdp_on_applicationSentData;
1616+
rpc->on_applicationUpdated = iwdp_on_applicationUpdated;
16031617
rpc->send_plist = iwdp_send_plist;
16041618
rpc->state = iwi;
16051619
iwi->rpc = rpc;

src/rpc.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,58 @@ rpc_status rpc_recv_applicationSentData(rpc_t self, const plist_t args) {
421421
return ret;
422422
}
423423

424+
/*
425+
_rpc_applicationUpdated: <dict>
426+
<key>WIRApplicationBundleIdentifierKey</key>
427+
<string>com.apple.WebKit.WebContent</string>
428+
<key>WIRHostApplicationIdentifierKey</key>
429+
<string>PID:409</string>
430+
<key>WIRApplicationNameKey</key>
431+
<string></string>
432+
<key>WIRIsApplicationProxyKey</key>
433+
<true/>
434+
<key>WIRIsApplicationActiveKey</key>
435+
<integer>0</integer>
436+
<key>WIRApplicationIdentifierKey</key>
437+
<string>PID:536</string>
438+
</dict>
439+
440+
OR
441+
442+
<key>WIRApplicationBundleIdentifierKey</key>
443+
<string>com.apple.mobilesafari</string>
444+
<key>WIRApplicationNameKey</key>
445+
<string>Safari</string>
446+
<key>WIRIsApplicationProxyKey</key>
447+
<false/>
448+
<key>WIRIsApplicationActiveKey</key>
449+
<integer>0</integer>
450+
<key>WIRApplicationIdentifierKey</key>
451+
<string>PID:730</string>
452+
*/
453+
rpc_status rpc_recv_applicationUpdated(rpc_t self, const plist_t args) {
454+
char *app_id = NULL;
455+
char *dest_id = NULL;
456+
rpc_status ret;
457+
if (!rpc_dict_get_required_string(args, "WIRHostApplicationIdentifierKey", &app_id)) {
458+
if (!rpc_dict_get_required_string(args, "WIRApplicationIdentifierKey", &dest_id) &&
459+
!self->on_applicationUpdated(self, app_id, dest_id)) {
460+
ret = RPC_SUCCESS;
461+
} else {
462+
ret = RPC_ERROR;
463+
}
464+
} else if (!rpc_dict_get_required_string(args, "WIRApplicationNameKey", &app_id) &&
465+
!rpc_dict_get_required_string(args, "WIRApplicationIdentifierKey", &dest_id) &&
466+
!self->on_applicationUpdated(self, app_id, dest_id)) {
467+
ret = RPC_SUCCESS;
468+
} else {
469+
ret = RPC_ERROR;
470+
}
471+
free(app_id);
472+
free(dest_id);
473+
return ret;
474+
}
475+
424476
rpc_status rpc_recv_msg(rpc_t self, const char *selector, const plist_t args) {
425477
if (!selector) {
426478
return RPC_ERROR;
@@ -449,6 +501,10 @@ rpc_status rpc_recv_msg(rpc_t self, const char *selector, const plist_t args) {
449501
if (!rpc_recv_applicationSentData(self, args)) {
450502
return RPC_SUCCESS;
451503
}
504+
} else if (!strcmp(selector, "_rpc_applicationUpdated:")) {
505+
if (!rpc_recv_applicationUpdated(self, args)) {
506+
return RPC_SUCCESS;
507+
}
452508
}
453509

454510
// invalid msg

0 commit comments

Comments
 (0)