"Fossies" - the Fresh Open Source Software Archive

Member "google-gadgets-for-linux-0.11.2/ggadget/npapi/npapi_plugin.h" (15 Mar 2009, 4489 Bytes) of package /linux/misc/old/google-gadgets-for-linux-0.11.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2   Copyright 2008 Google Inc.
    3 
    4   Licensed under the Apache License, Version 2.0 (the "License");
    5   you may not use this file except in compliance with the License.
    6   You may obtain a copy of the License at
    7 
    8        http://www.apache.org/licenses/LICENSE-2.0
    9 
   10   Unless required by applicable law or agreed to in writing, software
   11   distributed under the License is distributed on an "AS IS" BASIS,
   12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13   See the License for the specific language governing permissions and
   14   limitations under the License.
   15 */
   16 
   17 #ifndef GGADGET_NPAPI_NPAPI_PLUGIN_H__
   18 #define GGADGET_NPAPI_NPAPI_PLUGIN_H__
   19 
   20 #include <string>
   21 #include <ggadget/common.h>
   22 #include <ggadget/math_utils.h>
   23 #include <ggadget/string_utils.h>
   24 #include <ggadget/small_object.h>
   25 
   26 struct _NPWindow;
   27 
   28 namespace ggadget {
   29 
   30 class BasicElement;
   31 class ScriptableInterface;
   32 class Connection;
   33 template <typename R, typename P1> class Slot1;
   34 
   35 namespace npapi {
   36 
   37 /**
   38  * @defgroup NPAPILibrary libggadget-npapi - the NPAPI wrapper
   39  * @ingroup SharedLibraries
   40  *
   41  * This shared library contains a wrapper for NPAPI plugins, so that C++ and
   42  * javascript code can access them easily. The most important usage is to
   43  * support adobe flash plugin.
   44  */
   45 
   46 /**
   47  * @ingroup NPAPILibrary
   48  * Represents a npapi plugin instance.
   49  */
   50 class Plugin : public SmallObject<> {
   51  public:
   52   /**
   53    * Destroys the plugin instance.
   54    */
   55   void Destroy();
   56 
   57   /** Get the name of the plugin. */
   58   std::string GetName() const;
   59 
   60   /** Get the description of the plugin. */
   61   std::string GetDescription() const;
   62 
   63   /**
   64    * Get if the plugin is in windowlesss or windowed mode.
   65    * The Host should call this first to determine the window type before
   66    * calling SetWindow.
   67    */
   68   bool IsWindowless() const;
   69 
   70   /**
   71    * Setup the plugin window.
   72    * The host should reset the window if window meta changes, such as resize,
   73    * changing view, etc.. This class will make a copy of the window object
   74    * passed in.
   75    *
   76    * @param top_window the native handle of the top level window. On X, this
   77    *     should be a X Window ID.
   78    * @param window NPAPI window structure.
   79    * @return false if the windowless mode of the window parameter doesn't match
   80    *     the current windowless state of the plugin.
   81    */
   82   bool SetWindow(void *top_window, const _NPWindow &window);
   83 
   84   /** Set URL of the stream that will consumed by the plugin. */
   85 //  bool SetURL(const char *url);
   86 
   87   /**
   88    * Returns true if the plugin is in transparent mode, otherwise returns false.
   89    */
   90   bool IsTransparent() const;
   91 
   92   /**
   93    * Set the data source of the plugin.
   94    * @param src a http/https or local file URL or a local file path.
   95    */
   96   void SetSrc(const char *src);
   97 
   98   /**
   99    * Delegates a native event to the plugin. Only use this interface for
  100    * windowless mode, as X server sends events to the plugin directly if the
  101    * plugin has its own window.
  102    *
  103    * @param event point to the native event. On GTK2 platform, the event should
  104    *     be a pointer to a XEvent struct.
  105    * @return @c true if the event has been handled by the plugin.
  106    */
  107   bool HandleEvent(void *event);
  108 
  109   /**
  110    * Set handler that will be called when plugin wants to show some
  111    * status message.
  112    */
  113   Connection *ConnectOnNewMessage(Slot1<void, const char *> *handler);
  114 
  115   /**
  116    * Scriptable entry for the plugin. The host should register this
  117    * root object as a constant that can be accessed from script such
  118    * as Javascript.
  119    */
  120   ScriptableInterface *GetScriptablePlugin();
  121 
  122   /**
  123    * Gets and resets the current dirty rectangle that needs to be redrawn next
  124    * time. If the Rectangle is kWholePluginRect, the whole plugin need to be
  125    * redrawn.
  126    */
  127   Rectangle GetDirtyRect() const;
  128   void ResetDirtyRect();
  129 
  130   static const Rectangle kWholePluginRect;
  131 
  132  public:
  133   /**
  134    * Creates a new Plugin instance.
  135    * @param mime_type MIME type of the content.
  136    * @param element the container element.
  137    * @param top_window see SetWindow().
  138    * @param window see SetWindow().
  139    * @param parameters initial arguments.
  140    */
  141   static Plugin *Create(const char *mime_type, BasicElement *element,
  142                         void *top_window, const _NPWindow &window,
  143                         const StringMap &parameters);
  144 
  145  private:
  146   DISALLOW_EVIL_CONSTRUCTORS(Plugin);
  147   Plugin();
  148   ~Plugin();
  149 
  150   class Impl;
  151   Impl *impl_;
  152 };
  153 
  154 } // namespace npapi
  155 } // namespace ggadget
  156 
  157 #endif // GGADGET_NPAPI_NPAPI_PLUGIN_H__