void UnarchiveColor(const char *name, BMessage *archive, rgb_color &color) { if (name == NULL) { archive->FindInt8("red", (int8*)&color.red); archive->FindInt8("green", (int8*)&color.green); archive->FindInt8("blue", (int8*)&color.blue); archive->FindInt8("alpha", (int8*)&color.alpha); } else { BMessage msg; archive->FindMessage(name, &msg); msg.FindInt8("red", (int8*)&color.red); msg.FindInt8("green", (int8*)&color.green); msg.FindInt8("blue", (int8*)&color.blue); msg.FindInt8("alpha", (int8*)&color.alpha); } }
status_t LocalDevice::_ReadLinkKeys() { int8 bt_status = BT_ERROR; BluetoothCommand<> LocalFeatures(OGF_CONTROL_BASEBAND, OCF_READ_STORED_LINK_KEY); BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; request.AddInt32("hci_id", fHid); request.AddData("raw command", B_ANY_TYPE, LocalFeatures.Data(), LocalFeatures.Size()); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_STORED_LINK_KEY)); request.AddInt16("eventExpected", HCI_EVENT_RETURN_LINK_KEYS); if (fMessenger->SendMessage(&request, &reply) == B_OK) reply.FindInt8("status", &bt_status); return bt_status; }
status_t LocalDevice::SetDeviceClass(DeviceClass deviceClass) { int8 bt_status = BT_ERROR; if (fMessenger == NULL) return bt_status; BluetoothCommand<typed_command(hci_write_dev_class)> setDeviceClass(OGF_CONTROL_BASEBAND, OCF_WRITE_CLASS_OF_DEV); setDeviceClass->dev_class[0] = deviceClass.Record() & 0xFF; setDeviceClass->dev_class[1] = (deviceClass.Record() & 0xFF00) >> 8; setDeviceClass->dev_class[2] = (deviceClass.Record() & 0xFF0000) >> 16; BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; request.AddInt32("hci_id", fHid); request.AddData("raw command", B_ANY_TYPE, setDeviceClass.Data(), setDeviceClass.Size()); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_CLASS_OF_DEV)); if (fMessenger->SendMessage(&request, &reply) == B_OK) reply.FindInt8("status", &bt_status); return bt_status; }
status_t LocalDevice::SetFriendlyName(BString& name) { int8 btStatus = BT_ERROR; if (fMessenger == NULL) return btStatus; BluetoothCommand<typed_command(hci_write_local_name)> writeName(OGF_CONTROL_BASEBAND, OCF_WRITE_LOCAL_NAME); strcpy(writeName->local_name, name.String()); BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; request.AddInt32("hci_id", fHid); request.AddData("raw command", B_ANY_TYPE, writeName.Data(), writeName.Size()); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_LOCAL_NAME)); if (fMessenger->SendMessage(&request, &reply) == B_OK) reply.FindInt8("status", &btStatus); return btStatus; }
status_t LocalDevice::SetDiscoverable(int mode) { if (fMessenger == NULL) return B_ERROR; BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; size_t size; int8 bt_status = BT_ERROR; request.AddInt32("hci_id", fHid); void* command = buildWriteScan(mode, &size); if (command == NULL) { return B_NO_MEMORY; } request.AddData("raw command", B_ANY_TYPE, command, size); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE)); if (fMessenger->SendMessage(&request, &reply) == B_OK) { if (reply.FindInt8("status", &bt_status ) == B_OK ) { return bt_status; } } return B_ERROR; }
int LocalDevice::GetDiscoverable() { if (fMessenger == NULL) return -1; size_t size; void* command = buildReadScan(&size); if (command == NULL) return -1; BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); request.AddInt32("hci_id", fHid); request.AddData("raw command", B_ANY_TYPE, command, size); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE)); int8 discoverable; BMessage reply; if (fMessenger->SendMessage(&request, &reply) == B_OK && reply.FindInt8("scan_enable", &discoverable) == B_OK) return discoverable; return -1; }
LocalDevice::LocalDevice(hci_id hid) : BluetoothDevice(), fHid(hid) { fMessenger = _RetrieveBluetoothMessenger(); _ReadBufferSize(); _ReadLocalFeatures(); _ReadLocalVersion(); _ReadTimeouts(); _ReadLinkKeys(); // Uncomment this if you want your device to have a nicer default name // BString name("HaikuBluetooth"); // SetFriendlyName(name); uint32 value; // HARDCODE -> move this to addons if (GetProperty("manufacturer", &value) == B_OK && value == 15) { // Uncomment this out if your Broadcom dongle is not working properly // Reset(); // Perform a reset to Broadcom buggyland // Uncomment this out if your Broadcom dongle has a null bdaddr //#define BT_WRITE_BDADDR_FOR_BCM2035 #ifdef BT_WRITE_BDADDR_FOR_BCM2035 #warning Writting broadcom bdaddr @ init. // try write bdaddr to a bcm2035 -> will be moved to an addon int8 bt_status = BT_ERROR; BluetoothCommand<typed_command(hci_write_bcm2035_bdaddr)> writeAddress(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR); BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; writeAddress->bdaddr.b[0] = 0x3C; writeAddress->bdaddr.b[1] = 0x19; writeAddress->bdaddr.b[2] = 0x30; writeAddress->bdaddr.b[3] = 0xC9; writeAddress->bdaddr.b[4] = 0x03; writeAddress->bdaddr.b[5] = 0x00; request.AddInt32("hci_id", fHid); request.AddData("raw command", B_ANY_TYPE, writeAddress.Data(), writeAddress.Size()); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_VENDOR_CMD, OCF_WRITE_BCM2035_BDADDR)); if (fMessenger->SendMessage(&request, &reply) == B_OK) reply.FindInt8("status", &bt_status); #endif } }
//------------------------------------------------------------------------------ void TMessageEasyFindTest::MessageEasyFindTest1() { BRect r(0, 0, -1, -1); BPoint p(0, 0); BMessage msg; CPPUNIT_ASSERT(msg.FindRect("data") == r); CPPUNIT_ASSERT(msg.FindPoint("data") == p); CPPUNIT_ASSERT(msg.FindString("data") == NULL); CPPUNIT_ASSERT(msg.FindInt8("data") == 0); CPPUNIT_ASSERT(msg.FindInt16("data") == 0); CPPUNIT_ASSERT(msg.FindInt32("data") == 0); CPPUNIT_ASSERT(msg.FindInt64("data") == 0); CPPUNIT_ASSERT(msg.FindBool("data") == false); CPPUNIT_ASSERT(msg.FindFloat("data") == 0); CPPUNIT_ASSERT(msg.FindDouble("data") == 0); }
void FolderShaper::ReadSettings() { status_t status; BMessage settings; status = settings.Unflatten(m_settings_file); if (status != B_OK) ErrorMessage("Unflatten()", status); BPoint loc; if (settings.FindPoint("winloc",&loc) == B_OK) m_winloc = loc; bool a; int8 b; if (settings.FindBool("do_move", &a) == B_OK) m_do_move = a; if (settings.FindInt8("do_open", &b) == B_OK) m_do_open = b; if (settings.FindBool("do_clobber", &a) == B_OK) m_do_clobber = a; if (settings.FindBool("do_keep_position", &a) == B_OK) m_do_keep_position = a; if (settings.FindBool("do_clean_up", &a) == B_OK) m_do_clean_up = a; }
status_t LocalDevice::Reset() { int8 bt_status = BT_ERROR; BluetoothCommand<> Reset(OGF_CONTROL_BASEBAND, OCF_RESET); BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; request.AddInt32("hci_id", fHid); request.AddData("raw command", B_ANY_TYPE, Reset.Data(), Reset.Size()); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_RESET)); if (fMessenger->SendMessage(&request, &reply) == B_OK) reply.FindInt8("status", &bt_status); return bt_status; }
status_t LocalDevice::_ReadLocalFeatures() { int8 bt_status = BT_ERROR; BluetoothCommand<> LocalFeatures(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_FEATURES); BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; request.AddInt32("hci_id", fHid); request.AddData("raw command", B_ANY_TYPE, LocalFeatures.Data(), LocalFeatures.Size()); request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_FEATURES)); if (fMessenger->SendMessage(&request, &reply) == B_OK) reply.FindInt8("status", &bt_status); return bt_status; }
void TTracker::ReadyToRun() { gStatusWindow = new BStatusWindow(); InitMimeTypes(); InstallDefaultTemplates(); InstallIndices(); HideVarDir(); fTrashWatcher = new BTrashWatcher(); fTrashWatcher->Run(); fClipboardRefsWatcher = new BClipboardRefsWatcher(); fClipboardRefsWatcher->Run(); fAutoMounter = new AutoMounter(); fAutoMounter->Run(); fTaskLoop = new StandAloneTaskLoop(true); bool openDisksWindow = false; // open desktop window BContainerWindow *deskWindow = NULL; BVolume bootVol; BVolumeRoster().GetBootVolume(&bootVol); BDirectory deskDir; if (FSGetDeskDir(&deskDir, bootVol.Device()) == B_OK) { // create desktop BEntry entry; deskDir.GetEntry(&entry); Model *model = new Model(&entry); if (model->InitCheck() == B_OK) { AutoLock<WindowList> lock(&fWindowList); deskWindow = new BDeskWindow(&fWindowList); AutoLock<BWindow> windowLock(deskWindow); deskWindow->CreatePoseView(model); deskWindow->Init(); } else delete model; // open previously open windows attr_info attrInfo; if (!BootedInSafeMode() && deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) == B_OK) { char *buffer = (char *)malloc((size_t)attrInfo.size); BMessage message; if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size) == attrInfo.size && message.Unflatten(buffer) == B_OK) { node_ref nodeRef; deskDir.GetNodeRef(&nodeRef); int32 stateMessageCounter = 0; const char *path; for (int32 outer = 0;message.FindString("paths", outer, &path) == B_OK;outer++) { int8 flags = 0; for (int32 inner = 0;message.FindInt8(path, inner, &flags) == B_OK;inner++) { BEntry entry(path, true); if (entry.InitCheck() == B_OK) { Model *model = new Model(&entry); if (model->InitCheck() == B_OK && model->IsContainer()) { BMessage state; bool restoreStateFromMessage = false; if ((flags & kOpenWindowHasState) != 0 && message.FindMessage("window state", stateMessageCounter++, &state) == B_OK) restoreStateFromMessage = true; if (restoreStateFromMessage) OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U), false, &state); else OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U)); } else delete model; } } } if (message.HasBool("open_disks_window")) openDisksWindow = true; } free(buffer); } } // create model for root of everything if (deskWindow) { BEntry entry("/"); Model model(&entry); if (model.InitCheck() == B_OK) { if (TrackerSettings().ShowDisksIcon()) { // add the root icon to desktop window BMessage message; message.what = B_NODE_MONITOR; message.AddInt32("opcode", B_ENTRY_CREATED); message.AddInt32("device", model.NodeRef()->device); message.AddInt64("node", model.NodeRef()->node); message.AddInt64("directory", model.EntryRef()->directory); message.AddString("name", model.EntryRef()->name); deskWindow->PostMessage(&message, deskWindow->PoseView()); } if (openDisksWindow) OpenContainerWindow(new Model(model), 0, kOpen, kRestoreWorkspace); } } // kick off building the mime type list for find panels, etc. fMimeTypeList = new MimeTypeList(); if (!BootedInSafeMode()) // kick of transient query killer DeleteTransientQueriesTask::StartUpTransientQueryCleaner(); }
status_t DesktopSettingsPrivate::_Load() { // TODO: add support for old app_server_settings file as well BPath basePath; status_t status = _GetPath(basePath); if (status < B_OK) return status; // read workspaces settings BPath path(basePath); path.Append("workspaces"); BFile file; status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { int32 columns; int32 rows; if (settings.FindInt32("columns", &columns) == B_OK && settings.FindInt32("rows", &rows) == B_OK) { _ValidateWorkspacesLayout(columns, rows); fWorkspacesColumns = columns; fWorkspacesRows = rows; } int32 i = 0; while (i < kMaxWorkspaces && settings.FindMessage("workspace", i, &fWorkspaceMessages[i]) == B_OK) { i++; } } } // read font settings path = basePath; path.Append("fonts"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK && gFontManager->Lock()) { const char* family; const char* style; float size; if (settings.FindString("plain family", &family) == B_OK && settings.FindString("plain style", &style) == B_OK && settings.FindFloat("plain size", &size) == B_OK) { FontStyle* fontStyle = gFontManager->GetStyle(family, style); fPlainFont.SetStyle(fontStyle); fPlainFont.SetSize(size); } if (settings.FindString("bold family", &family) == B_OK && settings.FindString("bold style", &style) == B_OK && settings.FindFloat("bold size", &size) == B_OK) { FontStyle* fontStyle = gFontManager->GetStyle(family, style); fBoldFont.SetStyle(fontStyle); fBoldFont.SetSize(size); } if (settings.FindString("fixed family", &family) == B_OK && settings.FindString("fixed style", &style) == B_OK && settings.FindFloat("fixed size", &size) == B_OK) { FontStyle* fontStyle = gFontManager->GetStyle(family, style); if (fontStyle != NULL && fontStyle->IsFixedWidth()) fFixedFont.SetStyle(fontStyle); fFixedFont.SetSize(size); } int32 hinting; if (settings.FindInt32("hinting", &hinting) == B_OK) gDefaultHintingMode = hinting; gFontManager->Unlock(); } } // read mouse settings path = basePath; path.Append("mouse"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { int32 mode; if (settings.FindInt32("mode", &mode) == B_OK) fMouseMode = (mode_mouse)mode; int32 focusFollowsMouseMode; if (settings.FindInt32("focus follows mouse mode", &focusFollowsMouseMode) == B_OK) { fFocusFollowsMouseMode = (mode_focus_follows_mouse)focusFollowsMouseMode; } bool acceptFirstClick; if (settings.FindBool("accept first click", &acceptFirstClick) == B_OK) { fAcceptFirstClick = acceptFirstClick; } } } // read appearance settings path = basePath; path.Append("appearance"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { // menus float fontSize; if (settings.FindFloat("font size", &fontSize) == B_OK) fMenuInfo.font_size = fontSize; const char* fontFamily; if (settings.FindString("font family", &fontFamily) == B_OK) strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH); const char* fontStyle; if (settings.FindString("font style", &fontStyle) == B_OK) strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH); rgb_color bgColor; if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK) fMenuInfo.background_color = bgColor; int32 separator; if (settings.FindInt32("separator", &separator) == B_OK) fMenuInfo.separator = separator; bool clickToOpen; if (settings.FindBool("click to open", &clickToOpen) == B_OK) fMenuInfo.click_to_open = clickToOpen; bool triggersAlwaysShown; if (settings.FindBool("triggers always shown", &triggersAlwaysShown) == B_OK) { fMenuInfo.triggers_always_shown = triggersAlwaysShown; } // scrollbars bool proportional; if (settings.FindBool("proportional", &proportional) == B_OK) fScrollBarInfo.proportional = proportional; bool doubleArrows; if (settings.FindBool("double arrows", &doubleArrows) == B_OK) fScrollBarInfo.double_arrows = doubleArrows; int32 knob; if (settings.FindInt32("knob", &knob) == B_OK) fScrollBarInfo.knob = knob; int32 minKnobSize; if (settings.FindInt32("min knob size", &minKnobSize) == B_OK) fScrollBarInfo.min_knob_size = minKnobSize; // subpixel font rendering bool subpix; if (settings.FindBool("subpixel antialiasing", &subpix) == B_OK) gSubpixelAntialiasing = subpix; int8 averageWeight; if (settings.FindInt8("subpixel average weight", &averageWeight) == B_OK) { gSubpixelAverageWeight = averageWeight; } bool subpixelOrdering; if (settings.FindBool("subpixel ordering", &subpixelOrdering) == B_OK) { gSubpixelOrderingRGB = subpixelOrdering; } // colors for (int32 i = 0; i < kNumColors; i++) { char colorName[12]; snprintf(colorName, sizeof(colorName), "color%" B_PRId32, (int32)index_to_color_which(i)); settings.FindInt32(colorName, (int32*)&fShared.colors[i]); } } } // read dragger settings path = basePath; path.Append("dragger"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { if (settings.FindBool("show", &fShowAllDraggers) != B_OK) fShowAllDraggers = true; } } return B_OK; }
FindWindow::FindWindow(BRect _rect, BMessage& previous, BMessenger& target, const BMessage* settings) : BWindow(_rect, B_TRANSLATE("Find"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE), fTarget(target) { BView* view = new BView(Bounds(), "main", B_FOLLOW_ALL, 0); view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); AddChild(view); int8 mode = kAsciiMode; if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL) settings->FindInt8("find_mode", &mode); // add the top widgets fMenu = new BPopUpMenu("mode"); BMessage* message; BMenuItem* item; fMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Text"), message = new BMessage(kMsgFindMode))); message->AddInt8("mode", kAsciiMode); if (mode == kAsciiMode) item->SetMarked(true); fMenu->AddItem(item = new BMenuItem(B_TRANSLATE_COMMENT("Hexadecimal", "A menu item, as short as possible, noun is recommended if it is " "shorter than adjective."), message = new BMessage(kMsgFindMode))); message->AddInt8("mode", kHexMode); if (mode == kHexMode) item->SetMarked(true); BRect rect = Bounds().InsetByCopy(5, 5); BMenuField* menuField = new BMenuField(rect, B_EMPTY_STRING, B_TRANSLATE("Mode:"), fMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP); menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 8); menuField->ResizeToPreferred(); view->AddChild(menuField); // add the bottom widgets BButton* button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Find"), new BMessage(kMsgStartFind), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->MakeDefault(true); button->ResizeToPreferred(); button->MoveTo(rect.right - button->Bounds().Width(), rect.bottom - button->Bounds().Height()); view->AddChild(button); fCaseCheckBox = new BCheckBox(rect, B_EMPTY_STRING, B_TRANSLATE("Case sensitive"), NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); fCaseCheckBox->ResizeToPreferred(); fCaseCheckBox->MoveTo(5, button->Frame().top); bool caseSensitive; if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) { if (settings == NULL || settings->FindBool("case_sensitive", &caseSensitive) != B_OK) caseSensitive = true; } fCaseCheckBox->SetValue(caseSensitive); view->AddChild(fCaseCheckBox); // and now those inbetween rect.top = menuField->Frame().bottom + 5; rect.bottom = fCaseCheckBox->Frame().top - 8; rect.InsetBy(2, 2); fTextView = new FindTextView(rect, B_EMPTY_STRING, rect.OffsetToCopy(B_ORIGIN).InsetByCopy(3, 3), B_FOLLOW_ALL); fTextView->SetWordWrap(true); fTextView->SetMode((find_mode)mode); fTextView->SetData(previous); BScrollView* scrollView = new BScrollView("scroller", fTextView, B_FOLLOW_ALL, B_WILL_DRAW, false, false); view->AddChild(scrollView); ResizeTo(290, button->Frame().Height() * 3 + 30); SetSizeLimits(fCaseCheckBox->Bounds().Width() + button->Bounds().Width() + 20, 32768, button->Frame().Height() * 3 + 10, 32768); }
status_t TMailApp::LoadSettings() { BMailSettings accountSettings; fDefaultAccount = accountSettings.DefaultOutboundAccount(); BPath path; status_t status = GetSettingsPath(path); if (status != B_OK) return status; path.Append("BeMail Settings"); BFile file; status = file.SetTo(path.Path(), B_READ_ONLY); if (status != B_OK) return LoadOldSettings(); BMessage settings; status = settings.Unflatten(&file); if (status < B_OK || settings.what != 'BeMl') { // the current settings are corrupted, try old ones return LoadOldSettings(); } BRect rect; if (settings.FindRect("MailWindowSize", &rect) == B_OK) fMailWindowFrame = rect; int32 int32Value; // if (settings.FindInt32("ExperienceLevel", &int32Value) == B_OK) // level = int32Value; const char *fontFamily; if (settings.FindString("FontFamily", &fontFamily) == B_OK) { const char *fontStyle; if (settings.FindString("FontStyle", &fontStyle) == B_OK) { float size; if (settings.FindFloat("FontSize", &size) == B_OK) { if (size >= 7) fContentFont.SetSize(size); if (fontFamily[0] && fontStyle[0]) { fContentFont.SetFamilyAndStyle(fontFamily[0] ? fontFamily : NULL, fontStyle[0] ? fontStyle : NULL); } } } } if (settings.FindRect("SignatureWindowSize", &rect) == B_OK) fSignatureWindowFrame = rect; bool boolValue; if (settings.FindBool("WordWrapMode", &boolValue) == B_OK) fWrapMode = boolValue; BPoint point; if (settings.FindPoint("PreferencesWindowLocation", &point) == B_OK) fPrefsWindowPos = point; if (settings.FindBool("AutoMarkRead", &boolValue) == B_OK) fAutoMarkRead = boolValue; const char *string; if (settings.FindString("SignatureText", &string) == B_OK) { free(fSignature); fSignature = strdup(string); } if (settings.FindInt32("CharacterSet", &int32Value) == B_OK) fMailCharacterSet = int32Value; if (fMailCharacterSet != B_MAIL_UTF8_CONVERSION && fMailCharacterSet != B_MAIL_US_ASCII_CONVERSION && BCharacterSetRoster::GetCharacterSetByConversionID(fMailCharacterSet) == NULL) fMailCharacterSet = B_MS_WINDOWS_CONVERSION; if (settings.FindString("FindString", &string) == B_OK) FindWindow::SetFindString(string); int8 int8Value; if (settings.FindInt8("ShowButtonBar", &int8Value) == B_OK) fShowToolBar = int8Value; if (settings.FindInt32("UseAccountFrom", &int32Value) == B_OK) fUseAccountFrom = int32Value; if (fUseAccountFrom < ACCOUNT_USE_DEFAULT || fUseAccountFrom > ACCOUNT_FROM_MAIL) fUseAccountFrom = ACCOUNT_USE_DEFAULT; if (settings.FindBool("ColoredQuotes", &boolValue) == B_OK) fColoredQuotes = boolValue; if (settings.FindString("ReplyPreamble", &string) == B_OK) { free(fReplyPreamble); fReplyPreamble = strdup(string); } if (settings.FindBool("AttachAttributes", &boolValue) == B_OK) fAttachAttributes = boolValue; if (settings.FindBool("WarnAboutUnencodableCharacters", &boolValue) == B_OK) fWarnAboutUnencodableCharacters = boolValue; if (settings.FindBool("StartWithSpellCheck", &boolValue) == B_OK) fStartWithSpellCheckOn = boolValue; return B_OK; }
void TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter) { size_t filterLength = 0; if (pathFilter != NULL) filterLength = strlen(pathFilter); BDirectory deskDir; attr_info attrInfo; if (FSGetDeskDir(&deskDir) != B_OK || deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) != B_OK) return; char *buffer = (char *)malloc((size_t)attrInfo.size); BMessage message; if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size) != attrInfo.size || message.Unflatten(buffer) != B_OK) { free(buffer); return; } free(buffer); node_ref nodeRef; deskDir.GetNodeRef(&nodeRef); int32 stateMessageCounter = 0; const char *path; for (int32 i = 0; message.FindString("paths", i, &path) == B_OK; i++) { if (strncmp(path, pathFilter, filterLength)) continue; BEntry entry(path, true); if (entry.InitCheck() != B_OK) continue; int8 flags = 0; for (int32 j = 0; message.FindInt8(path, j, &flags) == B_OK; j++) { Model *model = new Model(&entry); if (model->InitCheck() == B_OK && model->IsContainer()) { BMessage state; bool restoreStateFromMessage = false; if ((flags & kOpenWindowHasState) != 0 && message.FindMessage("window state", stateMessageCounter++, &state) == B_OK) restoreStateFromMessage = true; if (restoreStateFromMessage) { OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U) | kRestoreDecor, false, &state); } else { OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U) | kRestoreDecor); } } else delete model; } } // Open disks window if needed if (pathFilter == NULL && TrackerSettings().ShowDisksIcon() && message.HasBool("open_disks_window")) { BEntry entry("/"); Model* model = new Model(&entry); if (model->InitCheck() == B_OK) OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace); else delete model; } }