작성ìž: [hyacinth] 작성ì¼: [[Date(2013-04-01T05:38:07)]] [[TableOfContents]] == 들어가며 == NPAPIê³¼ NPRuntimeì— ëŒ€í•´ ì•Œê³ ì‹¶ìœ¼ë©´ 여기[[Footnote(http://theweak.tistory.com/1)]][[Footnote(http://breakstone.blog.qrobo.com/2009/05/28/npruntime-0-compile/)]] ë“±ì„ ì°¸ì¡°í•˜ë©´ ëœë‹¤. 요약하면 ì˜›ë‚ ë„·ìŠ¤ì¼€ì´í”„ ì‹œì ˆ 개발ë˜ë˜ í”ŒëŸ¬ê·¸ì¸ APIê°€ ì´í›„ ëª¨ì§ˆë¼ ê³„ì—´ 브ë¼ìš°ì €ì—ì„œ 남아있게 ë˜ì–´ 파ì´ì–´í스, í¬ë¡¬, 사파리, 오페ë¼ì—ì„œ 지ì›í•˜ê²Œ ë˜ì—ˆê³ ë”°ë¼ì„œ NPAPI 플러그ì¸ì„ 만들면 IE를 ì œì™¸í•œ 브ë¼ìš°ì € 아무 것ì—서나 ëŒì•„가게 ëœ ê²ƒì´ë‹¤. NPRuntimeì€ í”ŒëŸ¬ê·¸ì¸ì—ì„œ 웹브ë¼ìš°ì €ë¡œ ëª…ë ¹ì„ ì „ë‹¬í•´ 줄 수 있는 NPAPIì˜ í™•ìž¥ë²„ì „ì´ë‹¤. 즉 NPAPI+추가APIì˜ í˜•íƒœì´ë‹¤. ì´ íŽ˜ì´ì§€ì—서는 2013ë…„ 4ì›” 1ì¼ í˜„ìž¬ ìµœì‹ Gecko SDK[[Footnote(XULRunner SDKë¡œë„ ì•Œë ¤ì ¸ 있다.)]](19.0.2)와 ìµœì‹ ë¹„ì£¼ì–¼ 스튜디오(VS2008/2010/2012)를 사용한 NPAPI Hello world 를 만드는 ë°©ë²•ì„ ì†Œê°œí•œë‹¤. Gecko SDK 1.9 부터 프로ì 트 구성 방법과 í—¤ë”와 íƒ€ìž…ì´ ë§Žì´ ë°”ë€Œì–´ ë²„ë ¸ê¸° ë•Œë¬¸ì— 1.9 ë²„ì „ ì˜ˆì œë“¤ì€ ë³€ê²½ì´ í•„ìš”í•˜ë‹¤. ì´ì— 대한 ìžì„¸í•œ ë°©ë²•ì„ ì†Œê°œí•œë‹¤. ë ˆí¼ëŸ°ìŠ¤ 사ì´íŠ¸ https://developer.mozilla.org/en-US/docs/Plugins == Gecko SDK 빌드 환경 구성 == === 다운로드 === https://developer.mozilla.org/en-US/docs/Gecko_SDK 1. Get SDK for Windows 2. íŠ¹ì • ë””ë ‰í† ë¦¬ì— ì••ì¶•ì„ í•´ì œí•œë‹¤. 3. ì••ì¶•ì„ í•´ì œí•œ 곳으로 VC++ í¬í•¨ íŒŒì¼ ë””ë ‰í„°ë¦¬ë¥¼ ì„¤ì •í•œë‹¤. {{{ \xulrunner-sdk\include }}} == NPAPI 프로ì 트 만들기 == === Hello World 프로ì 트 === || attachment:nphelloplugin_vs2012.zip || || attachment:nphelloplugin_vs2010.zip || || attachment:nphelloplugin_vs2008.zip || === 빈 프로ì 트 ìƒì„± === Win32 프로ì 트 > ì‘ìš© 프로그램 종류 DLL > 빈 프로ì 트 === íŒŒì¼ ì¶”ê°€ === 모듈 ì •ì˜ íŒŒì¼ (.def) 리소스 íŒŒì¼ (.rc) Sources np_entry.cpp npn_gate.cpp npp_gate.cpp plugin.cpp Header plugin.h === 코드 추가 === npHelloPlugin.def {{{#!gcode LIBRARY "npHelloPlugin" EXPORTS NP_GetEntryPoints @1 NP_Initialize @2 NP_Shutdown @3 }}} npHelloPlugin.rc {{{#!gcode ... BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904e4" BEGIN ... VALUE "MIMEType", "application/hello-world-plugin" // npHelloPlugin.rc를 코드 보기로 ì—´ì–´ 추가 ... }}} np_entry.cpp ì˜ˆì œ 프로ì 트 참조 npn_gate.cpp ì˜ˆì œ 프로ì 트 참조 npp_gate.cpp ì˜ˆì œ 프로ì 트 참조 plugin.cpp ì˜ˆì œ 프로ì 트 참조 plugin.h ì˜ˆì œ 프로ì 트 참조 === 프로ì 트 ì†ì„± === C/C++ {{{ 추가 í¬í•¨ ë””ë ‰í„°ë¦¬ "D:\...\xulrunner-sdk\include" ì „ì²˜ë¦¬ê¸° _X86_ 추가 }}} === 빌드 === === ì¡°ê±´ === 1. í”ŒëŸ¬ê·¸ì¸ dll íŒŒì¼ ì´ë¦„ì´ ë°˜ë“œì‹œ npë¡œ 시작해야 한다. 2. 리소스(.rc)ì˜ ë¹Œë“œ 언어 ì„¤ì •ì´ ì˜ì–´(미êµ)ì´ì—¬ì•¼ë§Œ 한다. (í•œê¸€ì¼ ë•Œ í¬ë¡¬ì—서는 플러그ì¸ìœ¼ë¡œ ì¸ì‹ ë˜ì§€ë§Œ FFì—는 플러그ì¸ì„ ì°¾ì„ ìˆ˜ 없다.) == NPAPI 프로ì 트 만들기 (2) == === 메서드 추가 === TestMethod1 ë¼ëŠ” 메서드를 만들어 ë³´ìž. 1. plugin.cpp ì‹ë³„ìž ì¶”ê°€ {{{#!gcode static NPIdentifier sfuncTestMethod1_id; }}} bool HasMethod() {{{#!gcode bool ScriptablePluginObject::HasMethod(NPIdentifier name) { return (name == sFoo_id)|| (name == sfuncTestMethod1_id); // ... ì‹ë³„ìž ì¶”ê°€ } }}} bool Invoke() {{{#!gcode bool ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { if (name == sfuncTestMethod1_id) { // 메서드 ë™ìž‘ 구현 char buffer[] = "sfuncTestMethod1_id return"; uint32_t len = strlen(buffer) + 1; char *copy = (char*)NPN_MemAlloc(len); strncpy(copy, buffer, len); STRINGZ_TO_NPVARIANT(copy, *result); return PR_TRUE; } return PR_FALSE; } }}} == Gecko 1.9 -> Gecko 19.0.2 ì˜ˆì œ 코드 ìƒ ë³€ê²½í•´ì•¼ í• ì == {{{#!gcode }}} == 플러그ì¸ì„ 웹 페ì´ì§€ì— 추가 == {{{#!gcode <embed id="pluginobj" type="application/hello-world-plugin" border=1 width=0 height=0> <form method="post" name="form1"> <input type="button" value="메서드 테스트" onclick="alert(pluginobj.TestFunc('param0','param1'))" /> </from> }}} ---- CategoryDocument