6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
35 // DesktopPoseView adds support for displaying integrated desktops
36 // from multiple volumes to BPoseView
38 // Used by the Desktop window and by the root view in file panels
41 #include "DesktopPoseView.h"
43 #include <NodeMonitor.h>
46 #include <VolumeRoster.h>
52 #include "TrackerSettings.h"
53 #include "TrackerString.h"
56 // #pragma mark - DesktopPoseView
59 DesktopPoseView::DesktopPoseView(Model
* model
, uint32 viewMode
)
61 BPoseView(model
, viewMode
)
63 SetFlags(Flags() | B_DRAW_ON_CHILDREN
);
68 DesktopPoseView::InitDesktopDirentIterator(BPoseView
* nodeMonitoringTarget
,
71 // the desktop dirent iterator knows how to iterate over all the volumes,
72 // integrated onto the desktop
74 Model
sourceModel(ref
, false, true);
75 if (sourceModel
.InitCheck() != B_OK
)
78 CachedEntryIteratorList
* result
= new CachedEntryIteratorList();
80 ASSERT(!sourceModel
.IsQuery());
81 ASSERT(!sourceModel
.IsVirtualDirectory());
82 ASSERT(sourceModel
.Node() != NULL
);
84 BDirectory
* sourceDirectory
= dynamic_cast<BDirectory
*>(sourceModel
.Node());
85 ThrowOnAssert(sourceDirectory
!= NULL
);
87 // build an iterator list, start with boot
88 EntryListBase
* perDesktopIterator
89 = new CachedDirectoryEntryList(*sourceDirectory
);
91 result
->AddItem(perDesktopIterator
);
92 if (nodeMonitoringTarget
!= NULL
) {
93 TTracker::WatchNode(sourceModel
.NodeRef(),
94 B_WATCH_DIRECTORY
| B_WATCH_NAME
| B_WATCH_STAT
| B_WATCH_ATTR
,
95 nodeMonitoringTarget
);
98 if (result
->Rewind() != B_OK
) {
100 if (nodeMonitoringTarget
!= NULL
)
101 nodeMonitoringTarget
->HideBarberPole();
111 DesktopPoseView::InitDirentIterator(const entry_ref
* ref
)
113 return InitDesktopDirentIterator(this, ref
);
118 DesktopPoseView::FSNotification(const BMessage
* message
)
120 switch (message
->FindInt32("opcode")) {
121 case B_DEVICE_MOUNTED
:
124 if (message
->FindInt32("new device", &device
) != B_OK
)
127 ASSERT(TargetModel());
128 TrackerSettings settings
;
130 BVolume
volume(device
);
131 if (volume
.InitCheck() != B_OK
)
134 if (settings
.MountVolumesOntoDesktop()
135 && (!volume
.IsShared()
136 || settings
.MountSharedVolumesOntoDesktop())) {
137 // place an icon for the volume onto the desktop
138 CreateVolumePose(&volume
, true);
144 return _inherited::FSNotification(message
);
149 DesktopPoseView::AddPosesThreadValid(const entry_ref
*) const
156 DesktopPoseView::AddPosesCompleted()
158 _inherited::AddPosesCompleted();
164 DesktopPoseView::Represents(const node_ref
* ref
) const
166 // When the Tracker is set up to integrate non-boot beos volumes,
167 // it represents the home/Desktop folders of all beos volumes
169 return _inherited::Represents(ref
);
174 DesktopPoseView::Represents(const entry_ref
* ref
) const
178 entry
.GetNodeRef(&nref
);
179 return Represents(&nref
);
184 DesktopPoseView::ShowVolumes(bool visible
, bool showShared
)
191 AddRootPoses(true, showShared
);
199 DesktopPoseView::StartSettingsWatch()
201 if (be_app
->LockLooper()) {
202 be_app
->StartWatching(this, kShowDisksIconChanged
);
203 be_app
->StartWatching(this, kVolumesOnDesktopChanged
);
204 be_app
->StartWatching(this, kDesktopIntegrationChanged
);
205 be_app
->UnlockLooper();
211 DesktopPoseView::StopSettingsWatch()
213 if (be_app
->LockLooper()) {
214 be_app
->StopWatching(this, kShowDisksIconChanged
);
215 be_app
->StopWatching(this, kVolumesOnDesktopChanged
);
216 be_app
->StopWatching(this, kDesktopIntegrationChanged
);
217 be_app
->UnlockLooper();
223 DesktopPoseView::AdaptToVolumeChange(BMessage
* message
)
225 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
226 ThrowOnAssert(tracker
!= NULL
);
228 bool showDisksIcon
= false;
229 bool mountVolumesOnDesktop
= true;
230 bool mountSharedVolumesOntoDesktop
= false;
232 message
->FindBool("ShowDisksIcon", &showDisksIcon
);
233 message
->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop
);
234 message
->FindBool("MountSharedVolumesOntoDesktop",
235 &mountSharedVolumesOntoDesktop
);
239 if (model
.InitCheck() == B_OK
) {
240 BMessage entryMessage
;
241 entryMessage
.what
= B_NODE_MONITOR
;
244 entryMessage
.AddInt32("opcode", B_ENTRY_CREATED
);
246 entryMessage
.AddInt32("opcode", B_ENTRY_REMOVED
);
248 if (entry
.GetRef(&ref
) == B_OK
) {
249 BContainerWindow
* disksWindow
250 = tracker
->FindContainerWindow(&ref
);
251 if (disksWindow
!= NULL
) {
253 disksWindow
->Close();
257 entryMessage
.AddInt32("device", model
.NodeRef()->device
);
258 entryMessage
.AddInt64("node", model
.NodeRef()->node
);
259 entryMessage
.AddInt64("directory", model
.EntryRef()->directory
);
260 entryMessage
.AddString("name", model
.EntryRef()->name
);
261 BContainerWindow
* deskWindow
262 = dynamic_cast<BContainerWindow
*>(Window());
263 if (deskWindow
!= NULL
)
264 deskWindow
->PostMessage(&entryMessage
, deskWindow
->PoseView());
267 ShowVolumes(mountVolumesOnDesktop
, mountSharedVolumesOntoDesktop
);
272 DesktopPoseView::AdaptToDesktopIntegrationChange(BMessage
* message
)
274 bool mountVolumesOnDesktop
= true;
275 bool mountSharedVolumesOntoDesktop
= true;
277 message
->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop
);
278 message
->FindBool("MountSharedVolumesOntoDesktop",
279 &mountSharedVolumesOntoDesktop
);
281 ShowVolumes(false, mountSharedVolumesOntoDesktop
);
282 ShowVolumes(mountVolumesOnDesktop
, mountSharedVolumesOntoDesktop
);