// ---------------------------------------------------------
// CDownloadMgrSession::InitializeL
// ---------------------------------------------------------
//
void CDownloadMgrSession::InitializeL()
    {
    CLOG_ENTERFN( "CDownloadMgrSession::DownloadMgrAttachCountL" )
    iIsMaster = (TBool)CurrentMessage().Int2();

    TUid uid;
    TPckg<TUid> uidPckg( uid );

    Read( 0, uidPckg );

    CreateClientAppInstanceL( uidPckg().iUid );

    // Check how many download we have and return it to the client
    CLOG_WRITE_FORMAT( "CDownloadMgrSession::InitializeL iClientAppInstance %d", iClientAppInstance );
    CArrayPtrFlat<CHttpDownload>* currentDownloads = iClientAppInstance->DownloadsL();
	TPckg<TInt> countPckg( currentDownloads->Count() );
	TPckg<TInt> sessionId( iSessionId );

    Write( 1, CurrentMessage(), countPckg );
    Write( 3, CurrentMessage(), sessionId );

    CLOG_NAME_2( _L("Session_%x_%x"), uidPckg().iUid, iSessionId );

    currentDownloads->Reset();
    delete currentDownloads;
    }
Exemple #2
0
bool
TBarApp::QuitRequested()
{
	// don't allow user quitting
	if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) {
		// but allow quitting to hide fPreferencesWindow
		int32 index = 0;
		BWindow* window = NULL;
		while ((window = WindowAt(index++)) != NULL) {
			if (window == fPreferencesWindow) {
				if (fPreferencesWindow->Lock()) {
					if (fPreferencesWindow->IsActive())
						fPreferencesWindow->PostMessage(B_QUIT_REQUESTED);
					fPreferencesWindow->Unlock();
				}
				break;
			}
		}
		return false;
	}

	// system quitting, call inherited to notify all loopers
	fBarWindow->SaveSettings();
	BApplication::QuitRequested();
	return true;
}
Exemple #3
0
bool
TBarApp::QuitRequested()
{
	// don't allow the user to quit
	if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) {
		// but close the preferences window
		QuitPreferencesWindow();
		return false;
	}

	// system quitting, call inherited to notify all loopers
	fBarWindow->SaveSettings();
	BApplication::QuitRequested();
	return true;
}
Exemple #4
0
void
FileTypes::ArgvReceived(int32 argc, char **argv)
{
	BMessage *message = CurrentMessage();

	BDirectory currentDirectory;
	if (message)
		currentDirectory.SetTo(message->FindString("cwd"));

	BMessage refs;

	for (int i = 1 ; i < argc ; i++) {
		BPath path;
		if (argv[i][0] == '/')
			path.SetTo(argv[i]);
		else
			path.SetTo(&currentDirectory, argv[i]);

		status_t status;
		entry_ref ref;
		BEntry entry;

		if ((status = entry.SetTo(path.Path(), false)) != B_OK
			|| (status = entry.GetRef(&ref)) != B_OK) {
			fprintf(stderr, "Could not open file \"%s\": %s\n",
				path.Path(), strerror(status));
			continue;
		}

		refs.AddRef("refs", &ref);
	}

	RefsReceived(&refs);
}
// ---------------------------------------------------------
// CDownloadMgrSession::CreateDownloadL
// ---------------------------------------------------------
//
void CDownloadMgrSession::CreateDownloadL( CHttpDownload* aDownload, TBool aDefAttrib )
	{
	// make a new download object
	CDownloadSubSession* download = CDownloadSubSession::NewL( this, aDownload );
    CleanupStack::PushL( download );
    if( aDefAttrib )
        {
        download->SetDefAttributesL();
        }
	// add object to object container to gererate unique id
	iObjectContainer->AddL( download );
	// add object to object index; this returns a unique handle so we can get it again
    CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL, download %d", download );
	TInt handle = iObjectIx->AddL( download );
    CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL, iObjectIx->ActiveCount() %d", iObjectIx->ActiveCount() );
    // Store handle to the subsession. It is used when the URL is checked.
    download->SetHandle( handle );
    CleanupStack::Pop( download ); //download
	// write the handle to client
    TPckg<TInt> handlePckg( handle );

    Write( 1, CurrentMessage(), handlePckg );

    // write the handle to the framework
	WriteHandle( handle );	
	}
// ---------------------------------------------------------
// CDownloadMgrSession::DownloadAttachL
// ---------------------------------------------------------
//
void CDownloadMgrSession::DownloadAttachL()
	{
    CLOG_ENTERFN( "CDownloadMgrSession::DownloadAttachL" )
    // All we have to do to write the handle to the 3rd parameter.
    // The client-server framework will take care of the 3rd parameter
    // whenever the client calls a subsession related service.
    TInt handle = CurrentMessage().Int1();
    TPckg<TInt> handlePckg( handle );
    WriteHandle( handlePckg() );
	}
bool BepdfApplication::QuitRequested() {
	delete mStdoutTracer; mStdoutTracer = NULL;
	delete mStderrTracer; mStderrTracer = NULL;

	bool shortcut;
	if (B_OK == CurrentMessage()->FindBool("shortcut", &shortcut) && shortcut) {
		Notify(NOTIFY_QUIT_MSG);
	}
	return BApplication::QuitRequested();
}
bool FastTraxWindow::QuitRequested( void )
{
	// Response to Close Message, not to Application Quiting
	if( CurrentMessage() )
	{		
		BMessenger msgr( be_app ) ;
		BMessage reply ;
		if( msgr.IsValid() )
		{
			BMessage msg( Messages::WindowClosed ) ;
			msg.AddPointer( "Window", this ) ;
			msgr.SendMessage( &msg , &reply ) ;
		}
	}
	return inherited :: QuitRequested( ) ;
}
Exemple #9
0
void MainWindow::Quit()
{
	slayer->options.wind_rect = Frame();
	teamView->SaveState(&slayer->options.columnsState);
//	slayer->options.wind_minimized = minimized;

	// What follows is a really ugly hack to detect if the user closed
	// the window with close button, or if Application wants to close
	// all windows:
	BMessage *msg = CurrentMessage();  // this is null if called outside BMessageReceived loop
	                                   // -> message from application
	if (slayer->docked && msg != NULL)
		Minimize(true);
	else
		BWindow::Quit();
}
Exemple #10
0
void AnimatedSprite::doMessage(int msg, void* data, uint64 timestamp) {
	init();
	int s = getState();
	switch (msg) {
		case emtStartAnimation:
			isAnimated = true;
			break;
		case emtStopAnimation:
			isAnimated = false;
			break;
		case emtSwitch:
			s++;
			if (getImage(s) == NULL) {
				s = 0;
			}
			setState(s);
			return;
		case emtHide: 
			isVisible = false;
			return;
		case emtShadow:
			isVisible = true;
			alpha = IW_2D_ALPHA_HALF;
			return;
		case emtShow: 
			isVisible = true;
			alpha = IW_2D_ALPHA_NONE;
			return;
	};
	if (timestamp == 0) {
		timestamp = s3eTimerGetMs();
	}
	RIter p = rules.find(msg);
	if (p != rules.end()) {
		for (CIter q = currentMessages.begin(); q != currentMessages.end(); ++q) {
			if (q->isEmpty) {
				q->isEmpty       = false;
				q->message       = p->second;
				q->timestamp     = timestamp;
				q->lastTimeDelta = 0;
				return;
			}
		}
		currentMessages.push_back(CurrentMessage(p->second, timestamp));
	}
}
bool
TermApp::QuitRequested()
{
	// check whether the system is shutting down
	BMessage* message = CurrentMessage();
	bool shutdown;
	if (message != NULL && message->FindBool("_shutdown_", &shutdown) == B_OK
		&& shutdown) {
		// The system is shutting down. Quit the window synchronously. This
		// skips the checks for running processes and the "Are you sure..."
		// alert.
		if (fTermWindow->Lock())
			fTermWindow->Quit();
	}

	return BApplication::QuitRequested();
}
// ---------------------------------------------------------
// CDownloadMgrSession::AttachToDownloadL
// ---------------------------------------------------------
//
void CDownloadMgrSession::AttachToDownloadL()
    {
    CLOG_ENTERFN( "CDownloadMgrSession::AttachToDownload" )
    __ASSERT_DEBUG( iClientAppInstance, PanicClient( EMultipleInitDownloadEvent ) );

    const TInt32 id = CurrentMessage().Int0();

    CHttpDownload* dl = iClientAppInstance->AttachDownloadL( id );
		if (dl)
		{
			CreateDownloadL( dl );
		}
		else
		{
			User::LeaveIfError(KErrNotFound);
		}
    }
Exemple #13
0
void
TTracker::ArgvReceived(int32 argc, char **argv)
{
	BMessage *message = CurrentMessage();
	const char *currentWorkingDirectoryPath = NULL;
	entry_ref ref;

	if (message->FindString("cwd", &currentWorkingDirectoryPath) == B_OK) {
		BDirectory workingDirectory(currentWorkingDirectoryPath);
		for (int32 index = 1; index < argc; index++) {
			BEntry entry;
			if (entry.SetTo(&workingDirectory, argv[index]) == B_OK
				&& entry.GetRef(&ref) == B_OK) 
				OpenRef(&ref);
			else if (get_ref_for_path(argv[index], &ref) == B_OK)
				OpenRef(&ref);
		}
	}
}
// ---------------------------------------------------------
// CDownloadMgrSession::DownloadMgrAttachL
// ---------------------------------------------------------
//
void CDownloadMgrSession::DownloadMgrAttachL()
    {
    CLOG_ENTERFN( "CDownloadMgrSession::DownloadMgrAttachL" )
    // The client would like to attach the dowmloads were created previously.
    // Here, we create a buffer with the unique handles of download subsessions
    // and copy it to the client's address space.
    CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL iClientAppInstance %d", iClientAppInstance );
    CArrayPtrFlat<CHttpDownload>* currentDownloads = iClientAppInstance->DownloadsL();
    CleanupStack::PushL( currentDownloads );
    TPckgBuf<TInt> arrayPckg;
    HBufC8* buf = HBufC8::NewLC( currentDownloads->Count() * arrayPckg.Size() );
    // Cerate subsessions one by one and write the unique handles to the client.
    // Later the handles is used by the client subsession to attach to the server.
    for( TInt i = 0; i < currentDownloads->Count(); i++ )
        {
        CHttpDownload* httpDownload = (*currentDownloads)[i];
	    // make a new download object
	    CDownloadSubSession* download = CDownloadSubSession::NewL( this, httpDownload );
        CleanupStack::PushL( download );
	    // add object to object container to gererate unique id
	    iObjectContainer->AddL( download );
	    // add object to object index; this returns a unique handle so we can get it again
        CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL, download %d", download );
	    arrayPckg() = iObjectIx->AddL( download );
        CLOG_WRITE_FORMAT( "CDownloadMgrSession::DownloadMgrAttachL, iObjectIx->ActiveCount() %d", iObjectIx->ActiveCount() );
        // Store handle to the subsession. It is used when the URL is checked.
        download->SetHandle( arrayPckg() );
        CleanupStack::Pop( download ); //download
        buf->Des().Append( arrayPckg );
        }
    TPtr8 ptr = buf->Des();

    Write( 0, CurrentMessage(), ptr );

    CleanupStack::PopAndDestroy( buf ); // buf
    currentDownloads->Reset();
    CleanupStack::PopAndDestroy( currentDownloads ); // currentDownloads
    }
