[xiph-commits] r3052 - liboggplay/trunk/plugin

shans at svn.annodex.net shans at svn.annodex.net
Mon Jun 25 22:38:04 PDT 2007


Author: shans
Date: 2007-06-25 22:38:03 -0700 (Mon, 25 Jun 2007)
New Revision: 3052

Modified:
   liboggplay/trunk/plugin/plugin.cpp
   liboggplay/trunk/plugin/plugin.h
Log:
Code to retrieve the proxy from firefox



Modified: liboggplay/trunk/plugin/plugin.cpp
===================================================================
--- liboggplay/trunk/plugin/plugin.cpp	2007-06-26 01:09:23 UTC (rev 3051)
+++ liboggplay/trunk/plugin/plugin.cpp	2007-06-26 05:38:03 UTC (rev 3052)
@@ -59,6 +59,11 @@
 #include "nsIServiceManager.h"
 #include "nsIMemory.h"
 #include "nsISupportsUtils.h" // this is where some useful macros defined
+#include "necko/nsIProtocolProxyService.h"
+#include "necko/nsIProxyInfo.h"
+#include "nsIProtocolHandler.h"
+#include "nsEmbedString.h"
+
 #include <npruntime.h>
 
 
@@ -134,6 +139,7 @@
   if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2)
     return NPERR_INCOMPATIBLE_VERSION_ERROR;
 #endif
+
   return NPERR_NO_ERROR;
 }
 
@@ -226,6 +232,7 @@
   mOggHandle(NULL),
   mGuiHandle(NULL),
   mSource(NULL),
+  mServiceManager(NULL),
   mCmmlCallback(NULL),
   mEndPlayCallback(NULL)
 #if defined(XP_MACOSX)
@@ -237,10 +244,54 @@
   mPollingPeriod(POLLING_PERIOD)
 #endif
 {
+  nsISupports             * sm    = NULL;
+  nsIProtocolProxyService * pps   = NULL;
+  nsIProxyInfo            * pi    = NULL;
+  nsIProtocolHandler      * ph    = NULL;
+
   mString[0] = '\0';
   setSource(source);
   SEM_CREATE(mCmmlSem, 1);
   SEM_CREATE(mEndPlaySem, 1);
+
+  NPN_GetValue(NULL, NPNVserviceManager, &sm);
+
+  if (sm) {
+    sm->QueryInterface(NS_GET_IID(nsIServiceManager), 
+          (void **)&mServiceManager);
+    NS_RELEASE(sm);
+  }
+
+  if (mServiceManager) {
+
+    mServiceManager->GetServiceByContractID(
+        "@mozilla.org/network/protocol-proxy-service;1",
+        NS_GET_IID(nsIProtocolProxyService), (void **)&pps);
+    mServiceManager->GetServiceByContractID(
+        "@mozilla.org/network/protocol;1?name=http",
+        NS_GET_IID(nsIProtocolHandler), (void **)&ph);
+
+  }
+
+  if (pps) {
+    nsIURI    * eguri;
+    nsEmbedCString data("http://example.com");
+
+    ph->NewURI(data, NULL, NULL, &eguri);
+    pps->Resolve(eguri, 0, &pi);
+    printf("pi now %p\n", pi);
+  }
+
+  if (pi) {
+    nsEmbedCString host;
+    int            port;
+
+    pi->GetHost(host);
+    pi->GetPort(&port);
+    printf("proxy host is %s\n", host.get());
+    printf("proxy port is %d\n", port);
+  }
+
 }
 
 nsPluginInstance::~nsPluginInstance()

Modified: liboggplay/trunk/plugin/plugin.h
===================================================================
--- liboggplay/trunk/plugin/plugin.h	2007-06-26 01:09:23 UTC (rev 3051)
+++ liboggplay/trunk/plugin/plugin.h	2007-06-26 05:38:03 UTC (rev 3052)
@@ -40,6 +40,7 @@
 
 #include "pluginbase.h"
 #include "nsScriptablePeer.h"
+#include "nsIServiceManager.h"
 #include "std_semaphore.h"
 
 #if defined(XP_UX)
@@ -137,7 +138,8 @@
   nsScriptablePeer  * mScriptablePeer;
   void              * mOggHandle;
   void              * mGuiHandle;
-  char              * mSource;  
+  char              * mSource;
+  nsIServiceManager * mServiceManager;
 
   nsILibOggCallbackString   * mCmmlCallback;
   nsILibOggCallbackNoArg    * mEndPlayCallback;



More information about the commits mailing list