/* returns true if == */ bool CompareMessages(BMessage &a, BMessage &b) { char *name; type_code code; int32 count, index, i; const void *adata, *bdata; ssize_t asize, bsize; if (a.what != b.what) return false; for (index = 0; a.GetInfo(B_ANY_TYPE, index, GET_INFO_NAME_PTR(&name), &code, &count) == B_OK; i++) { for (i = 0; i < count; i++) { if (a.FindData(name, code, i, &adata, &asize) != B_OK) return false; if (b.FindData(name, code, i, &bdata, &bsize) != B_OK) return false; if (asize != bsize) return false; if (memcmp(adata, bdata, asize)) return false; } } /* cross compare */ for (index = 0; b.GetInfo(B_ANY_TYPE, index, GET_INFO_NAME_PTR(&name), &code, &count) == B_OK; i++) { type_code acode; int32 acount; if (a.GetInfo(name, &acode, &acount) < B_OK) return false; if (code != acode) return false; if (count != acount) return false; } return true; }
void _get_key_map(key_map **map, char **key_buffer, ssize_t *key_buffer_size) { BMessage command(IS_GET_KEY_MAP); BMessage reply; ssize_t map_count, key_count; const void *map_array = 0, *key_array = 0; if (key_buffer_size == NULL) key_buffer_size = &key_count; _control_input_server_(&command, &reply); if (reply.FindData("keymap", B_ANY_TYPE, &map_array, &map_count) != B_OK) { *map = 0; *key_buffer = 0; return; } if (reply.FindData("key_buffer", B_ANY_TYPE, &key_array, key_buffer_size) != B_OK) { *map = 0; *key_buffer = 0; return; } *map = (key_map *)malloc(map_count); memcpy(*map, map_array, map_count); *key_buffer = (char *)malloc(*key_buffer_size); memcpy(*key_buffer, key_array, *key_buffer_size); }
/** We share one global list for all BMediaFormats in the team - since the * format data can change at any time, we have to update the list to ensure * that we are working on the latest data set. The list is always sorted by * description. The formats lock has to be held when you call this function. */ static status_t update_media_formats() { if (!sLock.IsLocked()) return B_NOT_ALLOWED; // We want the add-ons to register themselves with the format manager, so // the list is up to date. AddOnManager::GetInstance()->RegisterAddOns(); BMessage reply; FormatManager::GetInstance()->GetFormats(sLastFormatsUpdate, reply); // do we need an update at all? bool needUpdate; if (reply.FindBool("need_update", &needUpdate) < B_OK) return B_ERROR; if (!needUpdate) return B_OK; // update timestamp and check if the message is okay type_code code; int32 count; if (reply.FindInt64("timestamp", &sLastFormatsUpdate) < B_OK || reply.GetInfo("formats", &code, &count) < B_OK) return B_ERROR; // overwrite already existing formats int32 index = 0; for (; index < sFormats.CountItems() && index < count; index++) { meta_format* item = sFormats.ItemAt(index); const meta_format* newItem; ssize_t size; if (reply.FindData("formats", MEDIA_META_FORMAT_TYPE, index, (const void**)&newItem, &size) == B_OK) *item = *newItem; } // allocate additional formats for (; index < count; index++) { const meta_format* newItem; ssize_t size; if (reply.FindData("formats", MEDIA_META_FORMAT_TYPE, index, (const void**)&newItem, &size) == B_OK) sFormats.AddItem(new meta_format(*newItem)); } // remove no longer used formats while (count < sFormats.CountItems()) delete sFormats.RemoveItemAt(count); return B_OK; }
/*! \brief Retrieves a cursor from the set. \param which System cursor specifier defined in CursorSet.h \param cursor Bitmap** to receive a newly-allocated BBitmap containing the appropriate data \param hotspot The recipient of the hotspot for the cursor \return - \c B_OK: Success - \c B_BAD_VALUE: a NULL parameter was passed - \c B_NAME_NOT_FOUND: The specified cursor does not exist in this set - \c B_ERROR: An internal error occurred BBitmaps created by this function are the responsibility of the caller. */ status_t CursorSet::FindCursor(BCursorID which, BBitmap **cursor, BPoint *hotspot) { if (!cursor || !hotspot) return B_BAD_VALUE; BMessage msg; if (FindMessage(_CursorWhichToString(which), &msg) != B_OK) return B_NAME_NOT_FOUND; const void *buffer; const char *tempstr; int32 bufferLength; BBitmap *bmp; BPoint hotpt; if (msg.FindString("class", &tempstr) != B_OK) return B_ERROR; if (msg.FindPoint("hotspot", &hotpt) != B_OK) return B_ERROR; if (strcmp(tempstr, "cursor") == 0) { bmp = new BBitmap(msg.FindRect("_frame"), (color_space)msg.FindInt32("_cspace"), true); msg.FindData("_data", B_RAW_TYPE, (const void **)&buffer, (ssize_t *)&bufferLength); memcpy(bmp->Bits(), buffer, bufferLength); *cursor = bmp; *hotspot = hotpt; return B_OK; } return B_ERROR; }
void App::_StoreSettings(const BMessage& settings) { // Take what is in settings and replace data under the same name in // fSettings, leaving anything in fSettings that is not contained in // settings. int32 i = 0; char* name; type_code type; int32 count; while (settings.GetInfo(B_ANY_TYPE, i++, &name, &type, &count) == B_OK) { fSettings.RemoveName(name); for (int32 j = 0; j < count; j++) { const void* data; ssize_t size; if (settings.FindData(name, type, j, &data, &size) != B_OK) break; fSettings.AddData(name, type, data, size); } } save_settings(&fSettings, "main_settings", "HaikuDepot"); }
// SDL version doesn't work due to cpu speed SDL_bool clipboard_paste_sdl( struct machine *oric ) { const char *text; int32 textLen; BMessage *clip = NULL; SDL_Event ev; ev.key.keysym.scancode = 0; ev.key.keysym.mod = (SDLMod)0; ev.key.keysym.sym = (SDLKey)0; if (be_clipboard->Lock()) { clip = be_clipboard->Data(); if (clip && clip->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &textLen) == B_OK) { for (int i = 0; i < textLen; i++) { fprintf(stderr, "pushing key '%c'\n", text[i]); ev.key.keysym.sym = (SDLKey)text[i]; ev.key.keysym.unicode = text[i]; ev.type = SDL_KEYDOWN; ev.key.state = SDL_PRESSED; SDL_PushEvent(&ev); ev.type = SDL_KEYUP; ev.key.state = SDL_RELEASED; SDL_PushEvent(&ev); } } be_clipboard->Unlock(); } return SDL_TRUE; }
bool Model::IsSuperHandler() const { ASSERT(CanHandleDrops() == kNeedToCheckType); BFile file(EntryRef(), O_RDONLY); BAppFileInfo handlerInfo(&file); BMessage message; if (handlerInfo.GetSupportedTypes(&message) != B_OK) return false; for (int32 index = 0; ; index++) { const char *mimeSignature; int32 bufferLength; if (message.FindData("types", 'CSTR', index, (const void **)&mimeSignature, &bufferLength)) return false; if (IsSuperHandlerSignature(mimeSignature)) return true; } return false; }
bdaddr_t LocalDevice::GetBluetoothAddress() { if (fMessenger == NULL) return bdaddrUtils::LocalAddress(); size_t size; void* command = buildReadBdAddr(&size); if (command == NULL) return bdaddrUtils::LocalAddress(); const bdaddr_t* bdaddr; BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); BMessage reply; ssize_t ssize; 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_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR)); if (fMessenger->SendMessage(&request, &reply) == B_OK && reply.FindData("bdaddr", B_ANY_TYPE, 0, (const void**)&bdaddr, &ssize) == B_OK) return *bdaddr; return bdaddrUtils::LocalAddress(); }
void BYdpMainWindow::NewClipData(void) { const char *text; int32 textLen; BString result; static BString lastResult; BMessage *clip = (BMessage *)NULL; int i; char c; if (!config->clipboardTracking) return; if (be_clipboard->Lock()) { if ((clip = be_clipboard->Data())) clip->FindData("text/plain", B_MIME_TYPE,(const void **)&text, &textLen); be_clipboard->Unlock(); result = ""; for (i=0;i<textLen;i++) { c = text[i]; if ((c!=' ')&&(c!='.')&&(c!=',')&&(c!='\t')&&(c!='\'')&&(c!='"')) result += c; } if (lastResult.Compare(result) != 0) { lastResult = result; wordInput->SetText(result.String()); if (config->setFocusOnSelf) this->Activate(); } // const char *tmp = result.String(); // printf("got:%s:clip:%i,%i,%i\n",tmp,tmp[0],tmp[1],tmp[2]); } }
void FindTextView::Paste(BClipboard* clipboard) { if (clipboard == NULL) return; AutoLocker<BClipboard> _(clipboard); BMessage* clip = clipboard->Data(); if (clip == NULL) return; const uint8* data; ssize_t dataSize; if (clip->FindData(B_FILE_MIME_TYPE, B_MIME_TYPE, (const void**)&data, &dataSize) == B_OK) { if (fMode == kHexMode) { char* hex; size_t hexSize; if (_GetHexFromData(data, dataSize, &hex, &hexSize) < B_OK) return; Insert(hex, hexSize); free(hex); } else Insert((char*)data, dataSize); return; } BTextView::Paste(clipboard); }
/*! \brief Retrieves a cursor from the set. \param which System cursor specifier defined in CursorSet.h \param cursor ServerCursor** to receive a newly-allocated ServerCursor containing the appropriate data \return - \c B_OK: Success - \c B_BAD_VALUE: a NULL parameter was passed - \c B_NAME_NOT_FOUND: The specified cursor does not exist in this set - \c B_ERROR: An internal error occurred BBitmaps created by this function are the responsibility of the caller. */ status_t CursorSet::FindCursor(BCursorID which, ServerCursor **_cursor) const { BMessage msg; if (FindMessage(_CursorWhichToString(which), &msg) != B_OK) return B_NAME_NOT_FOUND; const char *className; BPoint hotspot; if (msg.FindString("class", &className) != B_OK) return B_ERROR; if (msg.FindPoint("hotspot", &hotspot) != B_OK) return B_ERROR; if (strcmp(className, "cursor") == 0) { ServerCursor *cursor = new ServerCursor(msg.FindRect("_frame"), (color_space)msg.FindInt32("_cspace"), 0, hotspot); const void *buffer; int32 bufferLength; msg.FindData("_data",B_RAW_TYPE, (const void **)&buffer, (ssize_t *)&bufferLength); memcpy(cursor->Bits(), buffer, bufferLength); *_cursor = cursor; return B_OK; } return B_ERROR; }
int32 Model::SupportsMimeType(const char *type, const BObjectList<BString> *list, bool exactReason) const { ASSERT((type == 0) != (list == 0)); // pass in one or the other int32 result = kDoesNotSupportType; BFile file(EntryRef(), O_RDONLY); BAppFileInfo handlerInfo(&file); BMessage message; if (handlerInfo.GetSupportedTypes(&message) != B_OK) return kDoesNotSupportType; for (int32 index = 0; ; index++) { // check if this model lists the type of dropped document as supported const char *mimeSignature; int32 bufferLength; if (message.FindData("types", 'CSTR', index, (const void **)&mimeSignature, &bufferLength)) return result; if (IsSuperHandlerSignature(mimeSignature)) { if (!exactReason) return kSuperhandlerModel; if (result == kDoesNotSupportType) result = kSuperhandlerModel; } int32 match; if (type) { BString typeString(type); match = MatchMimeTypeString(&typeString, mimeSignature); } else match = WhileEachListItem(const_cast<BObjectList<BString> *>(list), MatchMimeTypeString, mimeSignature); // const_cast shouldnt be here, have to have it until MW cleans up if (match == kMatch) // supports the actual type, it can't get any better return kModelSupportsType; else if (match == kMatchSupertype) { if (!exactReason) return kModelSupportsSupertype; // we already know this model supports the file as a supertype, // now find out if it matches the type result = kModelSupportsSupertype; } } return result; }
void RemoveAttribute::DoRemoveAttribute(PDocument *doc, BMessage *node, BMessage *valueContainer,BMessage *undoMessage) { node->PrintToStream(); valueContainer->PrintToStream(); undoMessage->PrintToStream(); status_t err = B_OK; int32 i = 0; int32 j = 0; BList *subGroupList = new BList(); BMessage *subGroup = NULL; BMessage *tmpSubGroup = new BMessage(); BList *changed = doc->GetChangedNodes(); //do char *name = NULL; char *tmpName = NULL; char *subGroupName = NULL; type_code type = B_ANY_TYPE; void* oldValue = NULL; int32 index = 0; int32 count = 0; ssize_t size = 0; err = valueContainer->FindString("name",(const char**)&name); err = err | valueContainer->FindInt32("index",(int32 *)&index); subGroup = node; subGroupList->AddItem(subGroup); while (valueContainer->FindString("subgroup",i,(const char**)&subGroupName) == B_OK) { subGroup->FindMessage(subGroupName,tmpSubGroup); subGroupList->AddItem(tmpSubGroup); subGroup = tmpSubGroup; tmpSubGroup = new BMessage(); i++; } delete tmpSubGroup; #ifdef B_ZETA_VERSION_1_0_0 while ((subGroup->GetInfo(B_ANY_TYPE, j, (const char **)&tmpName, &type, &count) == B_OK) && ((count-1) != index)) #else while((subGroup->GetInfo(B_ANY_TYPE, j, (char**)&tmpName, &type, &count) == B_OK) && ((count-1) != index)) #endif j++; subGroup->FindData(name,type,count-1,(const void **)&oldValue,&size); undoMessage->AddData("deletedAttribut",type,oldValue,size); undoMessage->AddString("deletedName",name); undoMessage->AddInt32("deletedType",type); subGroup->RemoveData(name,index); for (i=subGroupList->CountItems()-1;i>0;i--) { tmpSubGroup = (BMessage *)subGroupList->ItemAt(i-1); valueContainer->FindString("subgroup",i-1,(const char**)&subGroupName); if (tmpSubGroup) tmpSubGroup->ReplaceMessage(subGroupName,(BMessage *)subGroupList->ItemAt(i)); delete subGroupList->RemoveItem(i); } changed->AddItem(node); }
status_t OutputView::GetCodecsForFamily(const media_format_family &family, const int32 &width, const int32 &height, BMenu *codecs, media_format &initialFormat) { SetInitialFormat(width, height, Settings().ClipDepth(), 10, initialFormat); // find the full media_file_format corresponding to // the given format family (e.g. AVI) media_file_format fileFormat; if (!GetMediaFileFormat(family, fileFormat)) return B_ERROR; BString currentCodec; BMenuItem *marked = codecs->FindMarked(); if (marked != NULL) currentCodec = marked->Label(); // suspend updates while we're rebuilding this menu in order to // reduce window flicker and other annoyances Window()->BeginViewTransaction(); codecs->RemoveItems(0, codecs->CountItems(), true); int32 cookie = 0; media_codec_info codec; media_format dummyFormat; while (get_next_encoder(&cookie, &fileFormat, &initialFormat, &dummyFormat, &codec) == B_OK) { BMenuItem *item = CreateCodecMenuItem(codec); if (item != NULL) codecs->AddItem(item); if (codec.pretty_name == currentCodec) item->SetMarked(true); } if (codecs->FindMarked() == NULL) { BMenuItem *item = codecs->ItemAt(0); if (item != NULL) item->SetMarked(true); } Window()->EndViewTransaction(); marked = codecs->FindMarked(); BMessage *message = marked->Message(); media_codec_info *info; ssize_t size; if (message->FindData(kCodecData, B_SIMPLE_DATA, (const void **)&info, &size) == B_OK) fController->SetMediaCodecInfo(*info); return B_OK; }
status_t ScreenConfigurations::Restore(const BMessage& settings) { fConfigurations.MakeEmpty(); BMessage stored; for (int32 i = 0; settings.FindMessage("screen", i, &stored) == B_OK; i++) { const display_mode* mode; ssize_t size; int32 id; if (stored.FindInt32("id", &id) != B_OK || stored.FindData("mode", B_RAW_TYPE, (const void**)&mode, &size) != B_OK || size != sizeof(display_mode)) continue; screen_configuration* configuration = new(std::nothrow) screen_configuration; if (configuration == NULL) return B_NO_MEMORY; configuration->id = id; configuration->is_current = false; const char* vendor; const char* name; uint32 productID; const char* serial; int32 week, year; if (stored.FindString("vendor", &vendor) == B_OK && stored.FindString("name", &name) == B_OK && stored.FindInt32("product id", (int32*)&productID) == B_OK && stored.FindString("serial", &serial) == B_OK && stored.FindInt32("produced week", &week) == B_OK && stored.FindInt32("produced year", &year) == B_OK) { // create monitor info strlcpy(configuration->info.vendor, vendor, sizeof(configuration->info.vendor)); strlcpy(configuration->info.name, name, sizeof(configuration->info.name)); strlcpy(configuration->info.serial_number, serial, sizeof(configuration->info.serial_number)); configuration->info.product_id = productID; configuration->info.produced.week = week; configuration->info.produced.year = year; configuration->has_info = true; } else configuration->has_info = false; stored.FindRect("frame", &configuration->frame); memcpy(&configuration->mode, mode, sizeof(display_mode)); fConfigurations.AddItem(configuration); } return B_OK; }
void FileTypesWindow::_MoveUpAttributeIndex(int32 index) { BMessage attributes; if (fCurrentType.GetAttrInfo(&attributes) != B_OK) return; // Iterate over all known attribute fields, and for each field, // iterate over all fields of the same name and build a copy // of the attributes message with the field at the given index swapped // with the previous field. BMessage resortedAttributes; for (uint32 i = 0; i < sizeof(kAttributeNames) / sizeof(kAttributeNames[0]); i++) { type_code type; int32 count; bool isFixedSize; if (attributes.GetInfo(kAttributeNames[i], &type, &count, &isFixedSize) != B_OK) { // Apparently the message does not contain this name, // so just ignore this attribute name. // NOTE: This shows that the attribute description is // too fragile. It would have been better to pack each // attribute description into a separate BMessage. continue; } for (int32 j = 0; j < count; j++) { const void* data; ssize_t size; int32 originalIndex; if (j == index - 1) originalIndex = j + 1; else if (j == index) originalIndex = j - 1; else originalIndex = j; attributes.FindData(kAttributeNames[i], type, originalIndex, &data, &size); if (j == 0) { resortedAttributes.AddData(kAttributeNames[i], type, data, size, isFixedSize); } else { resortedAttributes.AddData(kAttributeNames[i], type, data, size); } } } // Setting it directly on the type will trigger an update of the GUI as // well. TODO: FileTypes is heavily descructive, it should use an // Undo/Redo stack. fCurrentType.SetAttrInfo(&resortedAttributes); }
static void populate_colors(BMenu* dest, const BMessage& src, const BMessage& names, const BMessage* initial) { type_code type; int32 n; ssize_t size; rgb_color *col; const char *name; src.GetInfo ("color", &type, &n); for (int32 j = 0; j < n; j++) { names.FindString ("color", j, &name); if (src.FindData ("color", B_RGB_COLOR_TYPE, j, (const void **)(&col), &size) == B_OK) { // See if this field already exists in the menu. const int32 k = dest->CountItems(); int32 i; bool found = false; for (i=0; i<k; i++) { BMenuItem* it = dest->ItemAt(i); const char* field; if (it && it->Message() && it->Message()->FindString("field", &field) == B_OK && strcmp(field, name) == 0) { ColorMenuItem* ci = dynamic_cast<ColorMenuItem*>(it); if (ci) ci->SetColor(*col); found = true; break; } } if (found) continue; // This color doesn't currently exist; add it in. BMessage* msg = new BMessage(CMD_CHOOSE_UI_COLOR); msg->AddString("field", name); msg->AddInt32("index", j); const char* label = name; // Alphabetical order. for (i=0; i<n; i++) { BMenuItem* it = dest->ItemAt(i); if (it && strcmp(it->Label(), label) > 0) break; } rgb_color *init_col; if (!initial || initial->FindData ("color", B_RGB_COLOR_TYPE, j, (const void **)&init_col, &size) != B_OK) *init_col = *col; ColorMenuItem* ci = new ColorMenuItem(label, msg, *col, *init_col); dest->AddItem(ci); } } }
PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText) { chosePlainText = false; AutoClipboardLocker locker(be_clipboard); if (!locker.isLocked()) return 0; BMessage* data = be_clipboard->Data(); if (!data) return 0; const char* buffer = 0; ssize_t bufferLength; if (data->FindData("text/html", B_MIME_TYPE, reinterpret_cast<const void**>(&buffer), &bufferLength) == B_OK) { RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/plain", "UTF-8", true); String html = decoder->decode(buffer, bufferLength); html += decoder->flush(); if (!html.isEmpty()) { RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "", DisallowScriptingContent); if (fragment) return fragment.release(); } } if (!allowPlainText) return 0; if (data->FindData("text/plain", B_MIME_TYPE, reinterpret_cast<const void**>(&buffer), &bufferLength) == B_OK) { BString plainText(buffer, bufferLength); chosePlainText = true; RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), plainText); if (fragment) return fragment.release(); } return 0; }
void ColorSelector::ExtractColors(BMessage* dest, const BMessage& src) { type_code type; int32 n; src.GetInfo ("color", &type, &n); for (int32 i=0; i<n; i++) { const void* data; ssize_t size; if (src.FindData("color", B_RGB_COLOR_TYPE, i, &data, &size) == B_OK && size == sizeof(rgb_color)) dest->AddData("color", B_RGB_COLOR_TYPE, data, size, true, i==0 ? n : 1); } }
std::string copy_from_clipboard(const bool) { const char* data; ssize_t size; BMessage *clip = NULL; if (be_clipboard->Lock()) { clip = be_clipboard->Data(); be_clipboard->Unlock(); } if (clip != NULL && clip->FindData("text/plain", B_MIME_TYPE, (const void**)&data, &size) == B_OK) return (const char*)data; else return ""; }
void DataView::Paste() { if (!be_clipboard->Lock()) return; const void *data; ssize_t length; BMessage *clip; if ((clip = be_clipboard->Data()) != NULL && (clip->FindData(B_FILE_MIME_TYPE, B_MIME_TYPE, &data, &length) == B_OK || clip->FindData("text/plain", B_MIME_TYPE, &data, &length) == B_OK)) { // we have valid data, but it could still be too // large to to fit in the file if (fOffset + fStart + length > fFileSize) length = fFileSize - fOffset; if (fEditor.Replace(fOffset + fStart, (const uint8 *)data, length) == B_OK) SetSelection(fStart + length, fStart + length); } else beep(); be_clipboard->Unlock(); }
void gui_paste_from_clipboard(struct gui_window *g, int x, int y) { BMessage *clip; if (be_clipboard->Lock()) { clip = be_clipboard->Data(); if (clip) { const char *text; int32 textlen; if (clip->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &textlen) >= B_OK) { browser_window_paste_text(g->bw,text,textlen,true); } } be_clipboard->Unlock(); } }
String Pasteboard::plainText(Frame* frame) { AutoClipboardLocker locker(be_clipboard); if (!locker.isLocked()) return String(); BMessage* data = be_clipboard->Data(); if (!data) return String(); const char* buffer = 0; ssize_t bufferLength; BString string; if (data->FindData("text/plain", B_MIME_TYPE, reinterpret_cast<const void**>(&buffer), &bufferLength) == B_OK) string.Append(buffer, bufferLength); return string; }
status_t get_mouse_map(mouse_map *map) { BMessage command(IS_GET_MOUSE_MAP); BMessage reply; const void *data = 0; ssize_t count; status_t err = _control_input_server_(&command, &reply); if (err == B_OK) err = reply.FindData("mousemap", B_RAW_TYPE, &data, &count); if (err != B_OK) return err; memcpy(map, data, count); return B_OK; }
SDL_bool clipboard_paste( struct machine *oric ) { const char *text; int32 textLen; BMessage *clip = NULL; if (be_clipboard->Lock()) { clip = be_clipboard->Data(); if (clip && clip->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &textLen) == B_OK) { printf("clip: tlen %ld\n", textLen); BString t(text, textLen); t.ReplaceAll('\n', '\r'); t.ReplaceAll('\t', ' '); queuekeys( (char *)t.String() ); } be_clipboard->Unlock(); } return SDL_TRUE; }
status_t FindRGBColor(BMessage &message, const char *name, int32 index, rgb_color *c) { #ifdef B_BEOS_VERSION_DANO return message.FindRGBColor(name, index, c); #else const void *data; ssize_t len; status_t err; err = message.FindData(name, B_RGB_COLOR_TYPE, index, &data, &len); if (err < B_OK) return err; if (len > (ssize_t)sizeof(*c)) return E2BIG; // Hack memcpy((void *)c, data, len); return B_OK; #endif }
status_t FindFont(BMessage &message, const char *name, int32 index, BFont *f) { #ifdef B_BEOS_VERSION_DANO return message.FindFlat(name, index, f); #else const void *data; ssize_t len; status_t err = message.FindData(name, 'FONt', index, &data, &len); #define DERR(e) { PRINT(("%s: err: %s\n", __FUNCTION__, strerror(e))); } if (err < B_OK) return err; if (len > (ssize_t)sizeof(*f)) return E2BIG; // Hack: only Dano has BFont : public BFlattenable memcpy((void *)f, data, len); return B_OK; #endif }
void FindTextView::SetData(BMessage& message) { const uint8* data; ssize_t dataSize; if (message.FindData("data", B_RAW_TYPE, (const void**)&data, &dataSize) != B_OK) return; if (fMode == kHexMode) { char* hex; size_t hexSize; if (_GetHexFromData(data, dataSize, &hex, &hexSize) < B_OK) return; SetText(hex, hexSize); free(hex); } else SetText((char*)data, dataSize); }
status_t get_key_info(key_info *info) { BMessage command(IS_GET_KEY_INFO); BMessage reply; const void *data = 0; int32 err; ssize_t count; _control_input_server_(&command, &reply); if (reply.FindInt32("status", &err) != B_OK) return B_ERROR; if (reply.FindData("key_info", B_ANY_TYPE, &data, &count) != B_OK) return B_ERROR; memcpy(info, data, count); return B_OK; }
void NetworkPrefsView::UpdateNetworkData (BMessage & msg) { // enable network controls fStartupBox->SetEnabled (true); fServerButton->SetEnabled (true); fTextView->MakeEditable (true); fLagCheckBox->SetEnabled (true); SetPrimaryServer("<N/A>"); SetAlternateCount(0); bool startup (false), lagcheck (true); if (msg.FindBool ("connectOnStartup", &startup) == B_OK) fStartupBox->SetValue ((startup) ? B_CONTROL_ON : B_CONTROL_OFF); else fStartupBox->SetValue (B_CONTROL_OFF); if (msg.FindBool ("lagCheck", &lagcheck) == B_OK) fLagCheckBox->SetValue ((lagcheck) ? B_CONTROL_ON : B_CONTROL_OFF); else fLagCheckBox->SetValue (B_CONTROL_OFF); const char *autoexec (NULL); if ((autoexec = msg.FindString ("autoexec")) != NULL) fTextView->SetText (autoexec); else fTextView->SetText (""); uint32 altCount(0); ssize_t size; const ServerData *data (NULL); for (int32 i = 0; msg.FindData("server", B_ANY_TYPE, i, reinterpret_cast<const void **>(&data), &size) == B_OK; i++) { if (data->state == 0) SetPrimaryServer(data->serverName); else if(data->state == 1) ++altCount; } SetAlternateCount(altCount); }