예제 #1
0
void
AddOnManager::_LoadReplicant()
{
	CALLED();
	app_info info;
	be_app->GetAppInfo(&info);

	status_t err = BDeskbar().AddItem(&info.ref);
	if (err != B_OK) {
		ERROR("Deskbar refuses to add method replicant: %s\n", strerror(err));
	}
	BMessage request(B_GET_PROPERTY);
	BMessenger to;
	BMessenger status;

	request.AddSpecifier("Messenger");
	request.AddSpecifier("Shelf");

	// In the Deskbar the Shelf is in the View "Status" in Window "Deskbar"
	request.AddSpecifier("View", "Status");
	request.AddSpecifier("Window", "Deskbar");
	to = BMessenger("application/x-vnd.Be-TSKB", -1);

	BMessage reply;

	if (to.SendMessage(&request, &reply) == B_OK
		&& reply.FindMessenger("result", &status) == B_OK) {
		// enum replicant in Status view
		int32 index = 0;
		int32 uid;
		while ((uid = _GetReplicantAt(status, index++)) >= B_OK) {
			BMessage replicantInfo;
			if (_GetReplicantName(status, uid, &replicantInfo) != B_OK)
				continue;

			const char *name;
			if (replicantInfo.FindString("result", &name) == B_OK
				&& !strcmp(name, REPLICANT_CTL_NAME)) {
				BMessage replicant;
				if (_GetReplicantView(status, uid, &replicant) == B_OK) {
					BMessenger result;
					if (replicant.FindMessenger("result", &result) == B_OK) {
						gInputServer->SetMethodReplicant(new BMessenger(result));
					}
				}
			}
		}
	}

	if (!gInputServer->MethodReplicant()) {
		ERROR("LoadReplicant(): Method replicant not found!\n");
	}
}
예제 #2
0
BCheckBox*
AudioSettingsView::_MakeVolumeCheckBox()
{
	fVolumeCheckBox = new BCheckBox("volumeCheckBox",
		B_TRANSLATE("Show volume control on Deskbar"),
		new BMessage(MEDIA_SHOW_HIDE_VOLUME_CONTROL));

	if (BDeskbar().HasItem("MediaReplicant"))
		fVolumeCheckBox->SetValue(B_CONTROL_ON);

	return fVolumeCheckBox;
}
예제 #3
0
void
AddOnManager::_UnloadReplicant()
{
	BDeskbar().RemoveItem(REPLICANT_CTL_NAME);
}
예제 #4
0
status_t
AddOnManager::_UnregisterAddOn(BEntry& entry)
{
	BPath path(&entry);

	entry_ref ref;
	status_t status = entry.GetRef(&ref);
	if (status < B_OK)
		return status;

	TRACE("AddOnManager::UnregisterAddOn(): trying to unload \"%s\"\n",
		path.Path());

	BAutolock _(this);

	if (_IsDevice(path.Path())) {
		for (int32 i = fDeviceList.CountItems(); i-- > 0;) {
			device_info* info = fDeviceList.ItemAt(i);
			if (!strcmp(info->ref.name, ref.name)) {
				gInputServer->StartStopDevices(*info->add_on, false);
				delete fDeviceList.RemoveItemAt(i);
				break;
			}
		}
	} else if (_IsFilter(path.Path())) {
		for (int32 i = fFilterList.CountItems(); i-- > 0;) {
			filter_info* info = fFilterList.ItemAt(i);
			if (!strcmp(info->ref.name, ref.name)) {
				BAutolock locker(InputServer::gInputFilterListLocker);
				InputServer::gInputFilterList.RemoveItem(info->add_on);
				delete fFilterList.RemoveItemAt(i);
				break;
			}
		}
	} else if (_IsMethod(path.Path())) {
		BInputServerMethod* method = NULL;

		for (int32 i = fMethodList.CountItems(); i-- > 0;) {
			method_info* info = fMethodList.ItemAt(i);
			if (!strcmp(info->ref.name, ref.name)) {
				BAutolock locker(InputServer::gInputMethodListLocker);
				InputServer::gInputMethodList.RemoveItem(info->add_on);
				method = info->add_on;
					// this will only be used as a cookie, and not referenced
					// anymore
				delete fMethodList.RemoveItemAt(i);
				break;
			}
		}

		if (fMethodList.CountItems() <= 0) {
			// we remove the method replicant
			BDeskbar().RemoveItem(REPLICANT_CTL_NAME);
			gInputServer->SetMethodReplicant(NULL);
		} else if (method != NULL) {
			BMessage msg(IS_REMOVE_METHOD);
			msg.AddInt32("cookie", (uint32)method);
			if (gInputServer->MethodReplicant())
				gInputServer->MethodReplicant()->SendMessage(&msg);
		}
	}

	return B_OK;
}