]> git.sesse.net Git - vlc/blob - mozilla/vlcplugin.cpp
- the resurected mozilla plugin for Safari/Firefox on MacOS X
[vlc] / mozilla / vlcplugin.cpp
1 /*****************************************************************************
2  * vlcplugin.cpp: a VLC plugin for Mozilla
3  *****************************************************************************
4  * Copyright (C) 2002-2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include "config.h"
28
29 #include <vlc/vlc.h>
30
31 #ifdef HAVE_MOZILLA_CONFIG_H
32 #   include <mozilla-config.h>
33 #endif
34 #include <nsISupports.h>
35 #include <nsMemory.h>
36 #include <npapi.h>
37
38 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
39 #define XP_UNIX 1
40 #elif defined(XP_MACOSX)
41 #undef XP_UNIX
42 #endif
43
44 #include "vlcplugin.h"
45
46 /*****************************************************************************
47  * VlcPlugin constructor and destructor
48  *****************************************************************************/
49 VlcPlugin::VlcPlugin( NPP instance )
50 {
51     p_instance = instance;
52     p_peer = NULL;
53 }
54
55
56 VlcPlugin::~VlcPlugin()
57 {
58     if( p_peer )
59     {
60         p_peer->Disable();
61         p_peer->Release();
62     }
63 }
64
65
66 /*****************************************************************************
67  * VlcPlugin methods
68  *****************************************************************************/
69 void VlcPlugin::SetInstance( NPP instance )
70 {
71     p_instance = instance;
72 }
73
74
75 NPP VlcPlugin::GetInstance()
76 {
77     return p_instance;
78 }
79
80
81 VlcIntf* VlcPlugin::GetPeer()
82 {
83     if( !p_peer )
84     {
85         p_peer = new VlcPeer( this );
86         if( p_peer == NULL )
87         {
88             return NULL;
89         }
90
91         NS_ADDREF( p_peer );
92     }
93
94     NS_ADDREF( p_peer );
95     return p_peer;
96 }
97