Exemple #15
0
bool
TTracker::QuitRequested()
{
	// don't allow user quitting
	if (CurrentMessage() && CurrentMessage()->FindBool("shortcut"))
		return false;

	gStatusWindow->AttemptToQuit();
		// try quitting the copy/move/empty trash threads
		
	BVolume bootVolume;
	DEBUG_ONLY(status_t err =) BVolumeRoster().GetBootVolume(&bootVolume);
	ASSERT(err == B_OK);
	BMessage message;
	AutoLock<WindowList> lock(&fWindowList);
	// save open windows in a message inside an attribute of the desktop
	int32 count = fWindowList.CountItems();
	for (int32 i = 0; i < count; i++) {
		BContainerWindow *window = dynamic_cast<BContainerWindow *>
			(fWindowList.ItemAt(i));

		if (window && window->TargetModel() && !window->PoseView()->IsDesktopWindow()) {
			if (window->TargetModel()->IsRoot())
				message.AddBool("open_disks_window", true);
			else {
				BEntry entry;
				BPath path;
				const entry_ref *ref = window->TargetModel()->EntryRef();
				if (entry.SetTo(ref) == B_OK && entry.GetPath(&path) == B_OK) {
					int8 flags = window->IsMinimized() ? kOpenWindowMinimized : kOpenWindowNoFlags;
					uint32 deviceFlags = GetVolumeFlags(window->TargetModel());

					// save state for every window which is
					//	a) already open on another workspace
					//	b) on a volume not capable of writing attributes
					if (window != FindContainerWindow(ref)
						|| (deviceFlags & (B_FS_HAS_ATTR | B_FS_IS_READONLY)) != B_FS_HAS_ATTR) {
						BMessage stateMessage;
						window->SaveState(stateMessage);
						window->SetSaveStateEnabled(false);
							// This is to prevent its state to be saved to the node when closed.
						message.AddMessage("window state", &stateMessage);
						flags |= kOpenWindowHasState;
					}
					const char *target;
					bool pathAlreadyExists = false;
					for (int32 index = 0;message.FindString("paths", index, &target) == B_OK;index++) {
						if (!strcmp(target,path.Path())) {
							pathAlreadyExists = true;
							break;
						}
					}
					if (!pathAlreadyExists)
						message.AddString("paths", path.Path());
					message.AddInt8(path.Path(), flags);
				}
			}	
		}
	}
	lock.Unlock();

	// write windows to open on disk
	BDirectory deskDir;
	if (!BootedInSafeMode() && FSGetDeskDir(&deskDir, bootVolume.Device()) == B_OK) {
		// if message is empty, delete the corresponding attribute
		if (message.CountNames(B_ANY_TYPE)) {
			size_t size = (size_t)message.FlattenedSize();
			char *buffer = new char[size];
			message.Flatten(buffer, (ssize_t)size);
			deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, size);
			delete [] buffer;
		} else
			deskDir.RemoveAttr(kAttrOpenWindows);
	}

	for (int32 count = 0; count == 50; count++) {
		// wait 5 seconds for the copiing/moving to quit
		if (gStatusWindow->AttemptToQuit())
			break;

		snooze(100000);
	}

	return _inherited::QuitRequested();
}
Exemple #16
0
void
TeamWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_TEAM_RESTART_REQUESTED:
		{
			fListener->TeamRestartRequested();
			break;
		}
		case MSG_CHOOSE_DEBUG_REPORT_LOCATION:
		{
			try {
				char filename[B_FILE_NAME_LENGTH];
				UiUtils::ReportNameForTeam(fTeam, filename, sizeof(filename));
				BMessenger msgr(this);
				fFilePanel = new BFilePanel(B_SAVE_PANEL, &msgr,
					NULL, 0, false, new BMessage(MSG_GENERATE_DEBUG_REPORT));
				fFilePanel->SetSaveText(filename);
				fFilePanel->Show();
			} catch (...) {
				delete fFilePanel;
				fFilePanel = NULL;
			}
			break;
		}
		case MSG_GENERATE_DEBUG_REPORT:
		{
			delete fFilePanel;
			fFilePanel = NULL;

			BPath path;
			entry_ref ref;
			if (message->FindRef("directory", &ref) == B_OK
				&& message->HasString("name")) {
				path.SetTo(&ref);
				path.Append(message->FindString("name"));
				if (get_ref_for_path(path.Path(), &ref) == B_OK)
					fListener->DebugReportRequested(&ref);
			}
			break;
		}
		case MSG_DEBUG_REPORT_SAVED:
		{
			BString data;
			data.SetToFormat("Debug report successfully saved to '%s'",
				message->FindString("path"));
			BAlert *alert = new(std::nothrow) BAlert("Report saved",
				data.String(), "Close");
			if (alert == NULL)
				break;

			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			alert->Go();
			break;
		}
		case MSG_SHOW_INSPECTOR_WINDOW:
		{
			if (fInspectorWindow) {
				fInspectorWindow->Activate(true);
			} else {
				try {
					fInspectorWindow = InspectorWindow::Create(fTeam,
						fListener, this);
					if (fInspectorWindow != NULL) {
						BMessage settings;
						fInspectorWindow->LoadSettings(fUiSettings);
						fInspectorWindow->Show();
					}
	           	} catch (...) {
	           		// TODO: notify user
	           	}
			}

			target_addr_t address;
			if (message->FindUInt64("address", &address) == B_OK) {
				BMessage addressMessage(MSG_INSPECT_ADDRESS);
				addressMessage.AddUInt64("address", address);
				fInspectorWindow->PostMessage(&addressMessage);
			}
           	break;
		}
		case MSG_INSPECTOR_WINDOW_CLOSED:
		{
			_SaveInspectorSettings(CurrentMessage());
			fInspectorWindow = NULL;
			break;

		}
		case MSG_SHOW_BREAK_CONDITION_CONFIG_WINDOW:
		{
			if (fBreakConditionConfigWindow) {
				fBreakConditionConfigWindow->Activate(true);
			} else {
				try {
					fBreakConditionConfigWindow
						= BreakConditionConfigWindow::Create(
						fTeam, fListener, this);
					if (fBreakConditionConfigWindow != NULL)
						fBreakConditionConfigWindow->Show();
	           	} catch (...) {
	           		// TODO: notify user
	           	}
			}
			break;
		}
		case MSG_BREAK_CONDITION_CONFIG_WINDOW_CLOSED:
		{
			fBreakConditionConfigWindow = NULL;
			break;
		}
		case MSG_SHOW_WATCH_VARIABLE_PROMPT:
		{
			target_addr_t address;
			uint32 type;
			int32 length;

			if (message->FindUInt64("address", &address) != B_OK
				|| message->FindUInt32("type", &type) != B_OK
				|| message->FindInt32("length", &length) != B_OK) {
				break;
			}

			try {
				WatchPromptWindow* window = WatchPromptWindow::Create(
					fTeam->GetArchitecture(), address, type, length,
					fListener);
				window->Show();
			} catch (...) {
				// TODO: notify user
			}
			break;
		}
		case B_REFS_RECEIVED:
		{
			entry_ref locatedPath;
			if (message->FindRef("refs", &locatedPath) != B_OK)
				break;

			_HandleResolveMissingSourceFile(locatedPath);
			break;
		}
		case MSG_LOCATE_SOURCE_IF_NEEDED:
		{
			if (fActiveFunction != NULL
				&& fActiveFunction->GetFunctionDebugInfo()
					->SourceFile() != NULL && fActiveSourceCode != NULL
				&& fActiveSourceCode->GetSourceFile() == NULL
				&& fActiveFunction->GetFunction()->SourceCodeState()
					!= FUNCTION_SOURCE_NOT_LOADED) {
				try {
					if (fFilePanel == NULL) {
						fFilePanel = new BFilePanel(B_OPEN_PANEL,
							new BMessenger(this));
					}
					fFilePanel->Show();
				} catch (...) {
					delete fFilePanel;
					fFilePanel = NULL;
				}
			}
			break;
		}
		case MSG_THREAD_RUN:
		case MSG_THREAD_STOP:
		case MSG_THREAD_STEP_OVER:
		case MSG_THREAD_STEP_INTO:
		case MSG_THREAD_STEP_OUT:
			if (fActiveThread != NULL && fTraceUpdateRunner == NULL) {
				fListener->ThreadActionRequested(fActiveThread->ID(),
					message->what);
			}
			break;

		case MSG_CLEAR_STACK_TRACE:
		{
			if (fTraceUpdateRunner != NULL) {
				_SetActiveStackTrace(NULL);
				_UpdateRunButtons();
			}
			break;
		}
		case MSG_THREAD_STATE_CHANGED:
		{
			int32 threadID;
			if (message->FindInt32("thread", &threadID) != B_OK)
				break;

			_HandleThreadStateChanged(threadID);
			break;
		}
		case MSG_THREAD_CPU_STATE_CHANGED:
		{
			int32 threadID;
			if (message->FindInt32("thread", &threadID) != B_OK)
				break;

			_HandleCpuStateChanged(threadID);
			break;
		}

		case MSG_THREAD_STACK_TRACE_CHANGED:
		{
			int32 threadID;
			if (message->FindInt32("thread", &threadID) != B_OK)
				break;

			_HandleStackTraceChanged(threadID);
			break;
		}

		case MSG_IMAGE_DEBUG_INFO_CHANGED:
		{
			int32 imageID;
			if (message->FindInt32("image", &imageID) != B_OK)
				break;

			_HandleImageDebugInfoChanged(imageID);
			break;
		}

		case MSG_CONSOLE_OUTPUT_RECEIVED:
		{
			int32 fd;
			BString output;
			if (message->FindInt32("fd", &fd) != B_OK
					|| message->FindString("output", &output) != B_OK) {
				break;
			}
			fConsoleOutputView->ConsoleOutputReceived(fd, output);
			break;
		}

		case MSG_USER_BREAKPOINT_CHANGED:
		{
			UserBreakpoint* breakpoint;
			if (message->FindPointer("breakpoint", (void**)&breakpoint) != B_OK)
				break;
			BReference<UserBreakpoint> breakpointReference(breakpoint, true);

			_HandleUserBreakpointChanged(breakpoint);
			break;
		}

		case MSG_WATCHPOINT_CHANGED:
		{
			Watchpoint* watchpoint;
			if (message->FindPointer("watchpoint", (void**)&watchpoint) != B_OK)
				break;
			BReference<Watchpoint> watchpointReference(watchpoint, true);

			_HandleWatchpointChanged(watchpoint);
			break;

		}

		case MSG_FUNCTION_SOURCE_CODE_CHANGED:
		{
			_HandleSourceCodeChanged();
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
void
TeamWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_SHOW_INSPECTOR_WINDOW:
		{
			if (fInspectorWindow) {
				fInspectorWindow->Activate(true);
				break;
			}

			try {
				fInspectorWindow = InspectorWindow::Create(fTeam, fListener,
					this);
				if (fInspectorWindow != NULL) {
					BMessage settings;
					fInspectorWindow->LoadSettings(fUISettings);
					fInspectorWindow->Show();
				}
           	} catch (...) {
           		// TODO: notify user
           	}
           	break;
		}
		case MSG_INSPECTOR_WINDOW_CLOSED:
		{
			_SaveInspectorSettings(CurrentMessage());
			fInspectorWindow = NULL;

		}
		case B_REFS_RECEIVED:
		{
			entry_ref locatedPath;
			message->FindRef("refs", &locatedPath);
			_HandleResolveMissingSourceFile(locatedPath);
			break;
		}
		case MSG_LOCATE_SOURCE_IF_NEEDED:
		{
			if (fActiveFunction != NULL
				&& fActiveFunction->GetFunctionDebugInfo()
					->SourceFile() != NULL && fActiveSourceCode != NULL
				&& fActiveSourceCode->GetSourceFile() == NULL) {
				try {
					if (fSourceLocatePanel == NULL) {
						fSourceLocatePanel = new BFilePanel(B_OPEN_PANEL,
							new BMessenger(this));
					}
					fSourceLocatePanel->Show();
				} catch (...) {
					delete fSourceLocatePanel;
					fSourceLocatePanel = NULL;
				}
			}
			break;
		}
		case MSG_THREAD_RUN:
		case MSG_THREAD_STOP:
		case MSG_THREAD_STEP_OVER:
		case MSG_THREAD_STEP_INTO:
		case MSG_THREAD_STEP_OUT:
			if (fActiveThread != NULL) {
				fListener->ThreadActionRequested(fActiveThread->ID(),
					message->what);
			}
			break;

		case MSG_THREAD_STATE_CHANGED:
		{
			int32 threadID;
			if (message->FindInt32("thread", &threadID) != B_OK)
				break;

			_HandleThreadStateChanged(threadID);
			break;
		}
		case MSG_THREAD_CPU_STATE_CHANGED:
		{
			int32 threadID;
			if (message->FindInt32("thread", &threadID) != B_OK)
				break;

			_HandleCpuStateChanged(threadID);
			break;
		}

		case MSG_THREAD_STACK_TRACE_CHANGED:
		{
			int32 threadID;
			if (message->FindInt32("thread", &threadID) != B_OK)
				break;

			_HandleStackTraceChanged(threadID);
			break;
		}

		case MSG_IMAGE_DEBUG_INFO_CHANGED:
		{
			int32 imageID;
			if (message->FindInt32("image", &imageID) != B_OK)
				break;

			_HandleImageDebugInfoChanged(imageID);
			break;
		}

		case MSG_USER_BREAKPOINT_CHANGED:
		{
			UserBreakpoint* breakpoint;
			if (message->FindPointer("breakpoint", (void**)&breakpoint) != B_OK)
				break;
			BReference<UserBreakpoint> breakpointReference(breakpoint, true);

			_HandleUserBreakpointChanged(breakpoint);
			break;
		}

		case MSG_FUNCTION_SOURCE_CODE_CHANGED:
		{
			_HandleSourceCodeChanged();
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Exemple #18
0
bool
BrowserApp::QuitRequested()
{
	if (fDownloadWindow->DownloadsInProgress()) {
		BAlert* alert = new BAlert(B_TRANSLATE("Downloads in progress"),
			B_TRANSLATE("There are still downloads in progress, do you really "
			"want to quit WebPositive now?"), B_TRANSLATE("Quit"),
			B_TRANSLATE("Continue downloads"));
		int32 choice = alert->Go();
		if (choice == 1) {
			if (fWindowCount == 0) {
				if (fDownloadWindow->Lock()) {
					fDownloadWindow->SetWorkspaces(1 << current_workspace());
					if (fDownloadWindow->IsHidden())
						fDownloadWindow->Show();
					else
						fDownloadWindow->Activate();
					fDownloadWindow->SetMinimizeOnClose(true);
					fDownloadWindow->Unlock();
					return false;
				}
			} else
				return false;
		}
	}

	fSession->MakeEmpty();

	/* See if we got here because the last window is already closed.
	 * In that case we only need to save that one, which is already archived */
	BMessage* message = CurrentMessage();
	BMessage windowMessage;

	status_t ret = message->FindMessage("window", &windowMessage);
	if (ret == B_OK) {
		fSession->AddMessage("window", &windowMessage);
	} else {
		for (int i = 0; BWindow* window = WindowAt(i); i++) {
			BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window);
			if (!webWindow)
				continue;
			if (!webWindow->Lock())
				continue;

			BMessage windowArchive;
			webWindow->Archive(&windowArchive, true);
			fSession->AddMessage("window", &windowArchive);

			if (webWindow->QuitRequested()) {
				fLastWindowFrame = webWindow->WindowFrame();
				webWindow->Quit();
				i--;
			} else {
				webWindow->Unlock();
				return false;
			}
		}
	}

	BWebPage::ShutdownOnce();

	fSettings->SetValue("window frame", fLastWindowFrame);
	if (fDownloadWindow->Lock()) {
		fSettings->SetValue("downloads window frame", fDownloadWindow->Frame());
		fSettings->SetValue("show downloads", !fDownloadWindow->IsHidden());
		fDownloadWindow->Unlock();
	}
	if (fSettingsWindow->Lock()) {
		fSettings->SetValue("settings window frame", fSettingsWindow->Frame());
		fSettingsWindow->Unlock();
	}
	if (fConsoleWindow->Lock()) {
		fSettings->SetValue("console window frame", fConsoleWindow->Frame());
		fConsoleWindow->Unlock();
	}
	if (fCookieWindow->Lock()) {
		fSettings->SetValue("cookie window frame", fCookieWindow->Frame());
		fCookieWindow->Unlock();
	}

	BMessage cookieArchive;
	BNetworkCookieJar& cookieJar = fContext->GetCookieJar();
	cookieJar.PurgeForExit();
	if (cookieJar.Archive(&cookieArchive) == B_OK)
		fCookies->SetValue("cookies", cookieArchive);

	return true;
}
void
Window::FrameResized(float width, float height)
{
	CurrentMessage()->PrintToStream();
}