1
0

np_entry.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: NPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Netscape Public License
  6. * Version 1.1 (the "License"); you may not use this file except in
  7. * compliance with the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/NPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the NPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the NPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. //////////////////////////////////////////////////////////////
  38. //
  39. // Main plugin entry point implementation
  40. //
  41. #include "npapi.h"
  42. #include "npupp.h"
  43. #ifndef HIBYTE
  44. #define HIBYTE(x) ((((uint32)(x)) & 0xff00) >> 8)
  45. #endif
  46. NPNetscapeFuncs NPNFuncs;
  47. #ifdef XP_WIN
  48. NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
  49. {
  50. if(pFuncs == NULL)
  51. return NPERR_INVALID_FUNCTABLE_ERROR;
  52. if(pFuncs->size < sizeof(NPPluginFuncs))
  53. return NPERR_INVALID_FUNCTABLE_ERROR;
  54. pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
  55. pFuncs->newp = NPP_New;
  56. pFuncs->destroy = NPP_Destroy;
  57. pFuncs->setwindow = NPP_SetWindow;
  58. pFuncs->newstream = NPP_NewStream;
  59. pFuncs->destroystream = NPP_DestroyStream;
  60. pFuncs->asfile = NPP_StreamAsFile;
  61. pFuncs->writeready = NPP_WriteReady;
  62. pFuncs->write = NPP_Write;
  63. pFuncs->print = NPP_Print;
  64. pFuncs->event = NPP_HandleEvent;
  65. pFuncs->urlnotify = NPP_URLNotify;
  66. pFuncs->getvalue = NPP_GetValue;
  67. pFuncs->setvalue = NPP_SetValue;
  68. pFuncs->javaClass = NULL;
  69. return NPERR_NO_ERROR;
  70. }
  71. #endif /* XP_WIN */
  72. char *NPP_GetMIMEDescription();
  73. char *
  74. NP_GetMIMEDescription()
  75. {
  76. return NPP_GetMIMEDescription();
  77. }
  78. NPError
  79. NP_GetValue(void* future, NPPVariable variable, void *value)
  80. {
  81. return NPP_GetValue((NPP_t *)future, variable, value);
  82. }
  83. NPError OSCALL
  84. NP_Initialize(NPNetscapeFuncs* pFuncs
  85. #ifdef XP_UNIX
  86. , NPPluginFuncs* pluginFuncs
  87. #endif
  88. )
  89. {
  90. if(pFuncs == NULL)
  91. return NPERR_INVALID_FUNCTABLE_ERROR;
  92. if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
  93. return NPERR_INCOMPATIBLE_VERSION_ERROR;
  94. if(pFuncs->size < sizeof(NPNetscapeFuncs))
  95. return NPERR_INVALID_FUNCTABLE_ERROR;
  96. NPNFuncs.size = pFuncs->size;
  97. NPNFuncs.version = pFuncs->version;
  98. NPNFuncs.geturlnotify = pFuncs->geturlnotify;
  99. NPNFuncs.geturl = pFuncs->geturl;
  100. NPNFuncs.posturlnotify = pFuncs->posturlnotify;
  101. NPNFuncs.posturl = pFuncs->posturl;
  102. NPNFuncs.requestread = pFuncs->requestread;
  103. NPNFuncs.newstream = pFuncs->newstream;
  104. NPNFuncs.write = pFuncs->write;
  105. NPNFuncs.destroystream = pFuncs->destroystream;
  106. NPNFuncs.status = pFuncs->status;
  107. NPNFuncs.uagent = pFuncs->uagent;
  108. NPNFuncs.memalloc = pFuncs->memalloc;
  109. NPNFuncs.memfree = pFuncs->memfree;
  110. NPNFuncs.memflush = pFuncs->memflush;
  111. NPNFuncs.reloadplugins = pFuncs->reloadplugins;
  112. NPNFuncs.getJavaEnv = pFuncs->getJavaEnv;
  113. NPNFuncs.getJavaPeer = pFuncs->getJavaPeer;
  114. NPNFuncs.getvalue = pFuncs->getvalue;
  115. NPNFuncs.setvalue = pFuncs->setvalue;
  116. NPNFuncs.invalidaterect = pFuncs->invalidaterect;
  117. NPNFuncs.invalidateregion = pFuncs->invalidateregion;
  118. NPNFuncs.forceredraw = pFuncs->forceredraw;
  119. NPNFuncs.getstringidentifier = pFuncs->getstringidentifier;
  120. NPNFuncs.getstringidentifiers = pFuncs->getstringidentifiers;
  121. NPNFuncs.getintidentifier = pFuncs->getintidentifier;
  122. NPNFuncs.identifierisstring = pFuncs->identifierisstring;
  123. NPNFuncs.utf8fromidentifier = pFuncs->utf8fromidentifier;
  124. NPNFuncs.intfromidentifier = pFuncs->intfromidentifier;
  125. NPNFuncs.createobject = pFuncs->createobject;
  126. NPNFuncs.retainobject = pFuncs->retainobject;
  127. NPNFuncs.releaseobject = pFuncs->releaseobject;
  128. NPNFuncs.invoke = pFuncs->invoke;
  129. NPNFuncs.invokeDefault = pFuncs->invokeDefault;
  130. NPNFuncs.evaluate = pFuncs->evaluate;
  131. NPNFuncs.getproperty = pFuncs->getproperty;
  132. NPNFuncs.setproperty = pFuncs->setproperty;
  133. NPNFuncs.removeproperty = pFuncs->removeproperty;
  134. NPNFuncs.hasproperty = pFuncs->hasproperty;
  135. NPNFuncs.hasmethod = pFuncs->hasmethod;
  136. NPNFuncs.releasevariantvalue = pFuncs->releasevariantvalue;
  137. NPNFuncs.setexception = pFuncs->setexception;
  138. #ifdef XP_UNIX
  139. /*
  140. * Set up the plugin function table that Netscape will use to
  141. * call us. Netscape needs to know about our version and size
  142. * and have a UniversalProcPointer for every function we
  143. * implement.
  144. */
  145. pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
  146. pluginFuncs->size = sizeof(NPPluginFuncs);
  147. pluginFuncs->newp = NewNPP_NewProc(NPP_New);
  148. pluginFuncs->destroy = NewNPP_DestroyProc(NPP_Destroy);
  149. pluginFuncs->setwindow = NewNPP_SetWindowProc(NPP_SetWindow);
  150. pluginFuncs->newstream = NewNPP_NewStreamProc(NPP_NewStream);
  151. pluginFuncs->destroystream = NewNPP_DestroyStreamProc(NPP_DestroyStream);
  152. pluginFuncs->asfile = NewNPP_StreamAsFileProc(NPP_StreamAsFile);
  153. pluginFuncs->writeready = NewNPP_WriteReadyProc(NPP_WriteReady);
  154. pluginFuncs->write = NewNPP_WriteProc(NPP_Write);
  155. pluginFuncs->print = NewNPP_PrintProc(NPP_Print);
  156. pluginFuncs->urlnotify = NewNPP_URLNotifyProc(NPP_URLNotify);
  157. pluginFuncs->event = NULL;
  158. pluginFuncs->getvalue = NewNPP_GetValueProc(NPP_GetValue);
  159. #ifdef OJI
  160. pluginFuncs->javaClass = NPP_GetJavaClass();
  161. #endif
  162. NPP_Initialize();
  163. #endif
  164. return NPERR_NO_ERROR;
  165. }
  166. NPError OSCALL NP_Shutdown()
  167. {
  168. return NPERR_NO_ERROR;
  169. }