Author: fejj
Date: 2007-12-11 17:31:42 -0500 (Tue, 11 Dec 2007)
New Revision: 91133
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/downloader.cpp
trunk/moon/src/downloader.h
trunk/moon/src/media.cpp
trunk/moon/src/media.h
trunk/moon/src/playlist.cpp
trunk/moon/src/playlist.h
trunk/moon/src/runtime.cpp
trunk/moon/src/text.cpp
trunk/moon/src/text.h
Log:
2007-12-11 Jeffrey Stedfast <[EMAIL PROTECTED]>
* downloader.cpp|h: Made the ::Write() method take the same
int-type args as the NPP_Write() function (which means int32 for
both offset and nbytes).
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/ChangeLog 2007-12-11 22:31:42 UTC (rev 91133)
@@ -1,3 +1,9 @@
+2007-12-11 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * downloader.cpp|h: Made the ::Write() method take the same
+ int-type args as the NPP_Write() function (which means int32 for
+ both offset and nbytes).
+
2007-12-11 Sebastien Pouliot <[EMAIL PROTECTED]>
* stylus.cpp: Fix JS unit tests for Stroke properties by having
Modified: trunk/moon/src/downloader.cpp
===================================================================
--- trunk/moon/src/downloader.cpp 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/downloader.cpp 2007-12-11 22:31:42 UTC (rev 91133)
@@ -102,7 +102,7 @@
}
void *
-Downloader::GetResponseText (const char* PartName, uint64_t *size)
+Downloader::GetResponseText (const char *PartName, uint64_t *size)
{
FILE *f = NULL;
struct stat buf;
@@ -210,7 +210,7 @@
return file;
}
-char*
+char *
Downloader::GetResponseFile (const char *PartName)
{
if (part_hash != NULL){
@@ -229,15 +229,16 @@
}
void
-Downloader::Open (const char *verb, const char *URI)
+Downloader::Open (const char *verb, const char *uri)
{
started = false;
g_free (failed_msg);
g_free (filename);
failed_msg = NULL;
filename = NULL;
- SetValue (Downloader::UriProperty, Value(URI));
- open_func (verb, URI, downloader_state);
+
+ SetValue (Downloader::UriProperty, Value (uri));
+ open_func (verb, uri, downloader_state);
}
void
@@ -260,19 +261,22 @@
// A zero write means that we are done
//
void
-Downloader::Write (guchar *buf, gsize offset, gsize n)
+Downloader::Write (void *buf, int32_t offset, int32_t n)
{
+ double progress;
+
// Update progress
- total += n;
- double p;
+ if (n > 0)
+ total += n;
+
if (file_size >= 0)
- p = total / (double) file_size;
+ progress = total / (double) file_size;
else
- p = 0;
+ progress = 0;
- SetValue (Downloader::DownloadProgressProperty, Value (p));
+ SetValue (Downloader::DownloadProgressProperty, Value (progress));
Emit (DownloadProgressChangedEvent);
-
+
if (write)
write (buf, offset, n, consumer_closure);
}
@@ -296,19 +300,19 @@
// dl->SetValue (Downloader::StatusProperty, Value (400))
// For some reason the status is 0, not updated on errors?
failed_msg = g_strdup (msg);
- Emit (DownloadFailedEvent, (gpointer)msg);
+ Emit (DownloadFailedEvent, (gpointer) msg);
}
void
Downloader::NotifySize (int64_t size)
{
file_size = size;
-
+
if (notify_size)
notify_size (size, consumer_closure);
-
+
SetValue (Downloader::DownloadProgressProperty, Value (0.0));
-
+
Emit (DownloadProgressChangedEvent);
}
@@ -378,15 +382,15 @@
void *
-downloader_get_response_text (Downloader *dl, const char* PartName, uint64_t
*size)
+downloader_get_response_text (Downloader *dl, const char *PartName, uint64_t
*size)
{
return dl->GetResponseText (PartName, size);
}
void
-downloader_open (Downloader *dl, const char *verb, const char *URI)
+downloader_open (Downloader *dl, const char *verb, const char *uri)
{
- dl->Open (verb, URI);
+ dl->Open (verb, uri);
}
void
@@ -398,7 +402,7 @@
dl->Send ();
}
-Downloader*
+Downloader *
downloader_new (void)
{
return new Downloader ();
@@ -416,7 +420,7 @@
}
void
-downloader_write (Downloader *dl, guchar *buf, gsize offset, gsize n)
+downloader_write (Downloader *dl, void *buf, int32_t offset, int32_t n)
{
dl->Write (buf, offset, n);
}
@@ -440,7 +444,7 @@
}
void
-dummy_downloader_write (guchar *buf, gsize offset, gsize n, gpointer cb_data)
+dummy_downloader_write (void *buf, int32_t offset, int32_t n, gpointer cb_data)
{
g_warning ("downloader_set_function has never been called.\n");
}
@@ -463,27 +467,34 @@
{
g_warning ("downloader_set_function has never been called.\n");
}
+
void
dummy_downloader_open (const char *verb, const char *uri, gpointer state)
{
g_warning ("downloader_set_function has never been called.\n");
}
+
void
dummy_downloader_send (gpointer state)
{
g_warning ("downloader_set_function has never been called.\n");
}
+
void
dummy_downloader_abort (gpointer state)
{
g_warning ("downloader_set_function has never been called.\n");
}
-char*
+
+char *
dummy_downloader_get_response_text (char *fname, char *part, gpointer state)
{
g_warning ("downloader_set_function has never been called.\n");
return NULL;
}
+
+
+
DependencyProperty *Downloader::DownloadProgressProperty;
DependencyProperty *Downloader::ResponseTextProperty;
DependencyProperty *Downloader::StatusProperty;
@@ -511,4 +522,3 @@
dummy_downloader_send,
dummy_downloader_abort, true);
}
-
Modified: trunk/moon/src/downloader.h
===================================================================
--- trunk/moon/src/downloader.h 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/downloader.h 2007-12-11 22:31:42 UTC (rev 91133)
@@ -23,46 +23,45 @@
class Downloader;
-typedef void (*downloader_write_func)(guchar *buf, gsize offset, gsize n,
gpointer cb_data);
-typedef void (*downloader_notify_size_func)(int64_t size, gpointer
cb_data);
+typedef void (*downloader_write_func) (void *buf, int32_t offset, int32_t
n, gpointer cb_data);
+typedef void (*downloader_notify_size_func) (int64_t size, gpointer
cb_data);
-typedef gpointer (*downloader_create_state_func) (Downloader* dl);
+typedef gpointer (*downloader_create_state_func) (Downloader *dl);
typedef void (*downloader_destroy_state_func) (gpointer state);
-typedef void (*downloader_open_func)(const char *verb, const char *uri,
gpointer state);
-typedef void (*downloader_send_func)(gpointer state);
-typedef void (*downloader_abort_func)(gpointer state);
+typedef void (*downloader_open_func) (const char *verb, const char *uri,
gpointer state);
+typedef void (*downloader_send_func) (gpointer state);
+typedef void (*downloader_abort_func) (gpointer state);
class Downloader : public DependencyObject {
public:
- Downloader ();
- virtual ~Downloader ();
-
- virtual Type::Kind GetObjectType () { return Type::DOWNLOADER; };
-
- void Abort ();
- void* GetResponseText (const char* Partname, uint64_t *size);
- void Open (const char *verb, const char *URI);
- void Send ();
-
+ // Properties
static DependencyProperty *DownloadProgressProperty;
static DependencyProperty *ResponseTextProperty;
static DependencyProperty *StatusProperty;
static DependencyProperty *StatusTextProperty;
static DependencyProperty *UriProperty;
-
+
// Events you can AddHandler to
static int CompletedEvent;
static int DownloadProgressChangedEvent;
static int DownloadFailedEvent;
+
+ Downloader ();
+ virtual ~Downloader ();
+ virtual Type::Kind GetObjectType () { return Type::DOWNLOADER; };
-
+ void Abort ();
+ void *GetResponseText (const char *Partname, uint64_t *size);
+ void Open (const char *verb, const char *uri);
+ void Send ();
+
// the following is stuff not exposed by C#/js, but is useful
// when writing unmanaged code for downloader implementations
// or data sinks.
- char* GetResponseFile (const char *PartName);
- void Write (guchar *buf, gsize offset, gsize n);
+ char *GetResponseFile (const char *PartName);
+ void Write (void *buf, int32_t offset, int32_t n);
void NotifyFinished (const char *fname);
void NotifyFailed (const char *msg);
void NotifySize (int64_t size);
@@ -125,7 +124,7 @@
static downloader_send_func send_func;
static downloader_abort_func abort_func;
- char * ll_downloader_get_response_file (const char *PartName);
+ char *ll_downloader_get_response_file (const char *PartName);
gpointer context;
};
@@ -141,13 +140,13 @@
void downloader_abort (Downloader *dl);
void *downloader_get_response_text (Downloader *dl, const char *PartName,
uint64_t *size);
char *downloader_get_response_file (Downloader *dl, const char *PartName);
-void downloader_open (Downloader *dl, const char *verb, const
char *URI);
+void downloader_open (Downloader *dl, const char *verb, const
char *uri);
void downloader_send (Downloader *dl);
//
// Used to push data to the consumer
//
-void downloader_write (Downloader *dl, guchar *buf, gsize offset,
gsize n);
+void downloader_write (Downloader *dl, void *buf, int32_t offset,
int32_t n);
void downloader_completed (Downloader *dl, const char *filename);
void downloader_notify_size (Downloader *dl, int64_t size);
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/media.cpp 2007-12-11 22:31:42 UTC (rev 91133)
@@ -564,7 +564,7 @@
}
void
-MediaElement::DataWrite (guchar *buf, gsize offset, gsize count)
+MediaElement::DataWrite (void *buf, int32_t offset, int32_t n)
{
double progress = downloader->GetValue
(Downloader::DownloadProgressProperty)->AsDouble ();
@@ -575,9 +575,9 @@
}
void
-MediaElement::data_write (guchar *buf, gsize offset, gsize count, gpointer
data)
+MediaElement::data_write (void *buf, int32_t offset, int32_t n, gpointer data)
{
- ((MediaElement *) data)->DataWrite (buf, offset, count);
+ ((MediaElement *) data)->DataWrite (buf, offset, n);
}
void
@@ -1205,7 +1205,7 @@
}
void
-Image::SetSource (DependencyObject *dl, const char* PartName)
+Image::SetSource (DependencyObject *dl, const char *PartName)
{
g_return_if_fail (dl->GetObjectType() == Type::DOWNLOADER);
@@ -1237,7 +1237,7 @@
}
void
-Image::PixbufWrite (guchar *buf, gsize offset, gsize count)
+Image::PixbufWrite (void *buf, int32_t offset, int32_t n)
{
UpdateProgress ();
}
@@ -1416,9 +1416,9 @@
}
void
-Image::pixbuf_write (guchar *buf, gsize offset, gsize count, gpointer data)
+Image::pixbuf_write (void *buf, int32_t offset, int32_t n, gpointer data)
{
- ((Image*)data)->PixbufWrite (buf, offset, count);
+ ((Image *) data)->PixbufWrite (buf, offset, n);
}
void
Modified: trunk/moon/src/media.h
===================================================================
--- trunk/moon/src/media.h 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/media.h 2007-12-11 22:31:42 UTC (rev 91133)
@@ -69,10 +69,11 @@
void DownloaderAbort ();
// downloader callbacks
- void PixbufWrite (guchar *bug, gsize offset, gsize count);
+ void PixbufWrite (void *buf, int32_t offset, int32_t n);
void DownloaderComplete ();
void UpdateProgress ();
- static void pixbuf_write (guchar *buf, gsize offset, gsize count,
gpointer data);
+
+ static void pixbuf_write (void *buf, int32_t offset, int32_t n,
gpointer data);
static void downloader_complete (EventObject *sender, gpointer
calldata, gpointer closure);
static void size_notify (int64_t size, gpointer data);
@@ -190,11 +191,11 @@
MediaSource *source;
char *part_name;
- void DataWrite (guchar *data, gsize n, gsize nn);
+ void DataWrite (void *data, int32_t offset, int32_t n);
void DownloaderAbort ();
void DownloaderComplete ();
- static void data_write (guchar *data, gsize n, gsize nn, void *closure);
+ static void data_write (void *data, int32_t offset, int32_t n, void
*closure);
static void downloader_complete (EventObject *sender, gpointer
calldata, gpointer closure);
static void size_notify (int64_t size, gpointer data);
Modified: trunk/moon/src/playlist.cpp
===================================================================
--- trunk/moon/src/playlist.cpp 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/playlist.cpp 2007-12-11 22:31:42 UTC (rev 91133)
@@ -135,8 +135,9 @@
}
void
-Playlist::on_downloader_data_write (guchar *buf, gsize offset, gsize count,
gpointer data)
+Playlist::on_downloader_data_write (void *buf, int32_t offset, int32_t n,
gpointer data)
{
+
}
void
Modified: trunk/moon/src/playlist.h
===================================================================
--- trunk/moon/src/playlist.h 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/playlist.h 2007-12-11 22:31:42 UTC (rev 91133)
@@ -173,10 +173,12 @@
static void on_media_ended (EventObject *sender, gpointer calldata,
gpointer userdata);
static void on_downloader_complete (EventObject *sender, gpointer
calldata, gpointer userdata);
- static void on_downloader_data_write (guchar *buf, gsize offset, gsize
count, gpointer data);
+ static void on_downloader_data_write (void *buf, int32_t offset,
int32_t n, gpointer data);
static void on_downloader_size_notify (int64_t size, gpointer data);
+
protected:
virtual bool OpenInternal ();
+
public:
Playlist (MediaElement *element, const char *source_name, const char
*file_name);
virtual ~Playlist ();
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/runtime.cpp 2007-12-11 22:31:42 UTC (rev 91133)
@@ -1178,8 +1178,11 @@
Surface::drawing_area_size_allocate (GtkWidget *widget, GtkAllocation
*allocation, gpointer user_data)
{
Surface *s = (Surface *) user_data;
-
- if (s->width != allocation->width || s->height != allocation->height){
+
+ //printf ("Surface::size-allocate callback: current = %dx%d; new =
%dx%d\n",
+ // s->width, s->height, allocation->width, allocation->height);
+
+ if (s->width != allocation->width || s->height != allocation->height) {
s->width = allocation->width;
s->height = allocation->height;
Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/text.cpp 2007-12-11 22:31:42 UTC (rev 91133)
@@ -1121,7 +1121,7 @@
}
void
-TextBlock::data_write (guchar *buf, gsize offset, gsize count, gpointer data)
+TextBlock::data_write (void *buf, int32_t offset, int32_t n, gpointer data)
{
;
}
@@ -1694,7 +1694,7 @@
}
void
-Glyphs::data_write (guchar *buf, gsize offset, gsize count, gpointer data)
+Glyphs::data_write (void *buf, int32_t offset, int32_t n, gpointer data)
{
;
}
Modified: trunk/moon/src/text.h
===================================================================
--- trunk/moon/src/text.h 2007-12-11 22:23:02 UTC (rev 91132)
+++ trunk/moon/src/text.h 2007-12-11 22:31:42 UTC (rev 91133)
@@ -140,7 +140,7 @@
void DownloaderComplete ();
- static void data_write (guchar *data, gsize n, gsize nn, void *closure);
+ static void data_write (void *data, int32_t offset, int32_t n, void
*closure);
static void downloader_complete (EventObject *sender, gpointer
calldata, gpointer closure);
static void size_notify (int64_t size, gpointer data);
@@ -259,7 +259,7 @@
void DownloaderComplete ();
- static void data_write (guchar *data, gsize n, gsize nn, void *closure);
+ static void data_write (void *data, int32_t offset, int32_t n, void
*closure);
static void downloader_complete (EventObject *sender, gpointer
calldata, gpointer closure);
static void size_notify (int64_t size, gpointer data);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches