Esempio n. 1
0
status_t
DirectoryView::OpenDirectory(const Entry* dir)
{
	if (! dir->IsDirectory()) {
		return B_ERROR;
	}

	// stop node watcher
	stop_watching(this);

	// clear entry data and listview
	mListView->DeleteAllItems();
 	entryList_.DeleteAllItems();
	if (entry_) {
		delete entry_;
		entry_ = NULL;
	}
	if (parent_) {
		delete parent_;
		parent_ = NULL;
	}
	UpdateStatus();

	// set current directory
	entry_ = new Directory(*(Directory*)dir);

	// get parent directory
	BEntry bentry;
	if (entry_->GetBEntry(&bentry) == B_OK) {
		BEntry parent;
		if (bentry.GetParent(&parent) == B_OK) {
			parent_ = new Directory(parent);
		}
	}

	// get directory entry
	ListVisitor* lv1 = new ListVisitor(*entry_, &entryList_);
	lv1->Go();
	delete lv1;

	// show directory entry
	if (parent_ != NULL) {
		mListView->AddItem(new EntryListItem(parent_, EntryListItem::ENTRY_IS_PARENT));
	}
	mListView->AddEntryList((BList*) &entryList_);
	mListView->DoSort();
	if (mListView->CountItems() > 0)
		mListView->Select(0);
	UpdateStatus();

	// start node watcher
	if (bentry.InitCheck() == B_OK) {
		node_ref nref;
		bentry.GetNodeRef(&nref);
		watch_node(&nref, B_WATCH_ALL, this);
	}

	return B_OK;
}
Esempio n. 2
0
status_t HModuleRoster::StopWatching( void )
{
	if( !watching )
		return B_ERROR;
	stop_watching( this );
	watching = false;
	return B_OK;
}
Esempio n. 3
0
void
BPrinter::StopWatching()
{
	if (fListener) {
		stop_watching(*fListener);
		delete fListener;
		fListener = NULL;
	}
}
Esempio n. 4
0
VolumeWatcher::~VolumeWatcher()
{
	if (be_app->Lock()) {
		stop_watching(this);

		be_app->RemoveHandler(this);
		be_app->Unlock();
	}
}
PanelView::~PanelView()
////////////////////////////////////////////////////////////////////////
{
	// To be sure all watcher gone...
	stop_watching(this);

	if (m_UnknownIcon) delete m_UnknownIcon;
	if (m_ParentIcon) delete m_ParentIcon;
}
Esempio n. 6
0
void
BFilePanelPoseView::StopWatching()
{
	stop_watching(this);

	// inter-application observing
	BMessenger tracker(kTrackerSignature);
	BHandler::StopWatching(tracker, kVolumesOnDesktopChanged);
}
Esempio n. 7
0
void
PathHandler::Quit()
{
	if (sLooper->Lock()) {
		stop_watching(this);
		sLooper->RemoveHandler(this);
		sLooper->Unlock();
	}
	delete this;
}
Esempio n. 8
0
/*!	\brief Unsubscribes a target from node and mount monitoring.
	\param target Messenger referring to the target. Must be valid.
	\return \c B_OK, if everything went fine, another error code otherwise.
*/
status_t
stop_watching(BMessenger target)
{
	status_t error = (target.IsValid() ? B_OK : B_BAD_VALUE);
	if (error == B_OK) {
		BLooper *looper = NULL;
		BHandler *handler = target.Target(&looper);
		error = stop_watching(handler, looper);
	}
	return error;
}
Esempio n. 9
0
void 
AutoMounter::RescanDevices()
{
#if _INCLUDES_CLASS_DEVICE_MAP
	stop_watching(this);
	fList.RescanDevices(true);
	fList.UpdateMountingInfo();
	fList.EachMountedPartition(TryWatchMountPoint, 0);
	TTracker::WatchNode(0, B_WATCH_MOUNT, this);
	fList.EachMountedPartition(TryWatchMountPoint, 0);
#endif
}
Esempio n. 10
0
void
BClipboardRefsWatcher::Clear()
{
	stop_watching(this);
	watch_node(NULL, B_WATCH_MOUNT, this);

	BMessage message(kFSClipboardChanges);
	message.AddBool("clearClipboard", true);
	if (Lock()) {
		int32 items = fNotifyList.CountItems();
		for (int32 i = 0;i < items;i++) {
			fNotifyList.ItemAt(i)->SendMessage(&message);
		}
		Unlock();
	}
}
Esempio n. 11
0
void
VolumeWatcher::Stop()
{
	
	char name[255];
	fVolume.GetName(name);

	// set the time before stop watching to not miss anything
	fVolumeWorker->SetWatchingPosition(real_time_clock_usecs());

	stop_watching(&fWatchNameHandler);

	fVolumeWorker->WriteAnalyserSettings();

	// don't stop the work because we have to handle all entries after writing
	// the watching position
	//fVolumeWorker->Stop();
	fCatchUpManager.Stop();
}
Esempio n. 12
0
ChatWindow::~ChatWindow()
{
	stopNotify();
	SaveSettings();
	
	stop_watching( BMessenger(this) );

	if (fInput) {
		if (fInput->RemoveFilter(fFilter)) delete fFilter;
		fInput->RemoveSelf();
		
		delete fInput;
	};

	if (fResize) {
		fResize->RemoveSelf();
		delete fResize;
	};

	if (fDock) {
		for ( int i=0; i<fDock->CountChildren(); i++ )
		{
			gBubbles.SetHelp( fDock->ChildAt(i), NULL );
		}
		
		fDock->RemoveSelf();
		delete fDock;
	};

	if (fStatusBar) fStatusBar->RemoveSelf();
	delete fStatusBar;

	if ( fProtocolHack )
		delete fProtocolHack;
	
	fMan->Lock();
	fMan->Quit();
}
Esempio n. 13
0
void
BClipboardRefsWatcher::UpdatePoseViews(BMessage *reportMessage)
{
	if (Lock()) {
		// check if it was cleared, if so clear watching
		bool clearClipboard = false;
		if (reportMessage->FindBool("clearClipboard", &clearClipboard) == B_OK
			&& clearClipboard) {
			stop_watching(this);
			watch_node(NULL, B_WATCH_MOUNT, this);
		}

		// loop through reported node_ref's movemodes:
		// move or copy: start watching node_ref
		// remove: stop watching node_ref
		int32 index = 0;
		TClipboardNodeRef *tcnode = NULL;
		ssize_t size;
		while (reportMessage->FindData("tcnode", T_CLIPBOARD_NODE, index, (const void**)&tcnode, &size) == B_OK) {
			if (tcnode->moveMode == kDelete) {
				watch_node(&tcnode->node, B_STOP_WATCHING, this);
			} else {
				watch_node(&tcnode->node, B_STOP_WATCHING, this);
				TTracker::WatchNode(&tcnode->node, B_WATCH_NAME, this);
				fRefsInClipboard = true;
			}
			index++;
		}

		// send report
		int32 items = fNotifyList.CountItems();
		for (int32 i = 0;i < items;i++) {
			fNotifyList.ItemAt(i)->SendMessage(reportMessage);
		}
		Unlock();
	}
}
Esempio n. 14
0
BTranslatorRoster::Private::~Private()
{
	stop_watching(this);

	if (Looper() && LockLooper()) {
		BLooper* looper = Looper();
		Looper()->RemoveHandler(this);
		looper->Unlock();
	}

	// Release all translators, so that they can delete themselves

	TranslatorMap::iterator iterator = fTranslators.begin();
	std::set<image_id> images;

	while (iterator != fTranslators.end()) {
		BTranslator* translator = iterator->second.translator;

		translator->fOwningRoster = NULL;
			// we don't want to be notified about this anymore

		images.insert(iterator->second.image);
		translator->Release();

		iterator++;
	}

	// Unload all images

	std::set<image_id>::const_iterator imageIterator = images.begin();

	while (imageIterator != images.end()) {
		unload_add_on(*imageIterator);
		imageIterator++;
	}
}
Esempio n. 15
0
// destructor
NodeMonitor::~NodeMonitor()
{
	// stop volume watching
	stop_watching(this);
}
/*
* Given a single line of the output of db_delta.py
* Figures out what to do and does it.
* (adds and removes files and directories)
*/
int
App::parse_command(BString command)
{
  command.RemoveAll("\n"); //remove trailing whitespace
  if(command.Compare("RESET") == 0)
  {
    printf("Burn Everything. 8D\n");

    status_t err = stop_watching(be_app_messenger);
    if(err != B_OK) printf("stop_watching error: %s\n",strerror(err));

    BDirectory dir = BDirectory(local_path_string);
    rm_rf(&dir);

    BString str = BString("/"); //create_local_path wants a remote path 
    create_local_directory(&str);

    this->recursive_watch(&dir);
  }
  else if(command.Compare("FILE ",5) == 0)
  {
    BString path, dirpath, partial_path;
    BPath *bpath;
    int32 last_space = command.FindLast(" ");
    command.CopyInto(path,5,last_space - 5);

    path.CopyInto(dirpath,0,path.FindLast("/"));

    create_local_directory(&dirpath);
    //TODO fix watching new dirs
    bpath = new BPath(db_to_local_filepath(path.String()).String());
    BEntry new_file = BEntry(bpath->Path());
    if(new_file.InitCheck() && new_file.Exists()) {
      this->new_paths.AddItem((void*)bpath);
    } else {
      this->edited_paths.AddItem((void*)bpath);
    }

    printf("create a file at |%s|\n",path.String());
    char *argv[3];
    argv[0] = "db_get.py";
    char not_const1[path.CountChars() + 1];
    strcpy(not_const1,path.String());
    argv[1] = not_const1;
    BString tmp = db_to_local_filepath(path.String());
    char not_const2[tmp.CountChars() + 1]; //plus one for null
    strcpy(not_const2,tmp.String());
    argv[2] = not_const2;

    //create/update file
    //potential problem: takes awhile to do this step
    // having watching for dir turned off is risky.    
    BString * b = run_python_script(argv,3);
    delete b;

    //start watching the new/updated file
    node_ref nref;
    new_file = BEntry(db_to_local_filepath(path.String()).String());
    new_file.GetNodeRef(&nref);
    status_t err = watch_node(&nref,B_WATCH_STAT,be_app_messenger);

    BString parent_rev;
    command.CopyInto(parent_rev,last_space + 1, command.CountChars() - (last_space+1));
    BNode node = BNode(db_to_local_filepath(path.String()).String());
    set_parent_rev(&node,&parent_rev);
  }
  else if(command.Compare("FOLDER ",7) == 0)
  {
    BString path;
    command.CopyInto(path,7,command.FindLast(" ") - 7);

    //ignore the creation message
    BPath bpath = BPath(db_to_local_filepath(path.String()).String());
    BPath *actually_exists = find_existing_subpath(&bpath);
    this->new_paths.AddItem((void*)actually_exists);

    //create all nescessary dirs in path
    printf("create a folder at |%s|\n", path.String());
    create_local_directory(&path);

    //start watching the new dir
    BDirectory existing_dir = BDirectory(actually_exists->Path());
    recursive_watch(&existing_dir);
  }
  else if(command.Compare("REMOVE ",7) == 0)
  {
    //TODO: deal with Dropbox file paths being case-insensitive
    //which here means all lower case
    BString path;
    command.CopyInto(path,7,command.Length() - 7);

    const char * pathstr = db_to_local_filepath(path.String()).String();
    BPath *bpath = new BPath(pathstr);
    //TODO: check if it exists...
    this->removed_paths.AddItem((void*)bpath);

    printf("Remove whatever is at |%s|\n", pathstr);

    BEntry entry = BEntry(pathstr);
    status_t err = entry.Remove();
    if(err != B_OK)
      printf("Removal error: %s\n", strerror(err));
  }
  else
  {
    printf("Did not recognize command.\n");
    return B_ERROR;
  }
  return B_OK;
}
void
VirtualDirectoryPoseView::StopWatching()
{
	BPathMonitor::StopWatching(this);
	stop_watching(this);
}
UninstallView::~UninstallView()
{
	// Stop all node watching
	stop_watching(this);
}
void PanelView::ReadDirectory(const char *itemname)
////////////////////////////////////////////////////////////////////////
{
	BDirectory *dir;
	CustomListItem *item;

	stop_watching(this);
//	SetMousePointer(CR_HOURGLASS);
	MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS);
	
	// If we are not in the root directory, simply start the dir with a '..' entry...
	if (strcmp(m_Path.String(),"/")!=0)
	{
		item = new CustomListItem("..", m_Path.String(), FT_PARENT, 0);
		m_CustomListView->AddItem(item);
		if (m_Setting_ShowIcons)
		{
			item->AddIcon(m_ParentIcon);
			item->SetHeight(15.0f);
		}
	}
	
	dir = new BDirectory(m_Path.String());
	if (dir)
	{
		BEntry entry;
		
		if (dir->GetEntry(&entry)==B_OK)
		{	
			while (dir->GetNextEntry(&entry)==B_OK)			
			{
				AddDirectoryEntry(&entry);
			}
		}
	
		delete dir;
	}
	
	m_CustomListView->DoSortList();
	
	// Always select the first item in the list or the child where we came from...
	if (itemname)
	{
		CustomListItem *item;
		int n = m_CustomListView->CountItems();
		
		for (int i=0;i<n;i++)
		{
			item = (CustomListItem *)m_CustomListView->ItemAt(i);

			if (strcasecmp(itemname,item->m_FileName.String())==0)
			{
				m_CustomListView->Select(i,false);
				m_CustomListView->ScrollToSelection();
				break;
			}			
		}
		
		// When the given file disappeared, we have to select the first entry...
		if (m_CustomListView->CountSelectedEntries(CT_WITHPARENT)==0)
			m_CustomListView->Select(0,false);	
	}
	else
		m_CustomListView->Select(0,false);

	m_CurrentTotalSize = m_CustomListView->GetCurrentTotalSize();

	// Probably we have to update the path of the command line...
	Parent()->Looper()->PostMessage(new BMessage(MSG_UPDATECOMMANDLINE_PATH));	// To update command line...

	EnableMonitoring();
	
//	SetMousePointer(CR_DEFAULT);
	MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT);
}
BTrashWatcher::~BTrashWatcher()
{
	stop_watching(this);
}
Esempio n. 21
0
void
DownloadProgressView::_StopNodeMonitor()
{
	stop_watching(this);
}
Esempio n. 22
0
BeHappy::~BeHappy()
{
	stop_watching(be_app_messenger);
	delete prefs;
}
Esempio n. 23
0
/*!	\brief Unsubscribes a target from node and mount monitoring.
	\param handler The target handler. May be \c NULL, if \a looper is not
		   \c NULL. Then the preferred handler of the looper is targeted.
	\param looper The target looper. May be \c NULL, if \a handler is not
		   \c NULL. Then the handler's looper is the target looper.
	\return \c B_OK, if everything went fine, another error code otherwise.
*/
status_t
stop_watching(const BHandler *handler, const BLooper *looper)
{
	return stop_watching(BMessenger(handler, looper));
}
Esempio n. 24
0
BClipboardRefsWatcher::~BClipboardRefsWatcher()
{
	stop_watching(this);
	be_clipboard->StopWatching(this);
}
Esempio n. 25
0
void
App::StopWatching()
{
	stop_watching(this);
}
Esempio n. 26
0
ActivityView::~ActivityView()
{
	stop_watching(this);
	delete fOffscreen;
	delete fSystemInfoHandler;
}