status_t
BMailAccountSettings::Save()
{
	fModified = false;

	BMessage settings;
	settings.AddInt32("id", fAccountID);
	settings.AddString("name", fAccountName);
	settings.AddString("real_name", fRealName);
	settings.AddString("return_address", fReturnAdress);

	BMessage inboundSettings;
	fInboundSettings.Save(inboundSettings);
	settings.AddMessage("inbound", &inboundSettings);
	BMessage outboundSettings;
	fOutboundSettings.Save(outboundSettings);
	settings.AddMessage("outbound", &outboundSettings);

	settings.AddBool("inbound_enabled", fInboundEnabled);
	settings.AddBool("outbound_enabled", fOutboundEnabled);

	status_t status = _CreateAccountFilePath();
	if (status != B_OK)
		return status;

	BFile file(&fAccountFile, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
	status = file.InitCheck();
	if (status != B_OK)
		return status;
	return settings.Flatten(&file);
}
Exemple #2
0
bool BeGadu::QuitRequested() {
	DelDeskbarIcon();
//	if( iProfileSelector )
//		if( iProfileSelector->Lock() )
//			iProfileSelector->Quit();
	if( iWindow ) {
		if( iLastProfile )
			iLastProfile->SetTo( iWindow->GetProfile()->GetProfileName() );
		else
			iLastProfile = new BString( iWindow->GetProfile()->GetProfileName() );
		fprintf( stderr, _T("Last profile %s\n"), iLastProfile->String() );
		if( iWindow->Lock() )
			iWindow->Quit();
	}

	/* saving configuration */
	BMessage * cfgmesg = new BMessage();
	cfgmesg->AddBool( "iFirstRun", iFirstRun );
	cfgmesg->AddBool( "iHideAtStart", iHideAtStart );
	cfgmesg->AddString( "iLastProfile", *iLastProfile );

	BPath path;
	find_directory( B_USER_SETTINGS_DIRECTORY, &path );
	path.Append( "BeGadu/Config" );
	fprintf( stderr, _T("Saving configuration to %s\n"), path.Path() );
	BFile file( path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE );
	if( file.InitCheck() == B_OK ) {
		cfgmesg->Flatten( &file );
		file.Unset();
	}

	delete cfgmesg;
	BApplication::QuitRequested();
	return true;
}
Exemple #3
0
void
SelectionWindow::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case kSelectButtonPressed:
			{
					Hide();
					// Order of posting and hiding important
					// since we want to activate the target
					// window when the message arrives.
					// (Hide is synhcronous, while PostMessage is not.)
					// See PoseView::SelectMatchingEntries().
					
				BMessage *selectionInfo = new BMessage(kSelectMatchingEntries);
				selectionInfo->AddInt32("ExpressionType", ExpressionType());
				BString expression;
				Expression(expression);
				selectionInfo->AddString("Expression", expression.String());
				selectionInfo->AddBool("InvertSelection", Invert());
				selectionInfo->AddBool("IgnoreCase", IgnoreCase());
				fParentWindow->PostMessage(selectionInfo);
			}
			break;
	
		default:
			_inherited::MessageReceived(message);
	}
}
Exemple #4
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);
}
// SetMenu
void
ShapeListView::SetMenu(BMenu* menu)
{
	if (fMenu == menu)
		return;

	fMenu = menu;
	if (fMenu == NULL)
		return;

	BMessage* message = new BMessage(MSG_ADD_SHAPE);
	fAddEmptyMI = new BMenuItem(B_TRANSLATE("Add empty"), message);

	message = new BMessage(MSG_ADD_SHAPE);
	message->AddBool("path", true);
	fAddWidthPathMI = new BMenuItem(B_TRANSLATE("Add with path"), message);

	message = new BMessage(MSG_ADD_SHAPE);
	message->AddBool("style", true);
	fAddWidthStyleMI = new BMenuItem(B_TRANSLATE("Add with style"), message);

	message = new BMessage(MSG_ADD_SHAPE);
	message->AddBool("path", true);
	message->AddBool("style", true);
	fAddWidthPathAndStyleMI = new BMenuItem(
		B_TRANSLATE("Add with path & style"), message);

	fDuplicateMI = new BMenuItem(B_TRANSLATE("Duplicate"), 
		new BMessage(MSG_DUPLICATE));
	fResetTransformationMI = new BMenuItem(B_TRANSLATE("Reset transformation"),
		new BMessage(MSG_RESET_TRANSFORMATION));
	fFreezeTransformationMI = new BMenuItem(
		B_TRANSLATE("Freeze transformation"), 
		new BMessage(MSG_FREEZE_TRANSFORMATION));

	fRemoveMI = new BMenuItem(B_TRANSLATE("Remove"), new BMessage(MSG_REMOVE));


	fMenu->AddItem(fAddEmptyMI);
	fMenu->AddItem(fAddWidthPathMI);
	fMenu->AddItem(fAddWidthStyleMI);
	fMenu->AddItem(fAddWidthPathAndStyleMI);

	fMenu->AddSeparatorItem();

	fMenu->AddItem(fDuplicateMI);
	fMenu->AddItem(fResetTransformationMI);
	fMenu->AddItem(fFreezeTransformationMI);

	fMenu->AddSeparatorItem();

	fMenu->AddItem(fRemoveMI);

	fDuplicateMI->SetTarget(this);
	fResetTransformationMI->SetTarget(this);
	fFreezeTransformationMI->SetTarget(this);
	fRemoveMI->SetTarget(this);

	_UpdateMenu();
}
Exemple #6
0
void
OpenWithContainerWindow::NewAttributeMenu(BMenu* menu)
{
	_inherited::NewAttributeMenu(menu);

	BMessage* message = new BMessage(kAttributeItem);
	message->AddString("attr_name", kAttrOpenWithRelation);
	message->AddInt32("attr_type", B_STRING_TYPE);
	message->AddInt32("attr_hash",
		(int32)AttrHashString(kAttrOpenWithRelation, B_STRING_TYPE));
	message->AddFloat("attr_width", 180);
	message->AddInt32("attr_align", B_ALIGN_LEFT);
	message->AddBool("attr_editable", false);
	message->AddBool("attr_statfield", false);

	BMenuItem* item = new BMenuItem(B_TRANSLATE("Relation"), message);
	menu->AddItem(item);
	message = new BMessage(kAttributeItem);
	message->AddString("attr_name", kAttrAppVersion);
	message->AddInt32("attr_type", B_STRING_TYPE);
	message->AddInt32("attr_hash",
		(int32)AttrHashString(kAttrAppVersion, B_STRING_TYPE));
	message->AddFloat("attr_width", 70);
	message->AddInt32("attr_align", B_ALIGN_LEFT);
	message->AddBool("attr_editable", false);
	message->AddBool("attr_statfield", false);

	item = new BMenuItem(B_TRANSLATE("Version"), message);
	menu->AddItem(item);
}
void
Renamer_Extension::DetachedFromWindow()
{
	BMessage msg;
	msg.AddBool("replace", (bool)fReplaceOldCheckBox->Value());
	msg.AddBool("upperlower", (bool)fLowerCase->Value() == B_CONTROL_ON);

	UpdatePreferences("ren_extension", msg);
}
bool
ConnectionOptionsAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
{
	fIsNew = isNew;
	fDoesDialOnDemand = fAskBeforeDialing = fDoesAutoRedial = false;
	fSettings = settings;
	fProfile = profile;
	
	if(fConnectionOptionsView)
		fConnectionOptionsView->Reload();
			// reset all views (empty settings)
	
	if(!settings || !profile || isNew)
		return true;
	
	BMessage parameter;
	int32 index = 0;
	const char *value;
	if(FindMessageParameter(PPP_DIAL_ON_DEMAND_KEY, *fSettings, &parameter, &index)
			&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
		if(get_boolean_value(value, false))
			fDoesDialOnDemand = true;
		
		parameter.AddBool(MDSU_VALID, true);
		fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	index = 0;
	if(FindMessageParameter(PPP_ASK_BEFORE_DIALING_KEY, *fSettings, &parameter, &index)
			&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
		if(get_boolean_value(value, false))
			fAskBeforeDialing = true;
		
		parameter.AddBool(MDSU_VALID, true);
		fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	index = 0;
	if(FindMessageParameter(PPP_AUTO_REDIAL_KEY, *fSettings, &parameter, &index)
			&& parameter.FindString(MDSU_VALUES, &value) == B_OK) {
		if(get_boolean_value(value, false))
			fDoesAutoRedial = true;
		
		parameter.AddBool(MDSU_VALID, true);
		fSettings->ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	if(fConnectionOptionsView)
		fConnectionOptionsView->Reload();
			// reload new settings
	
	return true;
}
Exemple #9
0
bool
PPPoEAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
{
	fIsNew = isNew;
	fInterfaceName = fServiceName = "";
	fSettings = settings;
	fProfile = profile;
	
	if(fPPPoEView)
		fPPPoEView->Reload();
	
	if(!settings || !profile || isNew)
		return true;
	
	BMessage device;
	int32 deviceIndex = 0;
	if(!FindMessageParameter(PPP_DEVICE_KEY, *fSettings, &device, &deviceIndex))
		return false;
			// error: no device
	
	BString name;
	if(device.FindString(MDSU_VALUES, &name) != B_OK || name != kKernelModuleName)
		return false;
			// error: no device
	
	BMessage parameter;
	int32 index = 0;
	if(!FindMessageParameter(PPPoE_INTERFACE_KEY, device, &parameter, &index)
			|| parameter.FindString(MDSU_VALUES, &fInterfaceName) != B_OK)
		return false;
			// error: no interface
	else {
		parameter.AddBool(MDSU_VALID, true);
		device.ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	index = 0;
	if(!FindMessageParameter(PPPoE_SERVICE_NAME_KEY, device, &parameter, &index)
			|| parameter.FindString(MDSU_VALUES, &fServiceName) != B_OK)
		fServiceName = "";
	else {
		parameter.AddBool(MDSU_VALID, true);
		device.ReplaceMessage(MDSU_PARAMETERS, index, &parameter);
	}
	
	device.AddBool(MDSU_VALID, true);
	fSettings->ReplaceMessage(MDSU_PARAMETERS, deviceIndex, &device);
	
	if(fPPPoEView)
		fPPPoEView->Reload();
	
	return true;
}
Exemple #10
0
status_t TaskFS::SetUpMimeTyp(void)
{
	status_t err;
	//set the MimeType
	BMimeType mime(TASK_MIMETYPE);
	//later do better check
	bool valid = mime.IsInstalled();
	if (!valid) {
		mime.Install();
		mime.SetShortDescription(B_TRANSLATE_CONTEXT("Tasks",
			"Short mimetype description"));
		mime.SetLongDescription(B_TRANSLATE_CONTEXT("Tasks",
			"Long mimetype description"));
		//get the icon from our Ressources
		BResources* res = BApplication::AppResources();
		if (res != NULL){
			size_t size;
			const void* data = res->LoadResource(B_VECTOR_ICON_TYPE, "TASK_ICON", &size);
			if (data!=NULL)
				mime.SetIcon(reinterpret_cast<const uint8*>(data), size);
		}
		mime.SetPreferredApp(APP_SIG);

		// add default task fields to meta-mime type
		BMessage fields;
		for (int32 i = 0; sDefaultAttributes[i].attribute; i++) {
			fields.AddString("attr:public_name", sDefaultAttributes[i].name);
			fields.AddString("attr:name", sDefaultAttributes[i].attribute);
			fields.AddInt32("attr:type", sDefaultAttributes[i].type);
			fields.AddString("attr:display_as", sDefaultAttributes[i].displayAs);
			fields.AddBool("attr:viewable", sDefaultAttributes[i].isPublic);
			fields.AddBool("attr:editable", sDefaultAttributes[i].editable);
			fields.AddInt32("attr:width", sDefaultAttributes[i].width);
			fields.AddInt32("attr:alignment", B_ALIGN_LEFT);
			fields.AddBool("attr:extra", false);
		}
		mime.SetAttrInfo(&fields);
			// create indices on all volumes for the found attributes.
		int32 count = 8;
		BVolumeRoster volumeRoster;
		BVolume volume;
		while (volumeRoster.GetNextVolume(&volume) == B_OK) {
			for (int32 i = 0; i < count; i++) {
				if (sDefaultAttributes[i].isPublic == true)
					fs_create_index(volume.Device(), sDefaultAttributes[i].attribute,
						sDefaultAttributes[i].type, 0);
			}
		}
	}
	else
		err = B_OK;
	return err;
}
Exemple #11
0
status_t
Settings::SetDefaults()
{
	sSettings.MakeEmpty();
	sSettings.AddString(kOutputFile, "/boot/home/outputfile");
	sSettings.AddFloat(kClipShrink, 100);
	sSettings.AddInt32(kClipDepth, B_RGB32);
	sSettings.AddBool(kIncludeCursor, true);
	sSettings.AddInt32(kThreadPriority, B_NORMAL_PRIORITY);
	sSettings.AddBool(kMinimize, false);
	
	return B_OK;
}
Exemple #12
0
void
MainWindow::StoreSettings(BMessage& settings) const
{
	settings.AddRect("window frame", Frame());

	BMessage columnSettings;
	fPackageListView->SaveState(&columnSettings);

	settings.AddMessage("column settings", &columnSettings);

	settings.AddBool("show develop packages", fModel.ShowDevelopPackages());
	settings.AddBool("show source packages", fModel.ShowSourcePackages());
}
Exemple #13
0
void
NotifyList::BuildPopUp(void)
{
  delete fMyPopUp;
  fMyPopUp = new BPopUpMenu("Notify selection", false, false);

  int index (CurrentSelection());
  if (index < 0)
    return;
  
  NotifyListItem *item (dynamic_cast<NotifyListItem *>(ItemAt(index)));
  if (item)
  {
    BString name (item->Text());
    BMessage msg (M_SUBMIT);
    BString data ("/QUERY ");
    data.Append(name);
    msg.AddString("input", data.String());
    msg.AddBool ("history", false);
    msg.AddBool ("clear", false);
    fMyPopUp->AddItem (new BMenuItem (S_NOTIFYLIST_QUERY_ITEM, new BMessage (msg)));
    data = "/WHOIS ";
    data.Append(name);
    msg.ReplaceString("input", data.String());
    fMyPopUp->AddItem (new BMenuItem (S_NOTIFYLIST_WHOIS_ITEM, new BMessage (msg)));
    data = "/DCC CHAT ";
    data.Append(name);
    msg.ReplaceString("input", data.String());
    fMyPopUp->AddItem (new BMenuItem (S_NOTIFYLIST_DCC_ITEM, new BMessage (msg)));
    fMyPopUp->AddSeparatorItem();
    data = "/UNNOTIFY ";
    data.Append(name);
    msg.ReplaceString("input", data.String());
    fMyPopUp->AddItem (new BMenuItem (S_NOTIFYLIST_REMOVE_ITEM, new BMessage (msg)));

    WindowListItem *winItem (dynamic_cast<WindowListItem *>(
      vision_app->pClientWin()->pWindowList()->ItemAt(
        vision_app->pClientWin()->pWindowList()->CurrentSelection())));
    if (winItem)
      fMyPopUp->SetTargetForItems(winItem->pAgent());

    if (!item->GetState())
    {
      // user is offline, do not allow whois, query or dcc chat
      fMyPopUp->ItemAt(0)->SetEnabled(false);
      fMyPopUp->ItemAt(1)->SetEnabled(false);
      fMyPopUp->ItemAt(2)->SetEnabled(false);
    }
    fMyPopUp->SetFont(be_plain_font);
  }
}
void
Renamer_Remove::DetachedFromWindow()
{
	BMessage msg;
	msg.AddInt32("pos1", fPosition1->Value());
	msg.AddInt32("pos2", fPosition2->Value());

	BMenu* menu = fDirection1->Menu();
	msg.AddBool("direction1", bool(menu->IndexOf(menu->FindMarked())));
	menu = fDirection2->Menu();
	msg.AddBool("direction2", bool(menu->IndexOf(menu->FindMarked())));

	UpdatePreferences("ren_remove", msg);
}
Exemple #15
0
void
BColumn::ArchiveToMessage(BMessage &message) const
{
	message.AddInt32(kColumnVersionName, kColumnStateArchiveVersion);

	message.AddString(kColumnTitleName, fTitle);
	message.AddFloat(kColumnOffsetName, fOffset);
	message.AddFloat(kColumnWidthName, fWidth);
	message.AddInt32(kColumnAlignmentName, fAlignment);
	message.AddString(kColumnAttrName, fAttrName);
	message.AddInt32(kColumnAttrHashName, static_cast<int32>(fAttrHash));
	message.AddInt32(kColumnAttrTypeName, static_cast<int32>(fAttrType));
	message.AddBool(kColumnStatFieldName, fStatField);
	message.AddBool(kColumnEditableName, fEditable);
}
Exemple #16
0
bool
App::QuickImportProject(DPath folder)
{
	// Quickly makes a project in a folder by importing all resource files and C++ sources.
	if (!BEntry(folder.GetFullPath()).Exists())
		return false;

	BMessage settings;
	settings.AddString("name", folder.GetFileName());
	settings.AddString("target", folder.GetFileName());
	// skipping templatename field on purpose
	settings.AddInt32("type", PROJECT_GUI);
	settings.AddString("path", folder.GetFullPath());
	settings.AddInt32("scmtype", gDefaultSCM);
	settings.AddBool("createfolder", false);
	
	DPath path(folder);
	BEntry entry(path.GetFullPath());
	Project *proj = CreateNewProject(settings);
	if (!proj)
		return false;
	
	entry.SetTo(folder.GetFullPath());
	entry_ref addref;
	entry.GetRef(&addref);
	BMessage addmsg(M_ADD_FILES);
	addmsg.AddRef("refs",&addref);
	
	PostToProjectWindow(&addmsg,NULL);
	return true;
}
void AIMNetManager::MishMashWarningFunction( int type, SNAC_Object& snac )
{
	BMessage* msg;

	// you got booted because someone signed on w/ the same screen name
	if( type == 1 ) {
		printf( "You are being IMPERSONATED!!!! AAAAAAAHHHHHHH!!!!!\n" );
	
		// kill the connection and let 'em know why they got booted
		Logout();
		msg = new BMessage(BEAIM_DISCONNECTED);
		msg->AddBool("quietly", true);
		PostAppMessage( msg );
		windows->ShowMessage( Language.get("ERR_BEING_IMPERSONATED"), B_STOP_ALERT );
	}
	
	// you missed a few messages due to somebody else's rate violation
	else if( type == 2 ) {
		printf( "some messages were missed... the other person sent them too fast.\n" );
		windows->ShowMessage( Language.get("ERR_MISSED_MESSAGES"), B_INFO_ALERT );
	}
	
	// you did a rate violation yourself, you naughty person, you!
	else if( type == 3 ) {
		printf( "Rate violation!\n" );
		windows->ShowMessage( Language.get("ERR_RATE_VIOLATION"), B_STOP_ALERT, Language.get("BEHAVE_LABEL"), WS_WARNED );
	}
}
Exemple #18
0
int32
ClientWindow::ExecPipe (void *arg)
{
	BMessage *msg (reinterpret_cast<BMessage *>(arg));
	const char *exec;
	ClientWindow *client;
	
	msg->FindString ("exec", &exec);
	msg->FindPointer ("client", reinterpret_cast<void **>(&client));
	
	delete msg;
	
	FILE *fp = popen(exec, "r");

	char read[768]; // should be long enough for any line...
		
	while (fgets(read, 768, fp))
	{
		read[strlen(read)-1] = '\0'; // strip newline		
		
		BMessage msg (M_SUBMIT_RAW);
		msg.AddBool ("lines", 1);
		msg.AddString ("data", read);			
		client->PostMessage (&msg);
	}
		
	pclose(fp);
	
	return 0;

}
Exemple #19
0
BMessage AIMProtocol::GetSettingsTemplate() {
	BMessage main_msg(IM::SETTINGS_TEMPLATE);
	
	BMessage user_msg;
	user_msg.AddString("name","screenname");
	user_msg.AddString("description", "Screen Name");
	user_msg.AddInt32("type",B_STRING_TYPE);
	
	BMessage pass_msg;
	pass_msg.AddString("name","password");
	pass_msg.AddString("description", "Password");
	pass_msg.AddInt32("type",B_STRING_TYPE);
	pass_msg.AddBool("is_secret", true);

	BMessage profile;
	profile.AddString("name", "profile");
	profile.AddString("description", "User Profile");
	profile.AddInt32("type", B_STRING_TYPE);
	profile.AddString("default", "IM Kit: AIM user");
	profile.AddBool("multi_line", true);

	BMessage icon;
	icon.AddString("name", "icon");
	icon.AddString("description", "Buddy Icon");
	icon.AddInt32("type", B_STRING_TYPE);
		
	main_msg.AddMessage("setting",&user_msg);
	main_msg.AddMessage("setting",&pass_msg);
	main_msg.AddMessage("setting", &profile);
	main_msg.AddMessage("setting", &icon);
	
	return main_msg;
}
Exemple #20
0
void jsman::MessageReceived(BMessage *msg) {
	printf("JS_Man has received a BMessage\n");
	
	switch(msg->what) {
		case DisableJavascript: {
			if (js_enabled)
				js_enabled=false;
		}break;
		case EnableJavascript: {
			if (!js_enabled)
				js_enabled=true;
		}break;
		case GetJavascriptStatus: {
			BMessage reply;
			reply.AddBool("js_enabled",js_enabled);
			msg->SendReply(&reply);
		}break;
		case ProcessJSScript: {
			if (js_enabled) {
			}
		}break;
		case ClearJSScripts: {
			if (script_head) {
				jsscripts_st *cur;
				while (script_head!=NULL) {
					cur=script_head->next;
					delete script_head;
					script_head=cur;
				}
			}
		}break;
		default:
			BHandler::MessageReceived(msg);
	}
}
status_t
EthernetSettingsView::_TriggerAutoConfig(const char* device)
{
	BMessenger networkServer(kNetServerSignature);
	if (!networkServer.IsValid()) {
		(new BAlert("error", TR("The net_server needs to run for the auto "
			"configuration!"), TR("OK")))->Go();
		return B_ERROR;
	}

	BMessage message(kMsgConfigureInterface);
	message.AddString("device", device);
	BMessage address;
	address.AddString("family", "inet");
	address.AddBool("auto_config", true);
	message.AddMessage("address", &address);

	BMessage reply;
	status_t status = networkServer.SendMessage(&message, &reply);
	if (status != B_OK) {
		BString errorMessage(TR("Sending auto-config message failed: "));
		errorMessage << strerror(status);
		(new BAlert("error", errorMessage.String(), TR("OK")))->Go();
		return status;
	} else if (reply.FindInt32("status", &status) == B_OK
			&& status != B_OK) {
		BString errorMessage(TR("Auto-configuring failed: "));
		errorMessage << strerror(status);
		(new BAlert("error", errorMessage.String(), "OK"))->Go();
		return status;
	}

	return B_OK;
}
Exemple #22
0
void
TReplicantTray::ShowHideTime()
{
	if (fTime == NULL)
		return;

	// Check from the point of view of fTime because we need to ignore
	// whether or not the parent window is hidden.
	if (fTime->IsHidden(fTime))
		fTime->Show();
	else
		fTime->Hide();

	RealignReplicants();
	AdjustPlacement();

	// Check from the point of view of fTime ignoring parent's state.
	bool showClock = !fTime->IsHidden(fTime);

	// Update showClock setting that gets saved to disk on quit
	((TBarApp*)be_app)->Settings()->showClock = showClock;

	// Send a message to Time preferences telling it to update
	BMessenger messenger("application/x-vnd.Haiku-Time");
	BMessage* message = new BMessage(kShowHideTime);
	message->AddBool("showClock", showClock);
	messenger.SendMessage(message);
}
void
TReplicantTray::ShowHideTime()
{
	if (fTime == NULL)
		return;

	if (fTime->IsHidden())
		fTime->Show();
	else
		fTime->Hide();

	RealignReplicants();
	AdjustPlacement();

	bool showClock = !fTime->IsHidden();

	// Update showClock setting that gets saved to disk on quit
	((TBarApp*)be_app)->Settings()->showClock = showClock;

	// Send a message to Time preferences telling it to update
	BMessenger messenger("application/x-vnd.Haiku-Time");
	BMessage* message = new BMessage(kShowHideTime);
	message->AddBool("showClock", showClock);
	messenger.SendMessage(message);
}
Exemple #24
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;
}
Exemple #25
0
bool
FaberWindow::QuitRequested()
{
	if (ProjectManager::HasChanged()) {
		BString alertText = "Save changes to ";
		alertText << ProjectManager::Name();
		alertText << "?";

		BAlert* alert = new BAlert("Warning!", alertText.String(),
			"Cancel", "Don't save", "Save",
			B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
			B_WARNING_ALERT);

		alert->SetShortcut(0, B_ESCAPE);
		int32 button_index = alert->Go();

		if (button_index == 2) {
			BMessenger msg(this);
			// TODO add Builder-like methods to build commands.
			BMessage* command = CommandBuilder(FABER_SAVE_PROJECT);
			command->AddBool("faber:quit", true);
			msg.SendMessage(command);
			return false;
		} else if (button_index == 0)
			return false;
	}

	be_app->PostMessage(B_QUIT_REQUESTED);
	return true;
}
// Receive message function
void AIMNetManager::ReceiveMessage( SNAC_Object& snac ) {

	short i = 10;
	unsigned short temp, temp2;
	unsigned int languageValue;
	bool autoRespond = false;
	BMessage* incomingMsg = new BMessage(BEAIM_INCOMING_IM);
	DataContainer msg;
	
	// Grab the other person's info
	DecodeBuddyStuff( snac.data, i, incomingMsg );

	// This will be either 0x0002 or 0x0004 (autorespond mode?)
	temp = (unsigned short)GetWord( snac.data, i );
	i += 2;
	if( temp == 0x0004 ) {
		temp = (unsigned short)GetWord( snac.data, i );		// 0x0000
		temp = (unsigned short)GetWord( snac.data, i+2 );	// 0x0002
		autoRespond = true;
		i += 4;
	}

	if( autoRespond )
		printf( "AutoResponded IM...\n" );
	incomingMsg->AddBool( "autorespond", autoRespond );

	// Reality check
	if( temp != 0x0002 )
		printf( "RECV_MESSAGE ERROR: temp should be 0x0002, not 0x%X!\n", temp );
	
	// Get the message length (with 0x0D tacked on), and fixed value 0x0501
	temp = (unsigned short)GetWord( snac.data, i );
	temp = (unsigned short)GetWord( snac.data, i+2 );
	i += 4;
	
	// Another reality check
	if( temp != 0x0501 )
		printf( "RECV_MESSAGE ERROR: temp should be 0x0501, not 0x%X!\n", temp );
	
	// Grab the mysterious language value
	temp = (unsigned short)GetWord( snac.data, i );
	temp2 = (unsigned short)GetWord( snac.data, temp + i + 8 );
	languageValue = (temp2 << 16) + (unsigned short)GetWord( snac.data, temp + i + 6 );
	incomingMsg->AddInt32( "languagevalue", (int32)languageValue );
	i += 2;	
	
	printf( "Mysterious Language value: 0x%X\n", (unsigned)languageValue );
	
	// Get the message itself
	msg = snac.data.getrange( temp + i + 8 );
	msg << char(0);
	incomingMsg->AddString( "message", (char*)msg.c_ptr() );
	
	printf( "actual message: %s\n", msg.c_ptr() );
	
	// Send the message off its final resting place... the great bit-bucket in the sky
	incomingMsg->AddInt32( "wtype", (int32)USER_MESSAGE_TYPE );
	PostAppMessage( incomingMsg );
}
Exemple #27
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);
	}
}
Exemple #28
0
void
ShutdownProcess::_PrepareShutdownMessage(BMessage& message) const
{
	message.what = B_QUIT_REQUESTED;
	message.AddBool("_shutdown_", true);

	BMessage::Private(message).SetReply(BMessenger(fQuitRequestReplyHandler));
}
Exemple #29
0
void
Settings::_SetDefaults()
{
	fMessage.AddRect("file_types_frame", BRect(80.0f, 80.0f, 600.0f, 480.0f));
	fMessage.AddRect("app_types_frame", BRect(100.0f, 100.0f, 540.0f, 480.0f));
	fMessage.AddBool("show_icons", true);
	fMessage.AddBool("show_rule", false);
}
Exemple #30
0
void
AGMSBayesianSpamFilterConfig::ShowSpamServerConfigurationWindow () {
	status_t    errorCode = B_OK;
	BMessage    maximizeCommand;
	BMessenger	messengerToServer;
	BMessage    replyMessage;

	// Make sure the server is running.
	if (!be_roster->IsRunning (kServerSignature)) {
			errorCode = be_roster->Launch (kServerSignature);
			if (errorCode != B_OK) {
				BPath path;
				entry_ref ref;
				directory_which places[] = {
					B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
					B_SYSTEM_BIN_DIRECTORY
				};
				for (int32 i = 0; i < 2; i++) {
					find_directory(places[i],&path);
					path.Append("spamdbm");
					if (!BEntry(path.Path()).Exists())
						continue;
					get_ref_for_path(path.Path(),&ref);
					if ((errorCode =  be_roster->Launch (&ref)) == B_OK)
						break;
				}
				if (errorCode != B_OK)
					goto ErrorExit;
			}
		}
	
	// Set up the messenger to the database server.
	messengerToServer =
		BMessenger (kServerSignature);
	if (!messengerToServer.IsValid ())
		goto ErrorExit;

	// Wait for the server to finish starting up, and for it to create the window.
	snooze (2000000);

	// Tell it to show its main window, in case it is hidden in server mode.
	maximizeCommand.what = B_SET_PROPERTY;
	maximizeCommand.AddBool ("data", false);
	maximizeCommand.AddSpecifier ("Minimize");
	maximizeCommand.AddSpecifier ("Window", (int32)0);
	errorCode = messengerToServer.SendMessage (&maximizeCommand, &replyMessage);
	if (errorCode != B_OK)
		goto ErrorExit;
	return; // Successful.

ErrorExit:
	BAlert* alert = new BAlert ("SpamFilterConfig Error", B_TRANSLATE("Sorry, "
		"unable to launch the spamdbm program to let you edit the server "
		"settings."), B_TRANSLATE("Close"));
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go ();
	return;
}