46
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: SVGT Plugin Implementation source file
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
/*
|
|
20 |
************************************************************************************
|
|
21 |
* Contents: Example plugin implementation
|
|
22 |
* Implementation of the API used by Opera to control the plugin
|
|
23 |
************************************************************************************
|
|
24 |
*/
|
|
25 |
|
|
26 |
|
|
27 |
#include "Svgtplugin.h"
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Create a new instance of a SVG plugin.
|
|
31 |
**/
|
|
32 |
|
|
33 |
NPError SvgtPluginNewp(NPMIMEType pluginType, NPP instance, uint16 mode,
|
|
34 |
CDesCArray* argn, CDesCArray* argv, NPSavedData* saved)
|
|
35 |
{
|
|
36 |
CSvgtPlugin* lSvgtPlugin = NULL;
|
|
37 |
TRAPD(err,lSvgtPlugin = CSvgtPlugin::NewL(instance));
|
|
38 |
|
|
39 |
if (err == KErrNoMemory)
|
|
40 |
return NPERR_OUT_OF_MEMORY_ERROR;
|
|
41 |
if (err != KErrNone)
|
|
42 |
return NPERR_MODULE_LOAD_FAILED_ERROR;
|
|
43 |
|
|
44 |
instance->pdata = (void *) lSvgtPlugin;
|
|
45 |
NPError nerr = lSvgtPlugin->SvgPluginNew(pluginType, instance,
|
|
46 |
mode, argn, argv, saved);
|
|
47 |
return nerr;
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Destroy a plugin.
|
|
52 |
**/
|
|
53 |
NPError SvgtPluginDestroy(NPP instance, NPSavedData** /*save*/)
|
|
54 |
{
|
|
55 |
CSvgtPlugin* lSvgtPlugin = (CSvgtPlugin *)instance->pdata;
|
|
56 |
if ( lSvgtPlugin )
|
|
57 |
{
|
|
58 |
TRAPD(err,lSvgtPlugin->PrepareToExitL());
|
|
59 |
if (err != KErrNone)
|
|
60 |
{
|
|
61 |
#ifdef _DEBUG
|
|
62 |
RDebug::Printf("SvgtPluginDestroy Error when printing Warning.");
|
|
63 |
#endif //_DEBUG
|
|
64 |
}
|
|
65 |
/**Ignoring the error*/
|
|
66 |
delete lSvgtPlugin;
|
|
67 |
lSvgtPlugin = NULL;
|
|
68 |
}
|
|
69 |
return NPERR_NO_ERROR;
|
|
70 |
}
|
|
71 |
|
|
72 |
/**
|
|
73 |
* This is the parent window of a plugin.
|
|
74 |
*/
|
|
75 |
NPError SvgtPluginSetWindow(NPP instance, NPWindow *window)
|
|
76 |
{
|
|
77 |
CSvgtPlugin* lSvgtPlugin = (CSvgtPlugin *) instance->pdata;
|
|
78 |
TUint lWidth = window->width;
|
|
79 |
TUint lHeight = window->height;
|
|
80 |
|
|
81 |
TRAPD(err,lSvgtPlugin->SetWindowL(window,TRect(TSize(lWidth,lHeight))));
|
|
82 |
|
|
83 |
if (err == KErrNoMemory)
|
|
84 |
return NPERR_OUT_OF_MEMORY_ERROR;
|
|
85 |
if (err != KErrNone)
|
|
86 |
return NPERR_GENERIC_ERROR;
|
|
87 |
return NPERR_NO_ERROR;
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* A new data stream has been created for sending data to the plugin.
|
|
92 |
* @param stream - A pointer to plugin specific data can be placed in stream->pdata
|
|
93 |
*
|
|
94 |
*/
|
|
95 |
|
|
96 |
NPError SvgtPluginNewStream(NPP /*instance*/, NPMIMEType /*type*/, NPStream* /*stream*/, NPBool /*seekable*/, uint16* stype)
|
|
97 |
{
|
|
98 |
*stype = NP_ASFILEONLY;
|
|
99 |
return NPERR_NO_ERROR;
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
* A data stream has been terminated.
|
|
104 |
*/
|
|
105 |
NPError SvgtPluginDestroyStream(NPP /*instance*/, NPStream* /*stream*/, NPReason /*reason*/)
|
|
106 |
{
|
|
107 |
return NPERR_NO_ERROR;
|
|
108 |
}
|
|
109 |
|
|
110 |
/**
|
|
111 |
* A data stream has been fully saved to a file.
|
|
112 |
*/
|
|
113 |
void SvgtPluginAsFile(NPP instance, NPStream* stream, const TDesC& fname)
|
|
114 |
{
|
|
115 |
CSvgtPlugin* lSvgtPlugin = (CSvgtPlugin*)instance->pdata;
|
|
116 |
|
|
117 |
if (lSvgtPlugin && lSvgtPlugin->Control())
|
|
118 |
{
|
|
119 |
lSvgtPlugin->Control()->AsFile(fname, stream );
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
/**
|
|
124 |
* Return the maximum number of bytes this plugin can accept from the stream.
|
|
125 |
*/
|
|
126 |
int32 SvgtPluginWriteReady(NPP /*instance*/, NPStream* /*stream*/)
|
|
127 |
{
|
|
128 |
return 65536;
|
|
129 |
}
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Receive more data
|
|
133 |
* @param buffer - contains the data.
|
|
134 |
* @param len - the number of bytes in buffer.
|
|
135 |
* @param offset - the number of bytes already sent/processed.
|
|
136 |
* @return TInt number of bytes processed.
|
|
137 |
*/
|
|
138 |
int32 SvgtPluginWrite(NPP /*instance*/, NPStream* /*stream*/, int32 /*offset*/, int32 len, void* /*buffer*/)
|
|
139 |
{
|
|
140 |
return len;
|
|
141 |
}
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Event
|
|
145 |
*/
|
|
146 |
int16 SvgtPluginEvent(NPP /*instance*/, void* /*event*/)
|
|
147 |
{
|
|
148 |
return 0;
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Generic hook to set values/attributes within the plugin.
|
|
154 |
*/
|
|
155 |
NPError SvgtPluginSetValue(NPP /*instance*/, NPNVariable /*variable*/, void* /*ret_value*/)
|
|
156 |
{
|
|
157 |
return NPERR_NO_ERROR;
|
|
158 |
}
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Generic hook to get values/attributes from the plugin.
|
|
162 |
*/
|
|
163 |
NPError SvgtPluginGetValue(NPP instance, NPNVariable variable, void*
|
|
164 |
*ret_value)
|
|
165 |
{
|
|
166 |
CSvgtPlugin* lSvgtPlugin = (CSvgtPlugin *)instance->pdata;
|
|
167 |
if(lSvgtPlugin)
|
|
168 |
{
|
|
169 |
// A response of false when enum passed is NPPVpluginInteractiveBool
|
|
170 |
// must be interpreted as "Plugin is interactive"
|
|
171 |
// Since operations such as panning, zooming can be performed
|
|
172 |
// on all svg contents plugin can be considered always interactive
|
|
173 |
if(variable==NPPVpluginInteractiveBool)
|
|
174 |
{
|
|
175 |
*(TBool*) ret_value=EFalse;
|
|
176 |
}
|
|
177 |
}
|
|
178 |
return NPERR_NO_ERROR;
|
|
179 |
}
|
|
180 |
void SvgtPluginURLNotify(NPP /*instance*/, const TDesC& /*url*/, NPReason /*reason*/, void* /*notifyData*/)
|
|
181 |
{
|
|
182 |
}
|
|
183 |
|
|
184 |
void SvgtPluginPrint(NPP /*instance*/, NPPrint* /*platformPrint*/)
|
|
185 |
{
|
|
186 |
}
|