Author: rolf
Date: 2007-10-08 15:04:41 -0400 (Mon, 08 Oct 2007)
New Revision: 87118
Modified:
trunk/moon/plugin/ChangeLog
trunk/moon/plugin/downloader.cpp
trunk/moon/plugin/plugin-class.cpp
trunk/moon/plugin/plugin.cpp
trunk/moon/plugin/plugin.h
trunk/moon/src/ChangeLog
trunk/moon/src/canvas.cpp
trunk/moon/src/canvas.h
trunk/moon/src/downloader.cpp
trunk/moon/src/downloader.h
trunk/moon/src/media.cpp
trunk/moon/src/playlist.cpp
trunk/moon/src/runtime.cpp
trunk/moon/src/runtime.h
trunk/moon/src/text.cpp
trunk/moon/src/uielement.h
trunk/moon/src/visual.h
trunk/moon/src/xaml.cpp
Log:
* src/xaml.cpp: Set the surface of newly created objects (where
applicable).
* src/canvas.h, src/uielement.h, src/canvas.cpp: Move the surface field
to Visual.
* src/playlist.cpp, src/media.cpp, src/text.cpp: Create the downloader
using Surface' brand new CreateDownloader method.
* src/visual.h: Added a surface field, complete with setters and
getters.
* src/downloader.cpp, src/downloader.h: Add a context field.
* src/runtime.h: Add a downloader_context field, and CreateDownloader
methods.
* src/runtime.cpp: Add a downloader_context field.
* plugin/plugin.cpp: Set the downloader context of the surface.
* plugin/downloader.cpp: Ref/unref the downloader we store. Get the
context stored in the downloader if possible, and use it to get the
plugin instance.
* plugin/plugin-class.cpp: Use the brand new
PluginInstance::CreateDownloader, and provide xaml loaders for the
xaml_create_from* methods.
* plugin/plugin.h: Add a CreateDownloader method.
Modified: trunk/moon/plugin/ChangeLog
===================================================================
--- trunk/moon/plugin/ChangeLog 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/plugin/ChangeLog 2007-10-08 19:04:41 UTC (rev 87118)
@@ -1,3 +1,12 @@
+2007-10-08 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+
+ * plugin.cpp: Set the downloader context of the surface.
+ * downloader.cpp: Ref/unref the downloader we store. Get the context
stored
+ in the downloader if possible, and use it to get the plugin instance.
+ * plugin-class.cpp: Use the brand new PluginInstance::CreateDownloader,
and
+ provide xaml loaders for the xaml_create_from* methods.
+ * plugin.h: Add a CreateDownloader method.
+
2007-10-04 Zoltan Varga <[EMAIL PROTECTED]>
* plugin.cpp (LoadUrl): New method to download stuff synchronously
using the browser.
Modified: trunk/moon/plugin/downloader.cpp
===================================================================
--- trunk/moon/plugin/downloader.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/plugin/downloader.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -22,12 +22,14 @@
this->dl = dl;
this->verb = NULL;
this->uri = NULL;
+ //base_ref (dl);
}
~PluginDownloader ()
{
g_free (verb);
g_free (uri);
+ //base_unref (dl);
}
Downloader *dl;
@@ -67,18 +69,19 @@
// fprintf (stderr, "PluginDownloaderSend: Starting downloader
again for (%s %s)\n", pd->verb, pd->uri);
//
- // This is a hack: we need the p_downloader_create_state to provide us
- // with the pointer to this plugin. Currently we do not track this
- // information, but we will
- //
- // At this point, we merely steal the first plugin to do this,
- // but that is wrong (if that instance is killed, its download
- // will not complete
- //
- if (plugin_instances->data) {
+ NPP_t* plugin = NULL;
+ if (pd && pd->dl && pd->dl->GetContext ()) {
+ // Get the context from the downloader.
+ plugin = ((PluginInstance*) pd->dl->GetContext ())->getInstance
();
+ } else if (plugin_instances && plugin_instances->data) {
+ // TODO: Review if we really should allowing download with the
first plugin.
+ plugin = (NPP_t*) plugin_instances->data;
+ printf ("DOWNLOADING WITH FIRST PLUGIN (%p), (Downloader->id:
%i): %s\n", plugin, pd->dl->id, pd->uri);
+ }
+ if (plugin && pd) {
StreamNotify *notify = new StreamNotify
(StreamNotify::DOWNLOADER, pd->dl);
- NPN_GetURLNotify ((NPP_t *) plugin_instances->data, pd->uri,
NULL, notify);
+ NPN_GetURLNotify (plugin, pd->uri, NULL, notify);
}
//
Modified: trunk/moon/plugin/plugin-class.cpp
===================================================================
--- trunk/moon/plugin/plugin-class.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/plugin/plugin-class.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -1085,10 +1085,9 @@
NPObject *obj = NULL;
const char *object_type = NPVARIANT_TO_STRING
(args[0]).utf8characters;
if (!g_strcasecmp ("downloader", object_type)) {
+ PluginInstance *plugin = (PluginInstance*)
((MoonlightObject*)npobj)->instance->pdata;
+ Downloader *dl = PluginInstance::CreateDownloader
(plugin);
- Downloader *dl = new Downloader ();
-
-
obj = EventObjectCreateWrapper
(((MoonlightObject*)npobj)->instance, dl);
dl->unref ();
@@ -1437,9 +1436,9 @@
moonlight_content_invoke (NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount, NPVariant
*result)
{
+ PluginInstance *plugin = (PluginInstance*)
((MoonlightObject*)npobj)->instance->pdata;
+
if (name_matches (name, "findName")) {
- PluginInstance *plugin = (PluginInstance*)
((MoonlightObject*)npobj)->instance->pdata;
-
if (!argCount)
return true;
@@ -1466,11 +1465,15 @@
char *xaml = (char *) NPVARIANT_TO_STRING
(args[0]).utf8characters;
Type::Kind element_type;
- DependencyObject *dep = xaml_create_from_str (NULL, xaml,
false, &element_type);
+ XamlLoader *loader = PluginXamlLoader::FromStr (xaml, plugin,
plugin->surface);
+ DependencyObject *dep = xaml_create_from_str (loader, xaml,
false, &element_type);
+ delete loader;
- MoonlightEventObjectObject *depobj =
- EventObjectCreateWrapper
(((MoonlightObject*)npobj)->instance, dep);
- dep->unref ();
+ MoonlightEventObjectObject *depobj = NULL;
+ if (dep != NULL) {
+ depobj = EventObjectCreateWrapper
(((MoonlightObject*)npobj)->instance, dep);
+ dep->unref ();
+ }
OBJECT_TO_NPVARIANT (depobj, *result);
@@ -1490,7 +1493,9 @@
char *fname = down->GetResponseFile ((char *)
NPVARIANT_TO_STRING (args[1]).utf8characters);
if (fname != NULL) {
- dep = xaml_create_from_file (NULL, fname, false,
&element_type);
+ XamlLoader* loader = PluginXamlLoader::FromFilename
(fname, plugin, plugin->surface);
+ dep = xaml_create_from_file (loader, fname, false,
&element_type);
+ delete loader;
g_free (fname);
}
Modified: trunk/moon/plugin/plugin.cpp
===================================================================
--- trunk/moon/plugin/plugin.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/plugin/plugin.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -333,6 +333,7 @@
g_signal_connect (G_OBJECT(this->container), "event", G_CALLBACK
(plugin_event_callback), this);
this->surface = new Surface (window->width, window->height);
+ this->surface->SetDownloaderContext (this);
if (background) {
Color *c = color_from_str (background);
@@ -754,7 +755,7 @@
if (reason == NPRES_DONE)
DEBUGMSG ("URL %s downloaded successfully.", url);
else
- DEBUGMSG ("Download of URL %s failed.", url);
+ DEBUGMSG ("Download of URL %s failed: %i (%s)", url, reason,
reason == NPRES_USER_BREAK ? "user break" : (reason == NPRES_NETWORK_ERR ?
"network error" : "other error"));
if (notify)
delete notify;
Modified: trunk/moon/plugin/plugin.h
===================================================================
--- trunk/moon/plugin/plugin.h 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/plugin/plugin.h 2007-10-08 19:04:41 UTC (rev 87118)
@@ -84,6 +84,16 @@
NPP getNPP () { return instance; }
+ static Downloader* CreateDownloader (PluginInstance* instance)
+ {
+ if (instance) {
+ return instance->surface->CreateDownloader ();
+ } else {
+ printf ("PluginInstance::CreateDownloader (%p): Unable
to create contextual downloader.\n", instance);
+ return new Downloader ();
+ }
+ }
+
// Gtk controls
GtkWidget *container; // plugin container object
Surface *surface; // plugin surface object
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/ChangeLog 2007-10-08 19:04:41 UTC (rev 87118)
@@ -1,3 +1,14 @@
+2007-10-08 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+
+ * xaml.cpp: Set the surface of newly created objects (where applicable).
+ * canvas.h, uielement.h, canvas.cpp: Move the surface field to Visual.
+ * playlist.cpp, media.cpp, text.cpp: Create the downloader using
Surface'
+ brand new CreateDownloader method.
+ * visual.h: Added a surface field, complete with setters and getters.
+ * downloader.cpp, downloader.h: Add a context field.
+ * runtime.h: Add a downloader_context field, and CreateDownloader
methods.
+ * runtime.cpp: Add a downloader_context field.
+
2007-10-08 Larry Ewing <[EMAIL PROTECTED]>
* runtime.cpp: change previous logic to drop the alpha
Modified: trunk/moon/src/canvas.cpp
===================================================================
--- trunk/moon/src/canvas.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/canvas.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -21,7 +21,7 @@
#include "namescope.h"
#include "collection.h"
-Canvas::Canvas () : surface (NULL)
+Canvas::Canvas ()
{
NameScope *ns = new NameScope ();
ns->SetTemporary (true);
@@ -45,7 +45,8 @@
void
Canvas::ComputeBounds ()
{
- if (surface) {
+ Surface *surface = GetSurface ();
+ if (surface && surface->IsTopLevel (this)) {
// toplevel canvas don't subscribe to the same bounds
computation as others
bounds = Rect (0, 0, surface->GetWidth(), surface->GetHeight());
}
Modified: trunk/moon/src/canvas.h
===================================================================
--- trunk/moon/src/canvas.h 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/canvas.h 2007-10-08 19:04:41 UTC (rev 87118)
@@ -14,8 +14,8 @@
#define __MOON_CANVAS_H__
#include "panel.h"
+#include "runtime.h"
-class Surface;
//
// Canvas Class, the only purpose is to have the Left/Top properties that
// children can use
@@ -26,10 +26,6 @@
virtual Type::Kind GetObjectType () { return Type::CANVAS; }
- virtual Surface *GetSurface () { return surface ? surface :
UIElement::GetSurface(); };
- // This should only be called on the toplevel surface
- void SetSurface (Surface *surface) { this->surface = surface; }
-
Point GetTransformOrigin ();
virtual void ComputeBounds ();
@@ -39,12 +35,6 @@
static DependencyProperty* TopProperty;
static DependencyProperty* LeftProperty;
- private:
- //
- // if not-null, this is a toplevel canvas, and this points to the
- // surface
- //
- Surface *surface;
};
G_BEGIN_DECLS
Modified: trunk/moon/src/downloader.cpp
===================================================================
--- trunk/moon/src/downloader.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/downloader.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -71,6 +71,7 @@
file_size = -2;
total = 0;
part_hash = NULL;
+ context = NULL;
}
static void
Modified: trunk/moon/src/downloader.h
===================================================================
--- trunk/moon/src/downloader.h 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/downloader.h 2007-10-08 19:04:41 UTC (rev 87118)
@@ -85,6 +85,8 @@
bool Started ();
bool Completed ();
+ void SetContext (gpointer context) { this->context = context;}
+ gpointer GetContext () { return context; }
private:
GHashTable *part_hash;
@@ -111,6 +113,8 @@
static downloader_abort_func abort_func;
char * ll_downloader_get_response_file (char *PartName);
+
+ gpointer context;
};
Downloader* downloader_new (void);
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/media.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -652,7 +652,7 @@
char *uri = media_base_get_source (this);
if (uri && *uri) {
- Downloader *dl = new Downloader ();
+ Downloader *dl = Surface::CreateDownloader (this);
//printf ("setting media source to %s\n", uri);
downloader_open (dl, "GET", uri);
@@ -1387,7 +1387,7 @@
char *source = media_base_get_source (this);
- Downloader *dl = new Downloader ();
+ Downloader *dl = Surface::CreateDownloader (this);
downloader_open (dl, "GET", source);
SetSource (dl, "");
dl->unref ();
Modified: trunk/moon/src/playlist.cpp
===================================================================
--- trunk/moon/src/playlist.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/playlist.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -16,6 +16,7 @@
#include "playlist.h"
#include "downloader.h"
#include "xaml.h"
+#include "runtime.h"
// Playlist
@@ -24,7 +25,7 @@
{
entries = new List ();
current_entry = NULL;
- downloader = new Downloader ();
+ downloader = Surface::CreateDownloader (element);
downloader->SetWriteFunc (on_downloader_data_write,
on_downloader_size_notify, this);
downloader->AddHandler (downloader->CompletedEvent,
on_downloader_complete, this);
element->AddHandler(element->MediaEndedEvent, on_media_ended, this);
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/runtime.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -89,7 +89,8 @@
background_color(NULL),
cursor (MouseCursorDefault),
drawing_area_normal (NULL),
- drawing_area_fullscreen (NULL)
+ drawing_area_fullscreen (NULL),
+ downloader_context (NULL)
{
drawing_area = gtk_event_box_new ();
Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/runtime.h 2007-10-08 19:04:41 UTC (rev 87118)
@@ -24,6 +24,7 @@
#include "value.h"
#include "type.h"
#include "list.h"
+#include "downloader.h"
#define TIMERS 0
#if TIMERS
@@ -94,7 +95,34 @@
ClockGroup* GetClockGroup () { return clock_group; }
virtual Type::Kind GetObjectType () { return Type::SURFACE; };
+
+ void SetDownloaderContext (gpointer context) { downloader_context =
context; }
+ gpointer GetDownloaderContext () { return downloader_context; }
+ Downloader* CreateDownloader ()
+ {
+ Downloader *downloader = new Downloader ();
+ downloader->SetContext (downloader_context);
+ return downloader;
+ }
+
+ static Downloader* CreateDownloader (UIElement* element)
+ {
+ Surface* surface = NULL;
+ if (element) {
+ surface = element->GetSurface ();
+ }
+ if (surface) {
+ return surface->CreateDownloader ();
+ } else {
+ printf ("Surface::CreateDownloader (%p, ID: %i): Unable
to create contextual downloader.\n", element, element ? element->id : 0);
+ //print_stack_trace ();
+ return new Downloader ();
+ }
+ }
+
private:
+ gpointer downloader_context;
+
int normal_width, normal_height;
int screen_width, screen_height;
// the actual size of the drawing area,
Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/text.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -1703,7 +1703,7 @@
}
if (uri && *uri) {
- downloader = new Downloader ();
+ downloader = Surface::CreateDownloader (this);
//printf ("setting media source to %s\n", uri);
downloader_open (downloader, "GET", uri);
Modified: trunk/moon/src/uielement.h
===================================================================
--- trunk/moon/src/uielement.h 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/uielement.h 2007-10-08 19:04:41 UTC (rev 87118)
@@ -78,8 +78,6 @@
Point transform_origin;
- virtual Surface *GetSurface () { return parent ? parent->GetSurface() :
NULL; }
-
virtual bool EnableAntiAlias() { return true; }
//
Modified: trunk/moon/src/visual.h
===================================================================
--- trunk/moon/src/visual.h 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/visual.h 2007-10-08 19:04:41 UTC (rev 87118)
@@ -17,7 +17,7 @@
class Visual : public DependencyObject {
public:
- Visual () {};
+ Visual () : surface (NULL) {};
virtual Type::Kind GetObjectType () { return Type::VISUAL; };
//
@@ -25,6 +25,11 @@
// Returns whether the position x, y is inside the object
//
virtual bool InsideObject (cairo_t *cr, double x, double y);
+
+ Surface *GetSurface () { return surface; }
+ void SetSurface (Surface *surface) { this->surface = surface; }
+private:
+ Surface* surface;
};
Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp 2007-10-08 18:08:45 UTC (rev 87117)
+++ trunk/moon/src/xaml.cpp 2007-10-08 19:04:41 UTC (rev 87118)
@@ -520,6 +520,10 @@
this->missing_assemblies = NULL;
this->mappings = NULL;
this->vm_loaded = false;
+
+ if (!surface) {
+ printf ("XamlLoader::XamlLoader ('%s', '%s', %p): Initializing
XamlLoader without a surface.\n", filename, str, surface);
+ }
}
XamlLoader::~XamlLoader ()
@@ -2144,6 +2148,8 @@
if (!inst->item) {
inst->item = i->create_item ();
+ if (inst->item->Is (Type::UIELEMENT) && p->loader)
+ ((UIElement*) inst->item)->SetSurface
(p->loader->GetSurface ());
p->AddCreatedElement (inst->item);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches