Changed the progress monitor protocol to path a basic message that will be sent back
instead of having a fixed message code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20746 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a1c0361478
commit
5878fb7998
@ -8,6 +8,7 @@
|
||||
#include "ConfigView.h"
|
||||
#include "RAW.h"
|
||||
|
||||
#include <Messenger.h>
|
||||
#include <TranslatorRoster.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -32,12 +33,16 @@ class FreeAllocation {
|
||||
void* fBuffer;
|
||||
};
|
||||
|
||||
struct progress_data {
|
||||
BMessenger monitor;
|
||||
BMessage message;
|
||||
};
|
||||
|
||||
// Extensions that ShowImage supports
|
||||
const char* kDocumentCount = "/documentCount";
|
||||
const char* kDocumentIndex = "/documentIndex";
|
||||
const char* kProgressMonitor = "/progressMonitor";
|
||||
|
||||
const uint32 kMsgProgressMonitorUpdate = 'SIup';
|
||||
const char* kProgressMessage = "/progressMessage";
|
||||
|
||||
// The input formats that this translator supports.
|
||||
translation_format sInputFormats[] = {
|
||||
@ -158,16 +163,16 @@ RAWTranslator::DerivedIdentify(BPositionIO *stream,
|
||||
|
||||
/*static*/ void
|
||||
RAWTranslator::_ProgressMonitor(const char* message, float percentage,
|
||||
void* data)
|
||||
void* _data)
|
||||
{
|
||||
BMessenger& messenger = *(BMessenger*)data;
|
||||
progress_data& data = *(progress_data*)_data;
|
||||
|
||||
BMessage update(kMsgProgressMonitorUpdate);
|
||||
BMessage update(data.message);
|
||||
update.AddString("message", message);
|
||||
update.AddFloat("percent", percentage);
|
||||
update.AddInt64("time", system_time());
|
||||
|
||||
messenger.SendMessage(&update);
|
||||
data.monitor.SendMessage(&update);
|
||||
}
|
||||
|
||||
|
||||
@ -184,14 +189,19 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
||||
DCRaw raw(*source);
|
||||
|
||||
bool headerOnly = false;
|
||||
|
||||
progress_data progressData;
|
||||
BMessenger monitor;
|
||||
|
||||
if (settings != NULL) {
|
||||
settings->FindBool(B_TRANSLATOR_EXT_HEADER_ONLY, &headerOnly);
|
||||
|
||||
if (settings->FindMessenger(kProgressMonitor, &monitor) == B_OK) {
|
||||
raw.SetProgressMonitor(&_ProgressMonitor, &monitor);
|
||||
_ProgressMonitor("Reading Image Data", 0, &monitor);
|
||||
if (settings->FindMessenger(kProgressMonitor,
|
||||
&progressData.monitor) == B_OK
|
||||
&& settings->FindMessage(kProgressMessage,
|
||||
&progressData.message) == B_OK) {
|
||||
raw.SetProgressMonitor(&_ProgressMonitor, &progressData);
|
||||
_ProgressMonitor("Reading Image Data", 0, &progressData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
|
||||
#include "ProgressWindow.h"
|
||||
#include "ShowImageConstants.h"
|
||||
|
||||
#include <Autolock.h>
|
||||
#include <MessageRunner.h>
|
||||
@ -15,7 +16,6 @@
|
||||
|
||||
|
||||
static const uint32 kMsgShow = 'show';
|
||||
static const uint32 kMsgStatusUpdate = 'SIup';
|
||||
|
||||
|
||||
ProgressWindow::ProgressWindow(BWindow* referenceWindow)
|
||||
@ -92,7 +92,7 @@ ProgressWindow::MessageReceived(BMessage *message)
|
||||
fRetrievedShow = true;
|
||||
break;
|
||||
|
||||
case kMsgStatusUpdate:
|
||||
case kMsgProgressStatusUpdate:
|
||||
float percent;
|
||||
if (message->FindFloat("percent", &percent) == B_OK)
|
||||
fStatusBar->Update(percent - fStatusBar->CurrentValue());
|
||||
|
@ -63,6 +63,7 @@ enum {
|
||||
MSG_OPEN_RESIZER_WINDOW = 'mORS',
|
||||
MSG_RESIZER_WINDOW_QUIT = 'mRSQ',
|
||||
MSG_RESIZE = 'mRSZ',
|
||||
kMsgProgressStatusUpdate = 'SIup'
|
||||
};
|
||||
|
||||
#endif // SHOW_IMAGE_CONSTANTS_H
|
||||
|
@ -494,7 +494,9 @@ ShowImageView::SetImage(const entry_ref *ref)
|
||||
if (ioExtension.AddInt32("/documentIndex", fDocumentIndex) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
if (ioExtension.AddMessenger("/progressMonitor", fProgressWindow) == B_OK)
|
||||
BMessage progress(kMsgProgressStatusUpdate);
|
||||
if (ioExtension.AddMessenger("/progressMonitor", fProgressWindow) == B_OK
|
||||
&& ioExtension.AddMessage("/progressMessage", &progress) == B_OK)
|
||||
fProgressWindow->Start();
|
||||
|
||||
// Translate image data and create a new ShowImage window
|
||||
@ -1228,7 +1230,7 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap,
|
||||
}
|
||||
|
||||
BBitmapStream stream(bitmap);
|
||||
|
||||
|
||||
bool loop = true;
|
||||
while (loop) {
|
||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||
|
Loading…
Reference in New Issue
Block a user