1// NodeMonitoringEvent.cpp 2 3#include <Message.h> 4#include <NodeMonitor.h> 5 6#include "Debug.h" 7#include "NodeMonitoringEvent.h" 8 9// NodeMonitoringEvent 10 11// constructor 12NodeMonitoringEvent::NodeMonitoringEvent() 13 : Referencable(true), 14 time(system_time()), 15 queryHandler(NULL), 16 remotePort(-1), 17 remoteToken(-1) 18{ 19} 20 21// destructor 22NodeMonitoringEvent::~NodeMonitoringEvent() 23{ 24 if (queryHandler) 25 queryHandler->RemoveReference(); 26} 27 28 29// EntryCreatedEvent 30 31// Init 32status_t 33EntryCreatedEvent::Init(const BMessage* message) 34{ 35 opcode = B_ENTRY_CREATED; 36 const char* localName; 37 if (message->FindInt32("device", &volumeID) != B_OK 38 || message->FindInt64("directory", &directoryID) != B_OK 39 || message->FindInt64("node", &nodeID) != B_OK 40 || message->FindString("name", &localName) != B_OK) { 41 return B_BAD_VALUE; 42 } 43 if (!name.SetTo(localName)) 44 return B_NO_MEMORY; 45 return B_OK; 46} 47 48 49// EntryRemovedEvent 50 51// Init 52status_t 53EntryRemovedEvent::Init(const BMessage* message) 54{ 55 opcode = B_ENTRY_REMOVED; 56 if (message->FindInt32("device", &volumeID) != B_OK 57 || message->FindInt64("directory", &directoryID) != B_OK 58 || message->FindInt64("node", &nodeID) != B_OK) { 59 return B_BAD_VALUE; 60 } 61 nodeVolumeID = volumeID; 62 return B_OK; 63} 64 65 66// EntryMovedEvent 67 68// Init 69status_t 70EntryMovedEvent::Init(const BMessage* message) 71{ 72 opcode = B_ENTRY_MOVED; 73 const char* localName; 74 if (message->FindInt32("device", &volumeID) != B_OK 75 || message->FindInt64("from directory", &fromDirectoryID) != B_OK 76 || message->FindInt64("to directory", &toDirectoryID) != B_OK 77 || message->FindInt64("node", &nodeID) != B_OK 78 || message->FindString("name", &localName) != B_OK) { 79 return B_BAD_VALUE; 80 } 81 nodeVolumeID = volumeID; 82 if (!toName.SetTo(localName)) 83 return B_NO_MEMORY; 84 return B_OK; 85} 86 87 88// StatChangedEvent 89 90// Init 91status_t 92StatChangedEvent::Init(const BMessage* message) 93{ 94 opcode = B_STAT_CHANGED; 95 if (message->FindInt32("device", &volumeID) != B_OK 96 || message->FindInt64("node", &nodeID)) { 97 return B_BAD_VALUE; 98 } 99 return B_OK; 100} 101 102 103// AttributeChangedEvent 104 105// Init 106status_t 107AttributeChangedEvent::Init(const BMessage* message) 108{ 109 opcode = B_ATTR_CHANGED; 110 const char* localName; 111 if (message->FindInt32("device", &volumeID) != B_OK 112 || message->FindInt64("node", &nodeID) 113 || message->FindString("attr", &localName) != B_OK) { 114 return B_BAD_VALUE; 115 } 116 if (!attribute.SetTo(localName)) 117 return B_NO_MEMORY; 118 return B_OK; 119} 120 121 122// VolumeMountedEvent 123 124// Init 125status_t 126VolumeMountedEvent::Init(const BMessage* message) 127{ 128 opcode = B_DEVICE_MOUNTED; 129 if (message->FindInt32("new device", &newVolumeID) != B_OK 130 || message->FindInt32("device", &volumeID) != B_OK 131 || message->FindInt64("directory", &directoryID) != B_OK) { 132 return B_BAD_VALUE; 133 } 134 return B_OK; 135} 136 137 138// VolumeUnmountedEvent 139 140// Init 141status_t 142VolumeUnmountedEvent::Init(const BMessage* message) 143{ 144 opcode = B_DEVICE_UNMOUNTED; 145 if (message->FindInt32("device", &volumeID) != B_OK) 146 return B_BAD_VALUE; 147 return B_OK; 148} 149 150