⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qnp.cpp

📁 这个是Linux的qt源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	  uint16 *stype){    _NPInstance* This;    if (instance == NULL)	return NPERR_INVALID_INSTANCE_ERROR;    This = (_NPInstance*) instance->pdata;    if ( This ) {	QNPStream* qnps = new QNPStream(This->instance,type,stream,seekable);	stream->pdata = qnps;	QNPInstance::StreamMode sm = (QNPInstance::StreamMode)*stype;	if (!This->instance->newStreamCreated(qnps, sm)) {	    return NPERR_GENERIC_ERROR;	}	*stype = sm;    }    return NPERR_NO_ERROR;}int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile				   * mode so we can take any size stream in our				   * write call (since we ignore it) */extern "C" int32NPP_WriteReady(NPP instance, NPStream *stream){    _NPInstance* This;    if (instance != NULL) {	This = (_NPInstance*) instance->pdata;    } else {	// Yikes, that's unusual!	return 0;    }    if (This) {	return This->instance->writeReady((QNPStream*)stream->pdata);    }    /* Number of bytes ready to accept in NPP_Write() */    return STREAMBUFSIZE;}extern "C" int32NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer){    if (instance != NULL)    {	_NPInstance* This = (_NPInstance*) instance->pdata;	if (This) {	    return This->instance->write((QNPStream*)stream->pdata,		offset, len, buffer);	}    }    return len;        /* The number of bytes accepted */}extern "C" NPErrorNPP_DestroyStream(NPP instance, NPStream *stream, NPError reason){    _NPInstance* This;    if (instance == NULL)	return NPERR_INVALID_INSTANCE_ERROR;    if (!qnps_no_call_back) {	This = (_NPInstance*) instance->pdata;	QNPStream* qnps = (QNPStream*)stream->pdata;	if ( qnps )	    switch (reason) {		case NPRES_DONE:		    qnps->setComplete(TRUE);		    break;		case NPRES_USER_BREAK:		    break;		case NPRES_NETWORK_ERR:		    qnps->setOkay(FALSE);		    break;	    }	if (This) {	    // Give the instance a chance to do something	    This->instance->streamDestroyed(qnps);	}	qnps_no_call_back++;	delete qnps;	qnps_no_call_back--;    }    return NPERR_NO_ERROR;}extern "C" voidNPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname){    _NPInstance* This;    if (instance == NULL) return;    This = (_NPInstance*) instance->pdata;    if ( This ) {	QNPStream* qnps = (QNPStream*)stream->pdata;	This->instance->streamAsFile(qnps, fname);    }}typedef struct{    int32    type;    FILE*    fp;} NPPrintCallbackStruct;#ifdef Q_WS_X11class QNPPrinter : public QPrinter {    QFile file;public:    QNPPrinter(FILE* fp)    {	file.open(IO_WriteOnly, fp);	QPDevCmdParam param;	param.device = &file;	cmd(PdcSetdev, 0, &param);    }    void end()    {	QPDevCmdParam param;	param.device = 0;	cmd(PdcSetdev, 0, &param);    }};#endifextern "C" voidNPP_Print(NPP instance, NPPrint* printInfo){    if(printInfo == NULL)	return;    if (instance != NULL) {	_NPInstance* This = (_NPInstance*) instance->pdata;	if (printInfo->mode == NP_FULL) {	    printInfo->print.fullPrint.pluginPrinted =		This->instance->printFullPage();	} else if (printInfo->mode == NP_EMBED) {#ifdef Q_WS_X11	    void* platformPrint =		printInfo->print.embedPrint.platformPrint;	    FILE* outfile = ((NPPrintCallbackStruct*)platformPrint)->fp;	    if (ftell(outfile)) {// 		NPWindow* w =// 		    &(printInfo->print.embedPrint.window);		QNPPrinter prn(outfile);		QPainter painter(&prn);		// #### config viewport with w->{x,y,width,height}		This->instance->print(&painter);		prn.end();	    } else {		// Why does the browser make spurious NPP_Print calls?	    }#endif#ifdef Q_WS_WIN	    NPWindow* printWindow =		&(printInfo->print.embedPrint.window);	    void* platformPrint =		printInfo->print.embedPrint.platformPrint;	    // #### Nothing yet.#endif	}    }}extern "C" voidNPP_URLNotify(NPP instance,	      const char* url,	      NPReason reason,	      void* notifyData){    if (instance != NULL) {	QNPInstance::Reason r;	switch (reason) {	case NPRES_DONE:	    r = QNPInstance::ReasonDone;	    break;	case NPRES_USER_BREAK:	    r = QNPInstance::ReasonBreak;	    break;	case NPRES_NETWORK_ERR:	    r = QNPInstance::ReasonError;	    break;	default:	    r = QNPInstance::ReasonUnknown;	    break;	}	_NPInstance* This = (_NPInstance*) instance->pdata;	This->instance->notifyURL(url, r, notifyData);    }}#ifdef Q_WS_WINBOOL   WINAPI   DllMain (HANDLE hInst,			ULONG ul_reason_for_call,			LPVOID lpReserved){    return TRUE;}#endif/*!    \class QNPWidget qnp.h    \brief The QNPWidget class provides a QWidget that is a Web-browser plugin window.    \extension Netscape Plugin    Derive from QNPWidget to create a widget that can be used as a    Browser plugin window, or create one and add child widgets.    Instances of QNPWidget may only be created when    QNPInstance::newWindow() is called by the browser.    A common way to develop a plugin widget is to develop it as a    stand-alone application window, then make it a \e child of a    plugin widget to use it as a browser plugin. The technique is:\codeclass MyPluginWindow : public QNPWidget{    QWidget* child;public:    MyPluginWindow()    {	// Some widget that is normally used as a top-level widget	child = new MyIndependentlyDevelopedWidget();	// Use the background color of the web page	child->setBackgroundColor( backgroundColor() );	// Fill the plugin widget	child->setGeometry( 0, 0, width(), height() );    }    void resizeEvent(QResizeEvent*)    {	// Fill the plugin widget	child->resize(size());    }};\endcode    The default implementation is an empty window.*//*!    Creates a QNPWidget.*/QNPWidget::QNPWidget() :     pi(next_pi){    if (!next_pi) {	qFatal("QNPWidget must only be created within call to newWindow");    }    next_pi->widget = this;    next_pi = 0;#ifdef Q_WS_WIN    clearWFlags( WStyle_NormalBorder | WStyle_Title | WStyle_MinMax | WStyle_SysMenu );    topData()->ftop = 0;    topData()->fright = 0;    topData()->fleft = 0;    topData()->fbottom = 0;#endif}/*!    Destroys the window. This will be called by the plugin binding    code when the window is no longer required. The Web-browser will    delete windows when they leave the page. The bindings will change    the QWidget::winId() of the window when the window is resized, but    this should not affect normal widget behavior.*/QNPWidget::~QNPWidget(){#ifdef Q_WS_X11    destroy( FALSE, FALSE ); // X has destroyed all windows#endif}/*!\internal */void QNPWidget::enterEvent(QEvent*){    enterInstance();}/*!\internal */void QNPWidget:: leaveEvent(QEvent*){    if ( !QApplication::activePopupWidget() )	leaveInstance();}/*!    Called when the mouse enters the plugin window. Does nothing by    default.*/void QNPWidget::enterInstance(){}/*!    Called when the mouse leaves the plugin window. Does nothing by    default.*/void QNPWidget::leaveInstance(){}/*!    Returns the instance for which this widget is the window.*/QNPInstance* QNPWidget::instance(){    return pi->instance;}/*!    \class QNPInstance qnp.h    \brief The QNPInstance class provides a QObject that is a Web-browser plugin.    \extension Netscape Plugin    Deriving from QNPInstance creates an object that represents a    single \c{<EMBED>} tag in an HTML document.    The QNPInstance is responsible for creating an appropriate    QNPWidget window if required (not all plugins have windows), and    for interacting with the input/output facilities intrinsic to    plugins.    Note that there is \e{absolutely no guarantee} regarding the order    in which functions are called. Sometimes the browser will call    newWindow() first, at other times, newStreamCreated() will be    called first (assuming the \c{<EMBED>} tag has a SRC parameter).    \e{None of Qt's GUI functionality} may be used until after the    first call to newWindow(). This includes any use of QPaintDevice    (ie. QPixmap, QWidget, and all subclasses), QApplication, anything    related to QPainter (QBrush, etc.), fonts, QMovie, QToolTip, etc.    Useful classes which specifically \e can be used are QImage,    QFile, and QBuffer.    This restriction can easily be accommodated by structuring your    plugin so that the task of the QNPInstance is to gather data,    while the task of the QNPWidget is to provide a graphical    interface to that data,*//*!    \enum QNPInstance::InstanceMode    This enum type provides Qt-style names for three #defines in    \c npapi.h:    \value Embed - corresponds to NP_EMBED    \value Full - corresponds to NP_FULL    \value Background - corresponds to NP_BACKGROUND*//*!    \enum QNPInstance::Reason    \value ReasonDone    \value ReasonBreak    \value ReasonError    \value ReasonUnknown*//*!    \enum QNPInstance::StreamMode    \value Normal    \value Seek    \value AsFile    \value AsFileOnly*//*!    Creates a QNPInstance.    Can only be called from within a derived class created within    QNPlugin::newInstance().*/QNPInstance::QNPInstance() :    pi(next_pi){    if (!next_pi) {	qFatal("QNPInstance must only be created within call to newInstance");    }    next_pi->instance = this;    next_pi = 0;}/*!    Called when the plugin instance is about to disappear.*/QNPInstance::~QNPInstance(){}/*!    Called at most once, at some time after the QNPInstance is    created. If the plugin requires a window, this function should    return a derived class of QNPWidget that provides the required    interface.*/QNPWidget* QNPInstance::newWindow(){    // No window by default    next_pi = 0;    return 0;}/*!    Returns the plugin window created by newWindow(), if any.*/QNPWidget* QNPInstance::widget(){    return pi->widget;}/*!    \fn bool QNPInstance::newStreamCreated(QNPStream*, StreamMode& smode)    This function is called when a new stream has been created. The    instance should return TRUE if it accepts the processing of the    stream. If the instance requires the stream as a file, it should    set \a smode to \c AsFileOnly, in which case the data will be    delivered some time later to the streamAsFile() function.    Otherwise, the data will be delivered in chunks to the write()    function which must consume at least as much data as was returned    by the most recent call to writeReady().    Note that the \c AsFileOnly method is not supported by Netscape    2.0 and MSIE 3.0.    The default implementation accepts any stream.*/bool QNPInstance::newStreamCreated(QNPStream*, StreamMode&){    return TRUE;}/*!    Called when a stream is delivered as a single file called \a fname    rather than as chunks. This may be simpler for a plugin to deal    with, but precludes any incremental behavior.    Note that the \c AsFileOnly method is not supported by Netscape    2.0 and MSIE 3.0.    \sa newStreamCreated(), newStream()*/void QNPInstance::streamAsFile(QNPStream*, const char*){}/*!    Called when a stream is destroyed. At this point, the stream may    be complete() and okay(). If it is not okay(), then an error has    occurred. If it is okay(), but not complete(), then the user has    cancelled the transmission: do not give an error message in this    case.*/void QNPInstance::streamDestroyed(QNPStream*){}/*!    Returns the minimum amount of data the instance is willing to    receive from the given stream.    The default returns a very large value.*/int QNPInstance::writeReady(QNPStream*){    // Yes, we can handle any amount of data at once.    return 0X0FFFFFFF;}/*!    \fn int QNPInstance::write(QNPStream*, int offset, int len, void* buffer)    Called when incoming data is available for processing by the    instance. The instance \e must consume at least the amount that it    returned in the most recent call to writeReady(), but it may

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -