This source file includes following definitions.
- HandlingMonitor
- HandlingMonitor_Removed
- HandlingMonitor_Moved
- HandlingMonitor_Created
- HandlingMonitor_Changed
1 #include <stdio.h>
2 #include "BF_GUI_FilesPanel.h"
3 #include "BF_Roster.h"
4
5
6
7
8
9 #include <NodeMonitor.h>
10
11
12 void
13 BF_GUI_FilesPanel::HandlingMonitor(BMessage &o_Message)
14 {
15 int32 iOpCode=0;
16 if(B_OK!=o_Message.FindInt32("opcode",&iOpCode)) return;
17
18
19 node_ref uRef;
20 o_Message.FindInt32("device", &uRef.device);
21 o_Message.FindInt64("node", &uRef.node);
22 switch(iOpCode){
23 case B_ENTRY_REMOVED:
24 HandlingMonitor_Removed(o_Message,uRef);
25 break;
26 case B_ENTRY_MOVED:
27 HandlingMonitor_Moved(o_Message,uRef);
28 break;
29 case B_ENTRY_CREATED:
30 HandlingMonitor_Created(o_Message,uRef);
31 break;
32 case B_STAT_CHANGED:
33 HandlingMonitor_Changed(o_Message,uRef);
34 break;
35 };
36
37 }
38
39
40 void
41 BF_GUI_FilesPanel::HandlingMonitor_Removed(BMessage &o_Message,node_ref & u_Ref)
42 {
43
44 BF_Node *poNode = loNode.NodeByRef(u_Ref);
45 if(!poNode) return;
46
47 Nodes_Remove(poNode,NULL);
48 DELETE(poNode);
49 }
50
51
52 void
53 BF_GUI_FilesPanel::HandlingMonitor_Moved(BMessage &o_Message,node_ref & u_Ref)
54 {
55
56 node_ref uRefSrcDir,uRefDestDir;
57 uRefSrcDir.device = u_Ref.device;
58 if(B_OK!=o_Message.FindInt64("from directory",&uRefSrcDir.node)) return;
59 if(B_OK!=o_Message.FindInt64("to directory",&uRefDestDir.node)) return;
60 if(B_OK!=o_Message.FindInt32("device",&uRefDestDir.device)) return;
61
62
63 if(oPath.CheckNodeRef(uRefSrcDir) && oPath.CheckNodeRef(uRefDestDir)){
64 const char *pcNodeName=NULL;
65 ASSERT(B_OK==o_Message.FindString("name",&pcNodeName) && pcNodeName);
66 BF_Node *poNode = loNode.NodeByRef(u_Ref);
67 if(!poNode) return;
68 poNode->sName = pcNodeName;
69
70 Nodes_Update(poNode,NULL);
71 }else
72
73 if(oPath.CheckNodeRef(uRefSrcDir)){
74
75 BF_Node *poNode = loNode.NodeByRef(u_Ref);
76 if(!poNode) return;
77
78 Nodes_Remove(poNode,NULL);
79 DELETE(poNode);
80 }else
81
82 if(oPath.CheckNodeRef(uRefDestDir)){
83 const char *pcNodeName=NULL;
84 ASSERT(B_OK==o_Message.FindString("name",&pcNodeName) && pcNodeName);
85 BF_Node *poNode = BF_Roster_LoadNode(oPath.Path(),pcNodeName,LoadStyles());
86 if(!poNode) return;
87 Nodes_Add(poNode,NULL);
88 }else
89
90 if(oPath.CheckNodeRef(u_Ref)){
91 NavGoParentDir();
92 }
93 }
94
95 void
96 BF_GUI_FilesPanel::HandlingMonitor_Created(BMessage &o_Message,node_ref & u_Ref)
97 {
98 const char *pcNodeName=NULL;
99 ASSERT(B_OK==o_Message.FindString("name",&pcNodeName) && pcNodeName);
100 BF_Node *poNode = BF_Roster_LoadNode(oPath.Path(),pcNodeName,LoadStyles());
101 if(!poNode) return;
102 Nodes_Add(poNode,NULL);
103 }
104
105 void
106 BF_GUI_FilesPanel::HandlingMonitor_Changed(BMessage &o_Message,node_ref & u_Ref)
107 {
108 BF_Node *poNode = loNode.NodeByRef(u_Ref);
109 if(!poNode) return;
110
111 BF_Roster_ReloadNode(oPath.Path(),poNode,LoadStyles());
112
113 Nodes_Update(poNode,NULL);