38 // |
38 // |
39 NPError NpnUrlLoader(NPP aInstance, const TDesC& aUrl, TUint8 aMethod, |
39 NPError NpnUrlLoader(NPP aInstance, const TDesC& aUrl, TUint8 aMethod, |
40 const TDesC* aWindowType, const TDesC& aBuf, |
40 const TDesC* aWindowType, const TDesC& aBuf, |
41 TBool aFromFile, TBool aNotify, void* aNotifyData) |
41 TBool aFromFile, TBool aNotify, void* aNotifyData) |
42 { |
42 { |
43 |
43 |
44 PluginWin* pluginWin = (PluginWin* )aInstance->ndata; |
44 PluginWin* pluginWin = (PluginWin* )aInstance->ndata; |
45 if ( !pluginWin ) { |
45 if ( !pluginWin ) { |
46 return NPERR_INVALID_INSTANCE_ERROR; |
46 return NPERR_INVALID_INSTANCE_ERROR; |
47 } |
47 } |
48 |
48 |
49 TInt status = KErrNone; |
49 TInt status = KErrNone; |
50 |
50 |
51 // Make the load request |
51 // Make the load request |
52 // convert to 8 bit |
52 // convert to 8 bit |
53 HBufC8* url = HBufC8::NewLC(aUrl.Length()); |
53 HBufC8* url = HBufC8::NewLC(aUrl.Length()); |
54 url->Des().Copy(aUrl); |
54 url->Des().Copy(aUrl); |
55 if (aMethod==EUrlGet) { |
55 if (aMethod==EUrlGet) { |
56 TRAP_IGNORE(status = pluginWin->pluginSkin()->getRequestL(*url, aNotify, aNotifyData, aWindowType)); |
56 TRAP_IGNORE(status = pluginWin->pluginSkin()->getRequestL(*url, aNotify, aNotifyData, aWindowType)); |
57 } |
57 } |
58 else if (aMethod==EUrlPost) { |
58 else if (aMethod==EUrlPost) { |
59 TRAP_IGNORE(status = pluginWin->pluginSkin()->postRequestL(*url, aBuf, aFromFile, aNotify, aNotifyData, aWindowType)); |
59 TRAP_IGNORE(status = pluginWin->pluginSkin()->postRequestL(*url, aBuf, aFromFile, aNotify, aNotifyData, aWindowType)); |
159 // Allows a plugin to report its current status to the associated PluginInst. |
159 // Allows a plugin to report its current status to the associated PluginInst. |
160 // ----------------------------------------------------------------------------- |
160 // ----------------------------------------------------------------------------- |
161 // |
161 // |
162 void NpnStatus(NPP aInstance, const TDesC& aMessage) |
162 void NpnStatus(NPP aInstance, const TDesC& aMessage) |
163 { |
163 { |
164 // This function is not supported. |
164 // This function is not supported. |
165 } |
165 } |
166 |
166 |
167 // ----------------------------------------------------------------------------- |
167 // ----------------------------------------------------------------------------- |
168 // NpnUAgent |
168 // NpnUAgent |
169 // |
169 // |
170 // Returns the user agent of the Series 60 Browser. |
170 // Returns the user agent of the Series 60 Browser. |
171 // ----------------------------------------------------------------------------- |
171 // ----------------------------------------------------------------------------- |
172 // |
172 // |
173 const TDesC* NpnUAgent(NPP /*aInstance*/) |
173 const TDesC* NpnUAgent(NPP /*aInstance*/) |
174 { |
174 { |
175 // Get User Agent String |
175 // Get User Agent String |
176 CUserAgent* usrAgnt = CUserAgent::NewL(); |
176 CUserAgent* usrAgnt = CUserAgent::NewL(); |
177 CleanupStack::PushL( usrAgnt ); |
177 CleanupStack::PushL( usrAgnt ); |
178 |
178 |
179 HBufC8* userAgent8 = usrAgnt->UserAgentL(); |
179 HBufC8* userAgent8 = usrAgnt->UserAgentL(); |
180 CleanupStack::PushL( userAgent8 ); |
180 CleanupStack::PushL( userAgent8 ); |
273 const TDesC* aWindowType, void* aNotifyData) |
273 const TDesC* aWindowType, void* aNotifyData) |
274 { |
274 { |
275 TPtrC nullPtr(NULL, 0); |
275 TPtrC nullPtr(NULL, 0); |
276 return NpnUrlLoader(aInstance, aUrl, EUrlGet, aWindowType, nullPtr, |
276 return NpnUrlLoader(aInstance, aUrl, EUrlGet, aWindowType, nullPtr, |
277 EFalse, ETrue, aNotifyData); |
277 EFalse, ETrue, aNotifyData); |
278 |
278 |
279 } |
279 } |
280 |
280 |
281 // ----------------------------------------------------------------------------- |
281 // ----------------------------------------------------------------------------- |
282 // NpnPostUrlNotify |
282 // NpnPostUrlNotify |
283 // |
283 // |
300 // ----------------------------------------------------------------------------- |
300 // ----------------------------------------------------------------------------- |
301 // |
301 // |
302 NPError NpnGetValue(NPP aInstance, NPNVariable aVariable, void *aRetValue) |
302 NPError NpnGetValue(NPP aInstance, NPNVariable aVariable, void *aRetValue) |
303 { |
303 { |
304 TInt err = NPERR_NO_ERROR; |
304 TInt err = NPERR_NO_ERROR; |
305 |
305 |
306 switch (aVariable) { |
306 switch (aVariable) { |
307 |
307 |
308 case NPNVjavascriptEnabledBool: // Tells whether JavaScript is enabled; true=JavaScript enabled, false=not enabled |
308 case NPNVjavascriptEnabledBool: // Tells whether JavaScript is enabled; true=JavaScript enabled, false=not enabled |
309 // NEEDS IMPLEMENTATION |
309 // NEEDS IMPLEMENTATION |
310 // *((TBool*) aRetValue) = NW_Settings_GetEcmaScriptEnabled(); |
310 // *((TBool*) aRetValue) = NW_Settings_GetEcmaScriptEnabled(); |
311 break; |
311 break; |
312 |
312 |
313 case NPNVnetscapeWindow: { |
313 case NPNVnetscapeWindow: { |
314 |
314 |
315 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
315 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
316 if (pluginWin) { |
316 if (pluginWin) { |
317 NPWindow* npWindow = (NPWindow*)aRetValue; |
317 NPWindow* npWindow = (NPWindow*)aRetValue; |
318 TRect rect = pluginWin->Rect(); |
318 TRect rect = pluginWin->Rect(); |
321 npWindow->y = rect.iTl.iY; |
321 npWindow->y = rect.iTl.iY; |
322 npWindow->width = rect.Width(); |
322 npWindow->width = rect.Width(); |
323 npWindow->height = rect.Height(); |
323 npWindow->height = rect.Height(); |
324 npWindow->type = pluginWin->Windowed() ? NPWindowTypeWindow : NPWindowTypeDrawable; |
324 npWindow->type = pluginWin->Windowed() ? NPWindowTypeWindow : NPWindowTypeDrawable; |
325 npWindow->window = pluginWin->Windowed() ? NULL : (MPluginAdapter*) pluginWin; |
325 npWindow->window = pluginWin->Windowed() ? NULL : (MPluginAdapter*) pluginWin; |
326 |
326 |
327 NPRect clipRect = {0,0,0,0}; |
327 NPRect clipRect = {0,0,0,0}; |
328 npWindow->clipRect = clipRect; |
328 npWindow->clipRect = clipRect; |
329 } |
329 } |
330 } |
330 } |
331 break; |
331 break; |
332 |
332 |
333 case NPNVPluginElementNPObject: { |
333 case NPNVPluginElementNPObject: { |
334 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
334 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
335 WebCore::Element* pluginElement; |
335 WebCore::Element* pluginElement; |
336 if (pluginWin) { |
336 if (pluginWin) { |
337 pluginElement = pluginWin->pluginSkin()->getElement(); |
337 pluginElement = pluginWin->pluginSkin()->getElement(); |
338 } |
338 } |
339 |
339 |
340 NPObject* pluginScriptObject = 0; |
340 NPObject* pluginScriptObject = 0; |
341 if (pluginElement->hasTagName(appletTag) || pluginElement->hasTagName(embedTag) || pluginElement->hasTagName(objectTag)) |
341 if (pluginElement->hasTagName(appletTag) || pluginElement->hasTagName(embedTag) || pluginElement->hasTagName(objectTag)) |
342 pluginScriptObject = static_cast<WebCore::HTMLPlugInElement*>(pluginElement)->getNPObject(); |
342 pluginScriptObject = static_cast<WebCore::HTMLPlugInElement*>(pluginElement)->getNPObject(); |
343 |
343 |
344 if (pluginScriptObject) |
344 if (pluginScriptObject) |
345 _NPN_RetainObject(pluginScriptObject); |
345 _NPN_RetainObject(pluginScriptObject); |
346 |
346 |
347 void** v = (void**)aRetValue; |
347 void** v = (void**)aRetValue; |
348 *v = pluginScriptObject; |
348 *v = pluginScriptObject; |
349 } |
349 } |
350 break; |
350 break; |
351 |
351 |
352 case NPNVWindowNPObject: { |
352 case NPNVWindowNPObject: { |
353 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
353 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
354 NPObject* windowObject = pluginWin->windowScriptNPObject(); |
354 NPObject* windowObject = pluginWin->windowScriptNPObject(); |
355 if (windowObject) { |
355 if (windowObject) { |
356 void **v = (void **)aRetValue; |
356 void **v = (void **)aRetValue; |
366 case NPNVxtAppContext: // Unix only: Returns the application's XtAppContext |
366 case NPNVxtAppContext: // Unix only: Returns the application's XtAppContext |
367 case NPNVasdEnabledBool: // Tells whether SmartUpdate (former name: ASD) is enabled; |
367 case NPNVasdEnabledBool: // Tells whether SmartUpdate (former name: ASD) is enabled; |
368 // true=SmartUpdate enabled, false=not enabled |
368 // true=SmartUpdate enabled, false=not enabled |
369 case NPNVisOfflineBool: // Tells whether offline mode is enabled; |
369 case NPNVisOfflineBool: // Tells whether offline mode is enabled; |
370 // true=offline mode enabled, false=not enabled |
370 // true=offline mode enabled, false=not enabled |
371 |
371 |
372 case NPNNetworkAccess: |
372 case NPNNetworkAccess: { |
373 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
373 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
374 TInt apId = -1; |
374 TInt apId = -1; |
375 if (pluginWin) { |
375 if (pluginWin) { |
376 apId = pluginWin->pluginSkin()->handleNetworkAccess(); |
376 apId = pluginWin->pluginSkin()->handleNetworkAccess(); |
377 } |
377 } |
378 *((TInt*) aRetValue) = apId; |
378 *((TInt*) aRetValue) = apId; |
379 break; |
379 } |
380 |
380 break; |
381 case NPNVGenericParameter: { |
381 |
|
382 case NPNVGenericParameter: { |
382 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
383 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
383 if (pluginWin) { |
384 if (pluginWin) { |
384 void **v = (void **)aRetValue; |
385 void **v = (void **)aRetValue; |
385 *v = pluginWin->pluginSkin()->genericElementArray(); |
386 *v = pluginWin->pluginSkin()->genericElementArray(); |
386 } |
387 } |
387 else { |
388 else { |
388 err = NPERR_GENERIC_ERROR; |
389 err = NPERR_GENERIC_ERROR; |
389 } |
390 } |
390 } |
391 } |
391 break; // for code consistency |
392 break; // for code consistency |
392 |
393 |
393 case NPNVSupportsWindowless:{ |
394 case NPNVSupportsWindowless:{ |
394 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
395 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
395 if (pluginWin) { |
396 if (pluginWin) { |
396 *((TBool*) aRetValue) = ETrue; |
397 *((TBool*) aRetValue) = ETrue; |
397 } |
398 } |
398 else { |
399 else { |
399 err = NPERR_GENERIC_ERROR; |
400 err = NPERR_GENERIC_ERROR; |
400 } |
401 } |
401 } |
402 } |
402 break; |
403 break; |
403 default: |
404 default: |
404 { |
405 { |
405 *((TBool*) aRetValue) = EFalse; |
406 *((TBool*) aRetValue) = EFalse; |
406 err = NPERR_INVALID_PARAM; |
407 err = NPERR_INVALID_PARAM; |
407 } |
408 } |
408 break; |
409 break; |
409 } // end of switch |
410 } // end of switch |
410 |
411 |
411 return err; |
412 return err; |
412 |
413 |
413 } |
414 } |
414 |
415 |
415 // ----------------------------------------------------------------------------- |
416 // ----------------------------------------------------------------------------- |
440 if (pluginWin) { |
441 if (pluginWin) { |
441 NPBool* isWindowed = (NPBool*)aSetValue; |
442 NPBool* isWindowed = (NPBool*)aSetValue; |
442 if (isWindowed) |
443 if (isWindowed) |
443 pluginWin->setWindowedPlugin(*isWindowed); |
444 pluginWin->setWindowedPlugin(*isWindowed); |
444 } |
445 } |
445 |
446 |
446 } |
447 } |
447 break; |
448 break; |
448 case NPPVpluginTransparentBool: |
449 case NPPVpluginTransparentBool: |
449 { |
450 { |
450 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
451 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
451 if (pluginWin) { |
452 if (pluginWin) { |
452 NPBool* isTransparent = (NPBool*)aSetValue; |
453 NPBool* isTransparent = (NPBool*)aSetValue; |
453 if (isTransparent) |
454 if (isTransparent) |
454 pluginWin->setTransparentPlugin(*isTransparent); |
455 pluginWin->setTransparentPlugin(*isTransparent); |
455 } |
456 } |
456 } |
457 } |
457 break; |
458 break; |
458 case NPPVPluginFocusPosition: |
459 case NPPVPluginFocusPosition: |
459 { |
460 { |
460 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |
461 PluginWin* pluginWin = (PluginWin*)aInstance->ndata; |