感謝您的幫助和建議。
即使我將.so文件放入正確的文件夾 /usr/lib/mozilla/plugins /和Qt Lib路徑中,我也能找出問題,爲什麼我的插件沒有被調用, 。
有兩個原因...
不得不啓用編譯爲編譯器指令中的定義XP_UNIX(-DXP_UNIX)。 這會考慮的功能不同的原型,並實現
extern "C"
NPError OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs
#ifdef XP_UNIX
, NPPluginFuncs *pluginFuncs
#endif
)
{
// keep a pointer to the browser functions
g_browser = browserFuncs;
// any memory that is to be shared by all instances of
the browser plugin should be initialized here.
;
#ifdef XP_UNIX
// under Linux, as the browser won't call NP_GetEntryPoints()
explicitly, do it now to fill in <pluginFuncs>
return NP_GetEntryPoints(pluginFuncs);
#else
return NPERR_NO_ERROR;
#endif
}
和
extern "C"
#ifdef XP_UNIX
NPError NP_GetValue(void* instance, NPPVariable variable, void *value)
#else
NPError NP_GetValue(NPP instance, NPPVariable variable, void *value)
#endif
2 ..有2個功能NP_GetValue和NPP_GetValue。
extern "C"
NPError NP_GetValue(void* instance, NPPVariable variable, void *value);
和
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *ret_value);
NPP_GetValue是一個插件功能,其登記的,應當在 NP_GetEntryPoints
extern "C"
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* NPPluginFuncsptr)
{
......
NPPluginFuncsptr->newp = NPP_New;
NPPluginFuncsptr->getvalue = NPP_GetValue;
NPPluginFuncsptr->setvalue = NPP_SetValue;
return NPERR_NO_ERROR;
}
進行在我的代碼只有NP_GetValue年實施NPP_GetValue沒有落實。 因此,NPP_GetValue在.so中未定義,由於它沒有加載.so。
在實現函數NPP_GetValue時,該函數被定義並導出到.so文件中,並且能夠成功加載它。
從瀏覽器中調用的功能,插件是如下的順序...
NP_Initialize - >瀏覽器首先調用初始化函數。>從NP_Initialize爲Linux明確提出到 暴露/導出插件功能 -
NP_GetEntryPoints(在Linux中的情況下,一套插件功能應通過調用 NP_GetEntryPoints明確地作爲瀏覽器不會叫GetEntryPoints出口)。
NP_GetValue變量:1 - >從瀏覽器調用以獲取插件名稱 (NPPVpluginNameString)
NP_GetValue變量:2 - 從瀏覽器>調用以獲取 插件說明(NPPVpluginDescriptionString)
NP_GetMimeDescription - >從瀏覽器中調用以獲得MimeType描述 (該函數應該返回Mime類型描述 例如: 返回(「application/basic-plugin:bsc:Plug-in SDK sample」);)
NPP_New - >從瀏覽器調用創建插件實例。
NPP_GetValue插件:main.cpp中,NPP_GetValue,446ENTRY - >從瀏覽器插件獲取特定數據調用...
......
請注意以上順序中的下一個函數將被稱爲 IF和ONLY如果前一個函數調用返回成功。:-)
它顯示在about:plugins? – taxilian 2012-07-13 23:02:35
嗨它不顯示在about:插件在Mozilla中。我無法弄清楚爲什麼..... – Techtotie 2012-07-16 05:09:16
嘗試在調試模式下加載firefox(firefox -g);你可能會在輸出中看到一些有用的東西。當你到達gdb控制檯時,只需鍵入run – taxilian 2012-07-16 06:41:05