Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bepdf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ SYSTEM_INCLUDE_PATHS = ../xpdf \
../xpdf/goo \
../xpdf/splash \
../xpdf/xpdf \
/system/develop/headers/private/interface
/system/develop/headers/private/interface \
/system/develop/headers/private/storage

# Additional paths paths to look for local headers. These use the form
# #include "header". Directories that contain the files in SRCS are
Expand Down Expand Up @@ -147,7 +148,7 @@ SYMBOLS :=

# Includes debug information, which allows the binary to be debugged easily.
# If set to "TRUE", debug info will be created.
DEBUGGER :=
DEBUGGER :=

# Specify any additional compiler flags to be used.
COMPILER_FLAGS = -Wno-write-strings
Expand Down
27 changes: 13 additions & 14 deletions bepdf/beos/EntryChangedMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,37 @@ void EntryChangedMonitor::StartWatching(entry_ref *ref) {

mEntryRef = *ref;
mActive = true;
BNode node(ref);
if (node.InitCheck() == B_OK &&
node.GetNodeRef(&mNodeRef) == B_OK) {
watch_node(&mNodeRef, B_WATCH_STAT, this);
BEntry entry(ref);
BPath path;
if (entry.InitCheck() == B_OK &&
entry.GetPath(&path) == B_OK) {
BPathMonitor::StartWatching(path.Path(),B_WATCH_STAT,this);
}
}

void EntryChangedMonitor::StopWatching() {
if (mActive) {
watch_node(&mNodeRef, B_STOP_WATCHING, this);
BEntry entry(&mEntryRef);
BPath path;
entry.GetPath(&path);
BPathMonitor::StopWatching(path.Path(), this);

mActive = false;
}
}

void EntryChangedMonitor::MessageReceived(BMessage* msg) {
if (msg->what != B_NODE_MONITOR)
if (msg->what != B_PATH_MONITOR)
return;

int32 opcode;
if (msg->FindInt32("opcode", &opcode) != B_OK)
return;

if (opcode != B_STAT_CHANGED)
if (opcode != B_STAT_CHANGED )
return;

// Haiku sends a B_STAT_CHANGED notification
// when attributes are changed too
// this leads to an infinite loop, as
// BePDF changes file attributes after
// loading a file.
// TODO check if file has changed and only
// then notify the listener
NotifyListener();
}

void EntryChangedMonitor::NotifyListener() {
Expand Down
9 changes: 4 additions & 5 deletions bepdf/beos/EntryChangedMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#ifndef ENTRY_CHANGED_MONITOR_H
#define ENTRY_CHANGED_MONITOR_H

#include <Handler.h>
#include <Node.h>
#include <Entry.h>
#include <NodeMonitor.h>
#include <Handler.h>
#include <Path.h>
#include <PathMonitor.h>

class EntryChangedListener {
public:
Expand Down Expand Up @@ -59,7 +59,6 @@ class EntryChangedMonitor : public BHandler {
EntryChangedListener* mListener;
bool mActive;
entry_ref mEntryRef;
node_ref mNodeRef;
};

#endif
#endif
8 changes: 8 additions & 0 deletions bepdf/beos/PDFWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ bool PDFWindow::IsCurrentFile(entry_ref *ref) const {
///////////////////////////////////////////////////////////
bool PDFWindow::LoadFile(entry_ref *ref, const char *ownerPassword, const char *userPassword, bool *encrypted) {
if (mMainView != NULL) {
// Haiku sends a B_STAT_CHANGED notification
// when attributes are changed too
// that's why we stop watching when changing attributes
mEntryChangedMonitor.StopWatching();
StoreFileAttributes();
CleanUpBeforeLoad();
// load new file
Expand All @@ -354,6 +358,10 @@ bool PDFWindow::LoadFile(entry_ref *ref, const char *ownerPassword, const char *
InitAfterOpen();
return true;
}
//If unable to load the new ref, watch again
entry_ref oldRef;
if (mCurrentFile.GetRef(&oldRef) == B_OK)
mEntryChangedMonitor.StartWatching(&oldRef);
}
return false;
}
Expand Down