Example #1
0
status_t
AVFormatReader::GetMetaData(BMessage* _data)
{
	// The first cookie is always there!
	const AVFormatContext* context = fStreams[0]->Context();

	if (context == NULL)
		return B_NO_INIT;

	avdictionary_to_message(context->metadata, _data);

	// Add chapter info
	for (unsigned i = 0; i < context->nb_chapters; i++) {
		AVChapter* chapter = context->chapters[i];
		BMessage chapterData;
		chapterData.AddInt64("start", bigtime_t(1000000.0
			* chapter->start * chapter->time_base.num
			/ chapter->time_base.den + 0.5));
		chapterData.AddInt64("end", bigtime_t(1000000.0
			* chapter->end * chapter->time_base.num
			/ chapter->time_base.den + 0.5));

		avdictionary_to_message(chapter->metadata, &chapterData);
		_data->AddMessage("be:chapter", &chapterData);
	}

	// Add program info
	for (unsigned i = 0; i < context->nb_programs; i++) {
		BMessage programData;
		avdictionary_to_message(context->programs[i]->metadata, &programData);
		_data->AddMessage("be:program", &programData);
	}

	return B_OK;
}
Example #2
0
void
BFilePanelPoseView::AdaptToVolumeChange(BMessage* message)
{
	bool showDisksIcon;
	bool mountVolumesOnDesktop;
	bool mountSharedVolumesOntoDesktop;

	message->FindBool("ShowDisksIcon", &showDisksIcon);
	message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
	message->FindBool("MountSharedVolumesOntoDesktop",
		&mountSharedVolumesOntoDesktop);

	BEntry entry("/");
	Model model(&entry);
	if (model.InitCheck() == B_OK) {
		BMessage monitorMsg;
		monitorMsg.what = B_NODE_MONITOR;

		if (showDisksIcon)
			monitorMsg.AddInt32("opcode", B_ENTRY_CREATED);
		else
			monitorMsg.AddInt32("opcode", B_ENTRY_REMOVED);

		monitorMsg.AddInt32("device", model.NodeRef()->device);
		monitorMsg.AddInt64("node", model.NodeRef()->node);
		monitorMsg.AddInt64("directory", model.EntryRef()->directory);
		monitorMsg.AddString("name", model.EntryRef()->name);
		TrackerSettings().SetShowDisksIcon(showDisksIcon);
		if (Window())
			Window()->PostMessage(&monitorMsg, this);
	}

	ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
}
Example #3
0
void
QueryView::GetInitialEntries()
{	
	fEntryCount = 0;	
	entry_ref ref;

//	slaad
	BNode n(&ref);
	vollist vols;
	
	ExtractQueryVolumes(&n, &vols);
	vollist::iterator vIt;
	
	for (vIt = vols.begin(); vIt != vols.end(); vIt++) {
		BQuery *query = new BQuery();
		query->SetVolume(&(*vIt));
		query->SetPredicate(fPredicate.String());
		query->SetTarget(this);
		query->Fetch();
	
		while( query->GetNextRef(&ref) == B_OK )
		{
			// eiman
			BEntry entry(&ref);
			node_ref node;
			entry.GetNodeRef(&node);
			
			BMessage msg;
			msg.AddInt32("opcode",B_ENTRY_CREATED);
			msg.AddString("name",ref.name);
			msg.AddInt64("directory",ref.directory);
			msg.AddInt32("device",ref.device);
			msg.AddInt64("node",node.node);
			if ( !ShouldIgnore(&msg) )
			{
				fEntryCount++;
			}
		}
		
		fQueries.push_back(query);
	};
	
	#ifdef DEBUG
	BeDC dc("QueryWatcher");
	BString str;
	str<<Name()<<" initial count: "<<fEntryCount;
	dc.SendMessage(str.String());
	#endif

	UpdateDisplay();
}
Example #4
0
void
DataView::UpdateFromEditor(BMessage *message)
{
	if (fData == NULL)
		return;

	BAutolock locker(fEditor);

	fFileSize = fEditor.FileSize();

	// get the range of the changes

	int32 start = 0, end = fDataSize - 1;
	off_t offset, size;
	if (message != NULL
		&& message->FindInt64("offset", &offset) == B_OK
		&& message->FindInt64("size", &size) == B_OK) {
		if (offset > fOffset + (off_t)fDataSize
			|| offset + (off_t)size < fOffset) {
			// the changes are not within our scope, so we can ignore them
			return;
		}

		if (offset > fOffset)
			start = offset - fOffset;
		if (offset + (off_t)size < fOffset + (off_t)fDataSize)
			end = offset + size - fOffset;
	}

	if (fOffset + (off_t)fDataSize > fFileSize)
		fSizeInView = fFileSize - fOffset;
	else
		fSizeInView = fDataSize;

	const uint8 *data;
	if (fEditor.GetViewBuffer(&data) == B_OK)
		// ToDo: copy only the relevant part
		memcpy(fData, data, fDataSize);

	InvalidateRange(start, end);

	// we notify our selection listeners also if the
	// data in the selection has changed
	if (start <= fEnd && end >= fStart) {
		BMessage update;
		update.AddInt64("start", fStart);
		update.AddInt64("end", fEnd);
		SendNotices(kDataViewSelection, &update);
	}
}
Example #5
0
void
DesktopPoseView::AdaptToVolumeChange(BMessage* message)
{
	TTracker* tracker = dynamic_cast<TTracker*>(be_app);
	if (!tracker)
		return;

	bool showDisksIcon = false;
	bool mountVolumesOnDesktop = true;
	bool mountSharedVolumesOntoDesktop = false;

	message->FindBool("ShowDisksIcon", &showDisksIcon);
	message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
	message->FindBool("MountSharedVolumesOntoDesktop",
		&mountSharedVolumesOntoDesktop);

	BEntry entry("/");
	Model model(&entry);
	if (model.InitCheck() == B_OK) {
		BMessage entryMessage;
		entryMessage.what = B_NODE_MONITOR;

		if (showDisksIcon)
			entryMessage.AddInt32("opcode", B_ENTRY_CREATED);
		else {
			entryMessage.AddInt32("opcode", B_ENTRY_REMOVED);
			entry_ref ref;
			if (entry.GetRef(&ref) == B_OK) {
				BContainerWindow* disksWindow
					= tracker->FindContainerWindow(&ref);
				if (disksWindow) {
					disksWindow->Lock();
					disksWindow->Close();
				}
			}
		}
		entryMessage.AddInt32("device", model.NodeRef()->device);
		entryMessage.AddInt64("node", model.NodeRef()->node);
		entryMessage.AddInt64("directory", model.EntryRef()->directory);
		entryMessage.AddString("name", model.EntryRef()->name);
		BContainerWindow* deskWindow
			= dynamic_cast<BContainerWindow*>(Window());
		if (deskWindow)
			deskWindow->PostMessage(&entryMessage, deskWindow->PoseView());
	}

	ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
}
  virtual void Pulse (void)
  {
    return; // Not force testing message injection at this time.

    BMessage EventMessage;
    char     KeyAsString [16];
    int      i;
    m_EventTriggerCounter++;
printf ("Event %d\n", m_EventTriggerCounter);
    switch (m_EventTriggerCounter)
    {
      case 4:
//        EventMessage.what = B_MOUSE_MOVED;
//        EventMessage.AddFloat ("x", 0.2);
//        EventMessage.AddFloat ("y", 0.1);
//        EventMessage.AddInt64 ("when", system_time ());
//        EventMessage.AddInt32 ("buttons", 2);
//        EventMessage.what = B_MOUSE_WHEEL_CHANGED;
//        EventMessage.AddFloat ("be:wheel_delta_x", 0.0F);
//        EventMessage.AddFloat ("be:wheel_delta_y", -1.0F);
//        m_InputDeviceMousePntr->Control ('ViNC', &EventMessage);
        EventMessage.what = B_KEY_DOWN;
        EventMessage.AddInt64 ("when", system_time ());
        EventMessage.AddInt32 ("key", 61);
        EventMessage.AddInt32 ("modifiers", 0);
        strcpy (KeyAsString, "é");
        for (i = 0; KeyAsString[i] != 0; i++)
          EventMessage.AddInt8 ("byte", KeyAsString [i]);
        EventMessage.AddString ("bytes", KeyAsString);
        EventMessage.AddData ("states", B_UINT8_TYPE, KeyAsString, 16);
        EventMessage.AddInt32 ("raw_char", 62);
        m_InputDeviceKeyboardPntr->Control ('ViNC', &EventMessage);
        EventMessage.MakeEmpty ();
        EventMessage.what = B_KEY_UP;
        EventMessage.AddInt64 ("when", system_time ());
        EventMessage.AddInt32 ("key", 61);
        EventMessage.AddInt32 ("modifiers", 0);
        for (i = 0; KeyAsString[i] != 0; i++)
          EventMessage.AddInt8 ("byte", KeyAsString [i]);
        EventMessage.AddString ("bytes", KeyAsString);
        EventMessage.AddData ("states", B_UINT8_TYPE, KeyAsString, 16);
        EventMessage.AddInt32 ("raw_char", 62);
        m_InputDeviceKeyboardPntr->Control ('ViNC', &EventMessage);
        break;
      default:
        break;
    }
  };
Example #7
0
void
MouseCommandActuator::_GenerateMouseButtonEvent(bool mouseDown,
	const BMessage* keyMessage, BList* outList, BMessage* mouseMessage)
{
	BMessage* fakeMouse = new BMessage(*mouseMessage);
	fakeMouse->what = mouseDown ? B_MOUSE_DOWN : B_MOUSE_UP;

	// Update the buttons to reflect which mouse buttons we are faking
	fakeMouse->RemoveName("buttons");

	if (mouseDown)
		fakeMouse->AddInt32("buttons", fWhichButtons);

	// Trey sez you gotta keep then "when"'s increasing if you want
	// click & drag to work!
	int64 when;

	const BMessage* lastMessage;
	if (outList->CountItems() > 0) {
		int32 last = outList->CountItems() - 1;
		lastMessage = (const BMessage*)outList->ItemAt(last);
	} else
		lastMessage = keyMessage;

	if (lastMessage->FindInt64("when", &when) == B_OK) {
		when++;
		fakeMouse->RemoveName("when");
		fakeMouse->AddInt64("when", when);
	}

	outList->AddItem(fakeMouse);
}
/*!	\brief		Send the invocation message.
 */
status_t		CalendarControl::Invoke( BMessage* in )
{
	BMessage* toSend = NULL, *tempMessage = in;
	if ( tempMessage == NULL ) {
		tempMessage = this->Message();
		if ( !tempMessage ) {
			tempMessage = new BMessage( kCalendarControlInvoked );
			if ( !tempMessage ) {
				return B_BAD_VALUE;
			}
		}
	}
	
	toSend = new BMessage( tempMessage->what );
	if ( !toSend ) {
		return B_NO_MEMORY;
	}
	
	toSend->AddInt64( "when", system_time() );
	toSend->AddPointer( "source", this );
	toSend->AddInt32( "Day", ( int32 )fRepresentedTime.tm_mday );
	toSend->AddInt32( "Month", ( int32 )fRepresentedTime.tm_mon );
	toSend->AddInt32( "Year", ( int32 )fRepresentedTime.tm_year );
	toSend->AddString( "Calendar Module", fRepresentedTime.GetCalendarModule() );
	
	status_t toReturn = BControl::Invoke( toSend );
	
	delete toSend;
	return toReturn;
	
}	// <-- end of function CalendarControl::Invoke
PropPointEditor::PropPointEditor(PObject *obj, PProperty *prop)
	:	PropertyEditor(obj,prop),
		fXEditor(NULL),
		fYEditor(NULL),
		fMsgr(NULL)
{
	fPropName = new BString();
	
	SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	SetFlags(Flags() | B_FRAME_EVENTS);
	BString label("PointEditor");
	BString text;
	if (GetProperty())
		label = GetProperty()->GetName();
	
	
	BMessage *editMsg = new BMessage(M_EDIT);
	
	if (obj && prop)
	{
		editMsg->AddPointer("object",obj);
		editMsg->AddPointer("property",prop);
		editMsg->AddInt64("objectid",obj->GetID());
		editMsg->AddString("name",prop->GetName());
		*fPropName = prop->GetName();
	}
	
	fLabel = new BStringView(BRect(0,2,1,3),"label",label.String(),B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fLabel->ResizeToPreferred();
	
	fXEditor = new NumBox(Bounds(),"editor","X:","",editMsg, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	fYEditor = new NumBox(Bounds(),"editor","Y:","",editMsg, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	
	Update();
}
PropStringEditor::PropStringEditor(PObject *obj, PProperty *prop)
	:	PropertyEditor(obj,prop),
		fEditor(NULL),
		fMsgr(NULL)
{
	fPropName = new BString();
	
	SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	BString label("StringEditor");
	BString text;
	if (GetProperty())
	{
		label = GetProperty()->GetName();
		text = GetProperty()->GetValueAsString();
	}
	
	BMessage *editMsg = new BMessage(M_EDIT);
	
	if (obj && prop)
	{
		editMsg->AddPointer("object",obj);
		editMsg->AddPointer("property",prop);
		editMsg->AddInt64("objectid",obj->GetID());
		editMsg->AddString("name",prop->GetName());
		*fPropName = prop->GetName();
	}
	
	fEditor = new AutoTextControl(Bounds(),"editor",label.String(),text.String(),
									editMsg, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
}
Example #11
0
/*! This method is called when BMediaFormats asks for any updates
 	made to our format list.
	If there were any changes since the last time, the whole
	list will be sent back.
*/
void 
FormatManager::GetFormats(BMessage& message)
{
	BAutolock locker(fLock);

	bigtime_t lastUpdate;
	if (message.FindInt64("last_timestamp", &lastUpdate) == B_OK
		&& lastUpdate >= fLastUpdate) {
		// There weren't any changes since last time.
		BMessage reply;
		reply.AddBool("need_update", false);

		message.SendReply(&reply, (BHandler*)NULL, TIMEOUT);
		return;
	}

	// Add all meta formats to the list
	BMessage reply;
	reply.AddBool("need_update", true);
	reply.AddInt64("timestamp", system_time());

	int32 count = fList.CountItems();
	printf("FormatManager::GetFormats(): put %" B_PRId32 " formats into "
		"message\n", count);
	for (int32 i = 0; i < count; i++) {
		meta_format* format = fList.ItemAt(i);
		reply.AddData("formats", MEDIA_META_FORMAT_TYPE, format,
			sizeof(meta_format));
	}

	message.SendReply(&reply, (BHandler*)NULL, TIMEOUT);
}
Example #12
0
// -------------------------------------------------------------------
void
DRRegrView::MessageReceived(BMessage* theMesg)
{
	BMessage* dispMesg;
	int16 itemChecked;
	BMenu* theMenu;
	
	switch (theMesg->what) {
	
		case apply_change :
			dispMesg = new BMessage(set_display);
			dispMesg->AddInt64(disp_set_name,mKey);
			dispMesg->AddInt16(disp_mark_name,mPlotMark->PlotMark());
			dispMesg->AddInt32(mark_col_name,mColorCtrl->Value());
			theMenu = mLineSelect->Menu();
			itemChecked = theMenu->IndexOf(theMenu->FindMarked());
			dispMesg->AddInt16(disp_line_name,itemChecked);
			be_app->PostMessage(dispMesg);
			delete dispMesg;
			break;
			
		default :
			BView::MessageReceived(theMesg);
	}
}		
status_t
SATGroup::ArchiveGroup(BMessage& archive)
{
	archive.AddInt32("htab_count", fHorizontalTabs.CountItems());
	archive.AddInt32("vtab_count", fVerticalTabs.CountItems());

	for (int i = 0; i < fWindowAreaList.CountItems(); i++) {
		WindowArea* area = fWindowAreaList.ItemAt(i);
		int32 leftTab = fVerticalTabs.IndexOf(area->LeftTab());
		int32 rightTab = fVerticalTabs.IndexOf(area->RightTab());
		int32 topTab = fHorizontalTabs.IndexOf(area->TopTab());
		int32 bottomTab = fHorizontalTabs.IndexOf(area->BottomTab());

		BMessage areaMessage;
		areaMessage.AddInt32("left_tab", leftTab);
		areaMessage.AddInt32("right_tab", rightTab);
		areaMessage.AddInt32("top_tab", topTab);
		areaMessage.AddInt32("bottom_tab", bottomTab);

		const SATWindowList& windowList = area->WindowList();
		for (int a = 0; a < windowList.CountItems(); a++)
			areaMessage.AddInt64("window", windowList.ItemAt(a)->Id());

		archive.AddMessage("area", &areaMessage);
	}
	return B_OK;
}
Example #14
0
status_t
ActivityView::SaveState(BMessage& state) const
{
	status_t status = state.AddBool("show legend", fShowLegend);
	if (status != B_OK)
		return status;

	status = state.AddInt64("refresh interval", fRefreshInterval);
	if (status != B_OK)
		return status;

	status = state.AddData("history background color", B_RGB_COLOR_TYPE,
		&fHistoryBackgroundColor, sizeof(rgb_color));
	if (status != B_OK)
		return status;

	for (int32 i = 0; i < fSources.CountItems(); i++) {
		DataSource* source = fSources.ItemAt(i);

		if (!source->PerCPU() || source->CPU() == 0)
			status = state.AddString("source", source->InternalName());
		if (status != B_OK)
			return status;

		BString name = source->Name();
		name << " color";
		rgb_color color = source->Color();
		state.AddData(name.String(), B_RGB_COLOR_TYPE, &color,
			sizeof(rgb_color));
	}
	return B_OK;
}
void
ActivityWindow::_AddDefaultView()
{
	BMessage settings;
	settings.AddInt64("refresh interval", RefreshInterval());

	ActivityView* view = new ActivityView("ActivityMonitor", &settings);

	switch (ActivityViewCount()) {
		case 0:
			// The first view defaults to memory usage
			view->AddDataSource(new UsedMemoryDataSource());
			view->AddDataSource(new CachedMemoryDataSource());
			break;
		case 2:
			// The third view defaults to network in/out
			view->AddDataSource(new NetworkUsageDataSource(true));
			view->AddDataSource(new NetworkUsageDataSource(false));
			break;
		case 1:
		default:
			// Everything beyond that defaults to a CPU usage view
			view->AddDataSource(new CPUUsageDataSource());
			break;
	}

	fLayout->AddItem(view->CreateHistoryLayoutItem());
	fLayout->AddItem(view->CreateLegendLayoutItem());
}
Example #16
0
void
jView::Draw(BRect update)
{
	DBG(AWT_EVT, printf( "jView::Draw(" ));
	DBG(AWT_EVT, update.PrintToStream());
	DBG(AWT_EVT, printf( "\n" ));

#if 0
  DBG(AWT_EVT, printf("Draw\n"));

// !!! NOT THE BEST PLACE, 
//     it would be better to intercept events before they are dispatched to the handlers
//     (see event_hook)

  BMessage * msg = new BMessage();

  msg->what = UPDATE_EVENT;					/* custom update event */
  msg->AddPointer(sourceTag, Window()); 
  msg->AddRect("frame", Frame());           /* update the entire frame */
  
  bigtime_t t = system_time();
  msg->AddInt64("when", t);

	update.PrintToStream();

	javaApp->AddMessage( msg );
#endif
} 
Example #17
0
void stub_source_run(je_source_plugin *cookie)
{
	source_private *data = (source_private *)cookie->data;
	BMessage drawBitmap(JE_DRAW_BITMAP);
	BMessage msg;
	
	msg.what = JE_FRAMERATE_CHANGED;
	msg.AddInt64("framerate", 33000);
	msg.AddInt32("which", data->id);
	data->graphics_pipeline->SendMessage(&msg);
	
	msg.RemoveName("framerate");
	msg.what = JE_FRAME_SIZE_CHANGED;
	msg.AddRect("rect", data->outSize);
	data->graphics_pipeline->SendMessage(&msg);
	
	msg.RemoveName("rect");
	msg.what = JE_SOURCE_READY;
	data->graphics_pipeline->SendMessage(&msg);
	
	while (1)
	{
		data->nextFrame = system_time() + 33000;
		snooze_until(data->nextFrame, B_SYSTEM_TIMEBASE);
		
		if (data->exit)
			break;
		
		drawBitmap.RemoveName("bitmap");
		drawBitmap.AddPointer("bitmap", data->frame);
		data->window->SendMessage(&drawBitmap);
	}
	// it's ok to kill us now
	release_sem(data->exitSem);
}
Example #18
0
status_t
PathHandler::_AddFile(BEntry& entry, bool notify)
{
	if ((fFlags & (WATCH_NODE_FLAG_MASK & ~B_WATCH_DIRECTORY)) == 0)
		return B_OK;

#ifdef TRACE_PATH_MONITOR
{
	BPath path(&entry);
	TRACE("  ADD FILE %s\n", path.Path());
}
#endif

	node_ref nodeRef;
	status_t status = entry.GetNodeRef(&nodeRef);
	if (status != B_OK)
		return status;

	// check if we already know this file

	// TODO: It should be possible to omit this check if we know it
	// can't be the case (for example when adding subfolders recursively,
	// although in that case, the API user may still have added this file
	// independently, so for now, it should be the safest to perform this
	// check in all cases.)
	if (_HasFile(nodeRef))
		return B_OK;

	status = watch_node(&nodeRef, (fFlags & WATCH_NODE_FLAG_MASK), this);
	if (status != B_OK)
		return status;

	FileEntry setEntry;
	entry.GetRef(&setEntry.ref);
	setEntry.node = nodeRef.node;

	fFiles.insert(setEntry);

	if (notify && _WatchFilesOnly()) {
		// We also notify our target about new files if it's only interested
		// in files; it won't be notified about new directories, so it cannot
		// know when to search for them.
		BMessage update;
		update.AddInt32("opcode", B_ENTRY_CREATED);
		update.AddInt32("device", nodeRef.device);
		update.AddInt64("directory", setEntry.ref.directory);
		update.AddString("name", setEntry.ref.name);
		update.AddBool("added", true);

		_NotifyTarget(&update, nodeRef);
	}

	return B_OK;
}
Example #19
0
void Ticker::Start() {

	Stop();
	BMessage	*msg = new BMessage();
	msg->AddInt64("snooze", fDelay);
	msg->AddPointer("looper", this);
	
	fTicker = spawn_thread(ticker, "Beat Ticker", 50, msg);
	resume_thread(fTicker);

}
Example #20
0
status_t VBoxMouse::_ServiceThread()
{
    Log(("VBoxMouse::%s()\n", __FUNCTION__));

    fDriverFD = open(VBOXGUEST_DEVICE_NAME, O_RDWR);
    if (fDriverFD < 0)
        return ENXIO;

    /* The thread waits for incoming messages from the host. */
    while (!fExiting)
    {
        uint32_t cx, cy, fFeatures;
        int rc;

        fd_set readSet, writeSet, errorSet;
        FD_ZERO(&readSet);
        FD_ZERO(&writeSet);
        FD_ZERO(&errorSet);
        FD_SET(fDriverFD, &readSet);
        if (fDriverFD < 0)
            break;
        rc = select(fDriverFD + 1, &readSet, &writeSet, &errorSet, NULL);
        if (rc < 0)
        {
            if (errno == EINTR || errno == EAGAIN)
                continue;
            break;
        }

        rc = VbglR3GetMouseStatus(&fFeatures, &cx, &cy);
        if (   RT_SUCCESS(rc)
            && (fFeatures & VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE))
        {
            float x = cx * 1.0 / 65535;
            float y = cy * 1.0 / 65535;

            _debugPrintf("VBoxMouse: at %d,%d %f,%f\n", cx, cy, x, y);

            /* Send absolute movement */
            bigtime_t now = system_time();
            BMessage *event = new BMessage(B_MOUSE_MOVED);
            event->AddInt64("when", now);
            event->AddFloat("x", x);
            event->AddFloat("y", y);
            event->AddFloat("be:tablet_x", x);
            event->AddFloat("be:tablet_y", y);
            //event->PrintToStream();
            EnqueueMessage(event);

            //LogRelFlow(("processed host event rc = %d\n", rc));
        }
    }
    return 0;
}
Example #21
0
void QueryMenu::EntryCreated( const entry_ref &ref, ino_t node )
{
	BMessage 		*msg;
	BMenuItem 		*item;
	
	msg = new BMessage( B_REFS_RECEIVED );
	msg->AddRef( "refs", &ref );
	msg->AddInt64( "node", node );
	item = new BMenuItem( ref.name, msg );
	if( fTargetHandler )
		item->SetTarget( fTargetHandler );
	AddItem( item );
}
Example #22
0
BMenuItem*
ShowImageWindow::_AddDelayItem(BMenu* menu, const char* label, bigtime_t delay)
{
	BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY);
	message->AddInt64("delay", delay);

	BMenuItem* item = new BMenuItem(label, message, 0);
	item->SetTarget(this);

	if (delay == fSlideShowDelay)
		item->SetMarked(true);

	menu->AddItem(item);
	return item;
}
Example #23
0
void
ScreenshotWindow::_WriteSettings()
{
	if (fDelayControl)
		fDelay = (atoi(fDelayControl->Text()) * 1000000) + 50000;

	BMessage settings;

	settings.AddInt32("type", fImageFileType);
	settings.AddBool("includeBorder", fIncludeBorder);
	settings.AddBool("includeCursor", fIncludeCursor);
	settings.AddBool("grabActiveWindow", fGrabActiveWindow);
	settings.AddInt64("delay", fDelay);
	settings.AddString("outputFilename", fOutputFilename);

	BString path;
	int32 count = fOutputPathMenu->CountItems();
	if (count > 5) {
		for (int32 i = count - 3; i > count - 8 && i > 2; --i) {
			BMenuItem* item = fOutputPathMenu->ItemAt(i);
			if (item) {
				BMessage* msg = item->Message();
				if (msg && msg->FindString("path", &path) == B_OK)
					settings.AddString("path", path.String());
			}
		}
	}

	if (fLastSelectedPath) {
		BMessage* msg = fLastSelectedPath->Message();
		if (msg && msg->FindString("path", &path) == B_OK)
			settings.AddString("lastSelectedPath", path.String());
	}

	BPath settingsPath;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &settingsPath) != B_OK)
		return;
	settingsPath.Append("Screenshot_settings");

	BFile file(settingsPath.Path(), B_CREATE_FILE | B_ERASE_FILE
		| B_WRITE_ONLY);
	if (file.InitCheck() == B_OK) {
		ssize_t size;
		settings.Flatten(&file, &size);
	}
}
Example #24
0
filter_result
DCCFileFilter::HandleAlert (BMessage *msg)
{
	BTextControl *text (dynamic_cast<BTextControl *>(
		panel->Window()->FindView ("text view")));
	int32 which;

	msg->FindInt32 ("which", &which);

	if (which == 0 || text == 0)
	{
		return B_SKIP_MESSAGE;
	}

	entry_ref ref;
	panel->GetPanelDirectory (&ref);

	if (which == 2)
	{
		BDirectory dir (&ref);
		BFile file (&dir, text->Text(), B_READ_ONLY);
		BEntry entry (&dir, text->Text());
		BPath path;
		off_t position;

		file.GetSize (&position);
		entry.GetPath (&path);
		send_msg.AddString ("path", path.Path());
		send_msg.AddInt64  ("pos", position);

		send_msg.what = M_ADD_RESUME_DATA;
	}
	else
	{
		send_msg.AddRef ("directory", &ref);
		send_msg.AddString ("name", text->Text());
	}

	panel->Messenger().SendMessage (&send_msg);

	BMessage cmsg (B_CANCEL);
	cmsg.AddPointer ("source", panel);
	panel->Messenger().SendMessage (&cmsg);

	return B_SKIP_MESSAGE;
}
Example #25
0
void
FSClipboardRemove(Model *model)
{
	BMessenger messenger(kTrackerSignature);
	if (messenger.IsValid()) {
		BMessage *report = new BMessage(kFSClipboardChanges);
		TClipboardNodeRef tcnode;
		tcnode.node = *model->NodeRef();
		tcnode.moveMode = kDelete;
		const entry_ref *ref = model->EntryRef();
		report->AddInt32("device", ref->device);
		report->AddInt64("directory", ref->directory);
		report->AddBool("clearClipboard", false);
		report->AddData("tcnode", T_CLIPBOARD_NODE, &tcnode, sizeof(tcnode), true);
		messenger.SendMessage(report);
		delete report;
	}
}
Example #26
0
status_t
BKey::Flatten(BMessage& message) const
{
	if (message.MakeEmpty() != B_OK
		|| message.AddUInt32("type", Type()) != B_OK
		|| message.AddUInt32("purpose", fPurpose) != B_OK
		|| message.AddString("identifier", fIdentifier) != B_OK
		|| message.AddString("secondaryIdentifier", fSecondaryIdentifier)
			!= B_OK
		|| message.AddString("owner", fOwner) != B_OK
		|| message.AddInt64("creationTime", fCreationTime) != B_OK
		|| message.AddData("data", B_RAW_TYPE, fData.Buffer(),
			fData.BufferLength()) != B_OK) {
		return B_ERROR;
	}

	return B_OK;
}
void
SimpleColorPicker::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kColorChanged:
		{
			// Received from the BColorControl when its color changes
			fColor = fColorControl->ValueAsColor();
			fColor.alpha = 255;
			fColorPreview->SetColor(fColor);
			BMessage* forward = new BMessage(kColorChanged);
			forward->AddInt64("when", (int64)system_time());
			forward->AddData("be:value", B_RGB_COLOR_TYPE, &fColor,
				sizeof(fColor));
			Window()->PostMessage(forward);
			delete forward;
			break;
		}

		case kColorDropped:
		{
			char* nameFound;
			type_code typeFound;
			if (message->GetInfo(B_RGB_COLOR_TYPE, 0, &nameFound, &typeFound)
					!= B_OK) {
				BView::MessageReceived(message);
				return;
			}

			rgb_color* color;
			ssize_t numBytes;
			if (message->FindData(nameFound, typeFound, (const void **)&color,
					&numBytes) == B_OK) {
				SetColor(*color);
				Window()->PostMessage(message);
			}
		}

		default:
			BView::MessageReceived(message);
	}
}
Example #28
0
void 
BottomlineWindow::HandleInputMethodEvent(BMessage* event, EventList& newEvents)
{
	CALLED();

	PostMessage(event, fTextView);

	const char* string;
	bool confirmed;
	int32 opcode;
	if (event->FindInt32("be:opcode", &opcode) != B_OK
		|| opcode != B_INPUT_METHOD_CHANGED
		|| event->FindBool("be:confirmed", &confirmed) != B_OK
		|| !confirmed
		|| event->FindString("be:string", &string) != B_OK) 
		return;

	SERIAL_PRINT(("IME : %i, %s\n", opcode, string));
	SERIAL_PRINT(("IME : confirmed\n"));

	int32 length = strlen(string);
	int32 offset = 0;
	int32 nextOffset = 0;

	while (offset < length) {
		// this is supposed to go to the next UTF-8 character
		for (++nextOffset; (string[nextOffset] & 0xC0) == 0x80; ++nextOffset)
			;

		BMessage *newEvent = new BMessage(B_KEY_DOWN);
		if (newEvent != NULL) {
			newEvent->AddInt32("key", 0);
			newEvent->AddInt64("when", system_time());
			BString bytes(string + offset, nextOffset - offset);
			newEvent->AddString("bytes", bytes);
			newEvent->AddInt32("raw_char", 0xa);
			newEvents.AddItem(newEvent);
		}

		offset = nextOffset;
	}
}
void
PropEnumEditor::HandleEdit(int32 value)
{
	PObject *obj = GetObject();
	PProperty *prop = obj->FindProperty(fPropName->String());
	obj->SetIntProperty(fPropName->String(),value);
	
	BMessage *editMsg = new BMessage(M_PROPERTY_EDITED);
	
	if (obj && prop)
	{
		editMsg->AddPointer("object",obj);
		editMsg->AddPointer("property",prop);
		editMsg->AddInt64("objectid",obj->GetID());
		editMsg->AddString("name",prop->GetName());
		*fPropName = prop->GetName();
	}
	
	fMsgr->SendMessage(editMsg);
}
Example #30
0
void 
BMidiLocalConsumer::SetLatency(bigtime_t latency_)
{
	if (latency_ < 0) {
		WARN("SetLatency() does not accept negative values");
		return;
	} else if (!IsValid()) {
		return;
	} else if (fLatency != latency_) {
		BMessage msg;
		msg.AddInt64("midi:latency", latency_);

		if (SendChangeRequest(&msg) == B_OK) {
			if (LockLooper()) {
				fLatency = latency_;
				UnlockLooper();
			}
		}
	}
}