Well, what little time I have to work on this so far has yeilded this new version of decidePolicyForNaviationAction:
- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)url frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener{
BBString*stext;
BBString*sbody;
BBString*surl;
BBString*scr;
NSString*body;
int key;
// printf("decidepolicy\n");fflush(stdout);
key=(int)[[actionInformation objectForKey:WebActionNavigationTypeKey] intValue];
switch (key){
case WebNavigationTypeOther:
case WebNavigationTypeLinkClicked:
default:
if (_state==0) {
[listener ignore];
surl = bbStringFromCString((char*)[[[url URL] absoluteString] cString]);
body = [[NSString alloc] initWithData: [url HTTPBody] encoding: [NSString defaultCStringEncoding]];
sbody = bbStringFromCString((char*)[body cString]);
stext = bbStringConcat(surl, bbStringConcat(bbStringFromCString("\n"), sbody));
PostGuiEvent( BBEVENT_GADGETACTION,sender,0,0,0,0,(BBObject*)stext );
}else{
[listener use];
}
//default:
// [listener use];
}
}
This will intercept any navigation event, including form submittal.
I'm worried about two things:
1. I should really use some kind of structure to send in the URL and HTTPBody as separate strings.
2. In all those calls to bbStringConcat, am I generating a memory leak? It looks like they boil down to bbGCAlloc(), so I assume the memory will eventually be cleaned up and it'll be okay. That said, should I do my own clean up here?
Is there any kind of API reference for this level of the BMax / BB runtime? I would really be interested in seeing that kind of documentation...