TEST(demultiplex_handler, disconnect) { handler_manager_mock_ptr demuxer = std::make_shared<handler_manager_mock>(); request_handler_id id{"/", http_verb::GET, mime(mime_type::WILDCARD, mime_subtype::WILDCARD), mime(mime_type::WILDCARD, mime_subtype::WILDCARD)}; EXPECT_CALL(*demuxer, disconnect(id)).Times(1).WillOnce(Return()); demultiplex_handler d(*demuxer, id); }
Private() : pageTemplates(0), pageOpenExisting(0), pageOpenRecent(0) , templPageWidgetItem_BlankDatabase(0) , templPageWidgetItem_ImportExisting(0) , templPageWidgetItem_CreateFromTemplate(0) // , pageTemplatesID(-1) // , pageOpenExistingID(-1) // , pageOpenRecentID(-1) { result = -1; QString iconname(KexiDB::defaultFileBasedDriverIcon()); kexi_sqlite_icon = KIconLoader::global()->loadMimeTypeIcon(iconname, KIconLoader::Desktop); const char shortcutMimeTypeName[] = "application/x-kexiproject-shortcut"; KMimeType::Ptr mime(KMimeType::mimeType(shortcutMimeTypeName)); if (mime.isNull()) { KexiDBWarn << QString("'%1' mimetype not installed!").arg(shortcutMimeTypeName); iconname = QString(); } else iconname = mime->iconName(); kexi_shortcut_icon = KIconLoader::global()->loadMimeTypeIcon( iconname, KIconLoader::Desktop); prj_selector = 0; chkDoNotShow = 0; openExistingConnWidget = 0; templatesWidget = 0; templatesWidget_IconListView = 0; }
IconMenuItem::IconMenuItem(BMenu* submenu, BMessage* message, const char* iconType, icon_size which) : PositionPassingMenuItem(submenu, message), fDeviceIcon(NULL), fHeightDelta(0), fWhich(which) { BMimeType mime(iconType); fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), kDefaultIconDepth); if (mime.GetIcon(fDeviceIcon, which) != B_OK) { BMimeType super; mime.GetSupertype(&super); if (super.GetIcon(fDeviceIcon, which) != B_OK) { delete fDeviceIcon; fDeviceIcon = NULL; } } // IconMenuItem is used in synchronously invoked menus, make sure // we invoke with a timeout SetTimeout(kSynchMenuInvokeTimeout); }
GroupPropertiesView::GroupPropertiesView(BRect rect, const char *name) : BView(rect, "GroupInfoView", B_FOLLOW_ALL, B_WILL_DRAW) { newGroup = name == NULL; strcpy(group, newGroup ? "unknown" : name); getGroupDesc(group, desc, sizeof(desc)); rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR); SetViewColor(gray); BRect bmpRect(0.0, 0.0, 31.0, 31.0); icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime("application/x-vnd.Teldar-Group"); mime.GetIcon(icon, B_LARGE_ICON); BRect r(10, 52, 200, 72); editName = new BTextControl(r, "GroupName", "Name:", group, NULL); editName->SetDivider(70); editName->SetEnabled(newGroup); AddChild(editName); r.Set(10, 77, 250, 97); editDesc = new BTextControl(r, "Description", "Description:", desc, NULL); editDesc->SetDivider(70); AddChild(editDesc); r.Set(205, 320, 275, 340); BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_GROUP_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); okBtn->MakeDefault(true); AddChild(okBtn); r.Set(285, 320, 360, 340); AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_GROUP_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM)); r.Set(285, 125, 360, 145); AddChild(new BButton(r, "AddUserBtn", "Add", new BMessage(MSG_GROUP_ADD), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM)); r.Set(285, 155, 360, 175); removeBtn = new BButton(r, "RemoveBtn", "Remove", new BMessage(MSG_GROUP_REMOVE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); removeBtn->SetEnabled(false); AddChild(removeBtn); // Now add the membership list. CLVContainerView *listContView; r.Set(13, 125, 280 - B_V_SCROLL_BAR_WIDTH, 305); listView = new SmartColumnListView(r, &listContView, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST, false, false, true, false, B_FANCY_BORDER); listView->AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE | CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT)); listView->AddColumn(new CLVColumn("User", 85.0, CLV_SORT_KEYABLE, 50.0)); listView->AddColumn(new CLVColumn("Full Name", 130.0, CLV_SORT_KEYABLE)); listView->SetSelectionMessage(new BMessage(MSG_MEMBER_SELECT)); listView->SetInvocationMessage(new BMessage(MSG_LIST_DESELECT)); AddGroupMembers(listView); AddChild(listContView); }
static nsresult GetMimeExtensions(const char *mimeType, char *extensions, int extLen) { // check variables if (!mimeType || !extensions || extLen < 1) return NS_ERROR_FAILURE; extensions[0] = '\0'; // make mime object BMimeType mime(mimeType) ; if (mime.InitCheck() != B_OK) return NS_ERROR_FAILURE; // get extensions : comma separated (if multiple extensions in a mime-type) // ex) "jpg,jpeg" BString extStr(""); BMessage extMsg; mime.GetFileExtensions(&extMsg); uint32 type; int32 types_num; if (extMsg.GetInfo("extensions", &type, &types_num) != B_OK || type != B_STRING_TYPE || types_num == 0) return NS_ERROR_FAILURE; for (int i = 0 ; i < types_num ; i ++) { const char *ext; if (extMsg.FindString("extensions", i, &ext) != B_OK) { break; } if (i > 0) extStr.Append(","); extStr.Append(ext); } PL_strncpyz(extensions, extStr.String(), extLen) ; return NS_OK; }
InetHostView(BRect rect) : BView(rect, "InetHostView", B_FOLLOW_ALL, B_WILL_DRAW) { rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR); SetViewColor(gray); BRect bmpRect(0.0, 0.0, 31.0, 31.0); icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime("application/x-vnd.BeServed-inetserver"); mime.GetIcon(icon, B_LARGE_ICON); BRect r(10, 52, 310, 72); editName = new BTextControl(r, "ShareName", "Name or Address:", "", NULL); editName->SetDivider(90); AddChild(editName); r.Set(155, 97, 225, 117); BButton *okBtn = new BButton(r, "OkayBtn", "OK", new BMessage(MSG_HOST_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); okBtn->MakeDefault(true); AddChild(okBtn); r.Set(235, 97, 310, 117); AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_HOST_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM)); editName->MakeFocus(); }
void Chrome_Extractor::extract_downloads() { { SQLITE_OPEN(file) QSqlQuery query(db); QString insert_query; QSqlField name("name", QVariant::String); QSqlField source("source", QVariant::String); QSqlField mime("mime", QVariant::String); query.exec("SELECT full_path, url FROM downloads ORDER BY start_time;"); while (query.next()) { name.setValue(query.value(0)); source.setValue(query.value(1)); mime.setValue(query.value(2)); insert_query = "INSERT INTO download (name, source, mime) VALUES ("; insert_query += "'" % db.driver()->formatValue(name) % "',"; insert_query += "'" % db.driver()->formatValue(source) % "',"; insert_query += "'" % db.driver()->formatValue(mime); insert_query += "');"; send_zmq(insert_query); } query.clear(); insert_query.clear(); } SQLITE_CLOSE(file) }
MyNetHeaderView::MyNetHeaderView(BRect rect) : BView(rect, "MyNetHeaderView", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW) { rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR); SetViewColor(gray); BRect bmpRect(0.0, 0.0, 31.0, 31.0); icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime("application/x-vnd.Teldar-MyNetwork"); mime.GetIcon(icon, B_LARGE_ICON); BRect r; r.Set(15, 55, 70, 75); openBtn = new BButton(r, "OpenBtn", "Open", new BMessage(MSG_HOST_INVOKE)); openBtn->SetEnabled(false); AddChild(openBtn); r.Set(77, 55, 215, 75); hostBtn = new BButton(r, "HostBtn", "About this Computer...", new BMessage(MSG_HOST_INFO)); hostBtn->SetEnabled(false); AddChild(hostBtn); r.Set(222, 55, 288, 75); AddChild(new BButton(r, "RefreshBtn", "Refresh", new BMessage(MSG_HOST_REFRESH))); r.Set(295, 55, 390, 75); AddChild(new BButton(r, "InternetBtn", "Internet Host...", new BMessage(MSG_INET_HOSTS))); }
/*! \brief Adds the given type to the appropriate lists of installed types. If cached messages exist, the type is simply appended to the end of the current type list. */ status_t InstalledTypes::AddType(const char *type) { if (!fHaveDoneFullBuild) return B_OK; BMimeType mime(type); if (type == NULL || mime.InitCheck() != B_OK) return B_BAD_VALUE; // Find the / in the string, if one exists uint i; size_t len = strlen(type); for (i = 0; i < len; i++) { if (type[i] == '/') break; } if (i == len) { // Supertype only std::map<std::string, Supertype>::iterator i; return _AddSupertype(type, i); } // Copy the supertype char super[B_PATH_NAME_LENGTH]; strncpy(super, type, i); super[i] = 0; // Get a pointer to the subtype const char *sub = &(type[i+1]); // Add the subtype (which will add the supertype if necessary) return _AddSubtype(super, sub); }
/*! \brief Removes the given type from the appropriate installed types lists. Any corresponding cached messages are invalidated. */ status_t InstalledTypes::RemoveType(const char *type) { if (!fHaveDoneFullBuild) return B_OK; BMimeType mime(type); if (type == NULL || mime.InitCheck() != B_OK) return B_BAD_VALUE; // Find the / in the string, if one exists uint i; size_t len = strlen(type); for (i = 0; i < len; i++) { if (type[i] == '/') break; } if (i == len) { // Supertype only return _RemoveSupertype(type); } // Copy the supertype char super[B_PATH_NAME_LENGTH]; strncpy(super, type, i); super[i] = 0; // Get a pointer to the subtype const char *sub = &(type[i+1]); // Remove the subtype return _RemoveSubtype(super, sub); }
/** Re-zip an unpacked OpenRaster zip archive * * \param [in] dir Path to the directory */ void pack_directory( QDir dir ){ if( !dir.exists() ){ qWarning( "Path must be a directory!" ); return; } //Get mimetype QFile mime( dir.absolutePath() + "/mimetype" ); if( !mime.open( QIODevice::ReadOnly ) ){ qWarning( "mimetype missing" ); return; } QString mimetype = mime.readAll(); //Get stack QFile stack_file( dir.absolutePath() + "/stack.xml" ); if( !stack_file.open( QIODevice::ReadOnly ) ){ qWarning( "stack.xml missing" ); return; } QString stack = stack_file.readAll(); //Get thumbnail QList<std::pair<QString,QByteArray>> files; append_all_files( files, dir, "Thumbnails" ); //Get data files append_all_files( files, dir, "data" ); OraSaver::save( dir.dirName() + ".packed.cgcompress", mimetype, stack, files ); }
LoginView::LoginView(BRect rect, char *server, char *share) : BView(rect, "LoginView", B_FOLLOW_ALL, B_WILL_DRAW) { strcpy(resource, share); strcat(resource, " on "); strcat(resource, server); rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR); SetViewColor(gray); BRect bmpRect(0.0, 0.0, 31.0, 31.0); icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime("application/x-vnd.Teldar-FileSharing"); mime.GetIcon(icon, B_LARGE_ICON); BRect r(10, 72, 240, 92); user = new BTextControl(r, "User", "User:"******"", NULL); user->SetDivider(55); AddChild(user); r.top = 97; r.bottom = r.top + 20; password = new BTextControl(r, "Password", "Password:"******"", NULL); password->SetDivider(55); password->TextView()->HideTyping(true); AddChild(password); r.Set(LOGIN_PANEL_WIDTH - 160, LOGIN_PANEL_HEIGHT - 33, LOGIN_PANEL_WIDTH - 90, LOGIN_PANEL_HEIGHT - 13); BButton *okBtn = new BButton(r, "OkayBtn", "Login", new BMessage(MSG_LOGIN_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); okBtn->MakeDefault(true); AddChild(okBtn); r.Set(LOGIN_PANEL_WIDTH - 80, LOGIN_PANEL_HEIGHT - 33, LOGIN_PANEL_WIDTH - 10, LOGIN_PANEL_HEIGHT - 13); AddChild(new BButton(r, "CancelBtn", "Cancel", new BMessage(MSG_LOGIN_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM)); }
void mime_index_object_t::test<4>() { const S32 MULTI_CONTENT_LENGTH = 8000; const S32 MULTI_CONTENT_OFFSET = 100; const std::string MULTI_CONTENT_TYPE = std::string("multipart/mixed"); LLSD headers; headers["Content-Length"] = MULTI_CONTENT_LENGTH; headers["Content-Type"] = MULTI_CONTENT_TYPE; LLMimeIndex mime(headers, MULTI_CONTENT_OFFSET); const S32 META_CONTENT_LENGTH = 700; const S32 META_CONTENT_OFFSET = 69; const std::string META_CONTENT_TYPE = std::string( "application/llsd+xml"); headers = LLSD::emptyMap(); headers["Content-Length"] = META_CONTENT_LENGTH; headers["Content-Type"] = META_CONTENT_TYPE; LLMimeIndex meta(headers, META_CONTENT_OFFSET); mime.attachSubPart(meta); const S32 IMAGE_CONTENT_LENGTH = 6000; const S32 IMAGE_CONTENT_OFFSET = 200; const std::string IMAGE_CONTENT_TYPE = std::string("image/j2c"); headers = LLSD::emptyMap(); headers["Content-Length"] = IMAGE_CONTENT_LENGTH; headers["Content-Type"] = IMAGE_CONTENT_TYPE; LLMimeIndex image(headers, IMAGE_CONTENT_OFFSET); mime.attachSubPart(image); // check what we have ensure("is multipart", mime.isMultipart()); ensure_equals("multi offset", mime.offset(), MULTI_CONTENT_OFFSET); ensure_equals( "multi content length", mime.contentLength(), MULTI_CONTENT_LENGTH); ensure_equals("two attachments", mime.subPartCount(), 2); LLMimeIndex actual_meta = mime.subPart(0); ensure_equals( "meta type", actual_meta.contentType(), META_CONTENT_TYPE); ensure_equals( "meta offset", actual_meta.offset(), META_CONTENT_OFFSET); ensure_equals( "meta content length", actual_meta.contentLength(), META_CONTENT_LENGTH); LLMimeIndex actual_image = mime.subPart(1); ensure_equals( "image type", actual_image.contentType(), IMAGE_CONTENT_TYPE); ensure_equals( "image offset", actual_image.offset(), IMAGE_CONTENT_OFFSET); ensure_equals( "image content length", actual_image.contentLength(), IMAGE_CONTENT_LENGTH); }
bool PluginPackage::fetchInfo() { if (!load()) return false; NP_GetMIMEDescriptionFuncPtr NP_GetMIMEDescription = 0; NPP_GetValueProcPtr NPP_GetValue = 0; g_module_symbol(m_module, "NP_GetMIMEDescription", (void**)&NP_GetMIMEDescription); g_module_symbol(m_module, "NP_GetValue", (void**)&NPP_GetValue); if (!NP_GetMIMEDescription || !NPP_GetValue) return false; char* buffer = 0; NPError err = NPP_GetValue(0, NPPVpluginNameString, &buffer); if (err == NPERR_NO_ERROR) m_name = String::fromUTF8(buffer); buffer = 0; err = NPP_GetValue(0, NPPVpluginDescriptionString, &buffer); if (err == NPERR_NO_ERROR) { m_description = String::fromUTF8(buffer); determineModuleVersionFromDescription(); } const gchar* types = NP_GetMIMEDescription(); if (!types) return true; gchar** mimeDescs = g_strsplit(types, ";", -1); for (int i = 0; mimeDescs[i] && mimeDescs[i][0]; i++) { GOwnPtr<char> mime(g_utf8_strdown(mimeDescs[i], -1)); gchar** mimeData = g_strsplit(mime.get(), ":", 3); if (g_strv_length(mimeData) < 3) { g_strfreev(mimeData); continue; } String description = String::fromUTF8(mimeData[2]); gchar** extensions = g_strsplit(mimeData[1], ",", -1); Vector<String> extVector; for (int j = 0; extensions[j]; j++) extVector.append(String::fromUTF8(extensions[j])); determineQuirks(mimeData[0]); m_mimeToExtensions.add(mimeData[0], extVector); m_mimeToDescriptions.add(mimeData[0], description); g_strfreev(extensions); g_strfreev(mimeData); } g_strfreev(mimeDescs); return true; }
BString BUrl::PreferredApplication() const { BString appSignature; BMimeType mime(_UrlMimeType().String()); mime.GetPreferredApp(appSignature.LockBuffer(B_MIME_TYPE_LENGTH)); appSignature.UnlockBuffer(); return BString(appSignature); }
bool TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID, const char *shortDescription, const char *longDescription, const char *preferredAppSignature, uint32 forceMask) { // used by InitMimeTypes - checks if a metamime of a given <type> is // installed and if it has all the specified attributes; if not, the // whole mime type is installed and all attributes are set; nulls can // be passed for attributes that don't matter; returns true if anything // had to be changed BBitmap largeIcon(BRect(0, 0, 31, 31), B_CMAP8); BBitmap miniIcon(BRect(0, 0, 15, 15), B_CMAP8); char tmp[B_MIME_TYPE_LENGTH]; BMimeType mime(type); bool installed = mime.IsInstalled(); if (!installed || (bitsID >= 0 && ((forceMask & kForceLargeIcon) || mime.GetIcon(&largeIcon, B_LARGE_ICON) != B_OK)) || (bitsID >= 0 && ((forceMask & kForceMiniIcon) || mime.GetIcon(&miniIcon, B_MINI_ICON) != B_OK)) || (shortDescription && ((forceMask & kForceShortDescription) || mime.GetShortDescription(tmp) != B_OK)) || (longDescription && ((forceMask & kForceLongDescription) || mime.GetLongDescription(tmp) != B_OK)) || (preferredAppSignature && ((forceMask & kForcePreferredApp) || mime.GetPreferredApp(tmp) != B_OK))) { if (!installed) mime.Install(); if (bitsID >= 0) { if (GetTrackerResources()-> GetIconResource(bitsID, B_LARGE_ICON, &largeIcon) == B_OK) mime.SetIcon(&largeIcon, B_LARGE_ICON); if (GetTrackerResources()-> GetIconResource(bitsID, B_MINI_ICON, &miniIcon) == B_OK) mime.SetIcon(&miniIcon, B_MINI_ICON); } if (shortDescription) mime.SetShortDescription(shortDescription); if (longDescription) mime.SetLongDescription(longDescription); if (preferredAppSignature) mime.SetPreferredApp(preferredAppSignature); return true; } return false; }
ConsoleHeaderView::ConsoleHeaderView(BRect rect) : BView(rect, "ConsoleHeaderView", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW) { rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR); SetViewColor(gray); BRect bmpRect(0.0, 0.0, 31.0, 31.0); icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime("application/x-vnd.BeServed-DomainManager"); mime.GetIcon(icon, B_LARGE_ICON); }
void TMessageEdit::insertFromMimeData(const QMimeData *source) { MimeDataChecker mime( source ); QStringList files = mime.getFilesPath(); if (files.size()) { emit addAttachments(files); } else QTextEdit::insertFromMimeData(source); }
bool SafeDragObject::provides(const char *mime_type) const { QString mime(mime_type); if(mime == SafeDragObject_MimeType) return true; else if(mime == SafeDragObject_Text && m_state == Single) { return true; } return false; }
bool BUrl::HasPreferredApplication() const { BString appSignature = PreferredApplication(); BMimeType mime(appSignature.String()); if (appSignature.IFindFirst("application/") == 0 && mime.IsValid()) return true; return false; }
HostInfoView::HostInfoView(BRect rect, const char *name, uint32 ipAddr) : BView(rect, "HostInfoView", B_FOLLOW_ALL, B_WILL_DRAW) { address = ipAddr; hostInfo.cpus = 0; thread_id infoThread = spawn_thread(getHostInfo, "Get Host Info", B_NORMAL_PRIORITY, this); resume_thread(infoThread); rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR); SetViewColor(gray); BRect bmpRect(0.0, 0.0, 31.0, 31.0); icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime("application/x-vnd.BeServed-fileserver"); mime.GetIcon(icon, B_LARGE_ICON); BRect r(40, 55, 230, 120); BListView *aliasList = new BListView(r, "Aliases", B_SINGLE_SELECTION_LIST); AddChild(new BScrollView("ScrollAliases", aliasList, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true)); r.top = 145; r.bottom = 210; BListView *addressList = new BListView(r, "Addresses", B_SINGLE_SELECTION_LIST); AddChild(new BScrollView("ScrollAddresses", addressList, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true)); r.top = 275; r.bottom = 305; r.left = 38; r.right = 245; status = new BStatusBar(r, "Connections"); status->SetBarHeight(13.0); AddChild(status); ent = gethostbyaddr((char *) &ipAddr, sizeof(ipAddr), AF_INET); if (ent) { char buf[50]; int i; for (i = 0; ent->h_aliases[i] != 0; i++) aliasList->AddItem(new BStringItem(ent->h_aliases[i])); for (i = 0; ent->h_addr_list[i] != 0; i++) { sprintf(buf, "%d.%d.%d.%d", (uint8) ent->h_addr_list[i][0], (uint8) ent->h_addr_list[i][1], (uint8) ent->h_addr_list[i][2], (uint8) ent->h_addr_list[i][3]); addressList->AddItem(new BStringItem(buf)); } } }
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; }
const SerializedResource* getResource(const char* url, const char* mimeType) { KURL kURL = KURL(m_baseUrl, url); String mime(mimeType); for (size_t i = 0; i < m_resources.size(); ++i) { const SerializedResource& resource = m_resources[i]; if (resource.url == kURL && !resource.data->isEmpty() && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime))) return &resource; } return nullptr; }
Response* FakeConnection::getDocument(const std::string& uri) { TIMED_FUNC(FakeConnection_getDocument); LOG(DEBUG) << " Entering FakeConnection::getDocument"; LOG(DEBUG) << " Fetching document with URI: " << uri; std::map<std::string,IDocumentContent*>::iterator it; it = mImpl->documents.find(uri); std::string ct(""); std::string mime(""); if (mImpl->documents.end() != it) { LOG(DEBUG) << " Found document with URI: " << uri; IDocumentContent* docPtr = it->second; ct = docPtr->getContent(); mime = docPtr->getMimeType(); } //IDocumentContent& value = mImpl->documents[uri.c_str()]; //LOG(DEBUG) << " pointer value: " << value; Response* response = new Response; LOG(DEBUG) << " Setting response code"; LOG(DEBUG) << " Setting response content ptr"; //std::unique_ptr<std::string> content(new std::string(ct)); //response->setContent(std::move(content)); response->setContent(new std::string(ct)); LOG(DEBUG) << " Setting response headers"; if (0 == ct.compare("")) { // not found response->setResponseCode(ResponseCode::NOT_FOUND); response->setResponseType(ResponseType::UNKNOWN_TYPE); } else { // found HttpHeaders headers; headers.setHeader("Content-type",mime); response->setResponseHeaders(headers); response->setResponseCode(ResponseCode::OK); if (0 == mime.compare("application/json")) { response->setResponseType(ResponseType::JSON); } else if (0 == mime.compare("application/xml") ) { response->setResponseType(ResponseType::XML); } else if (0 == mime.compare("text/plain")) { response->setResponseType(ResponseType::TEXT); } else { response->setResponseType(ResponseType::BINARY); } } LOG(DEBUG) << " returning response "; return response; }
void ConfFilters::slotChange() { TQListViewItem *item = m_filters->currentItem(); if (item) { TQString mime(item->text(0)), cmd(item->text(1)); if (FilterDlg::doIt(this, &mime, &cmd)) { item->setText(0, mime); item->setText(1, cmd); } } }
QStringList DBusFileDialogManager::globPatternsForMime(const QString &mimeType) const { QMimeDatabase db; QMimeType mime(db.mimeTypeForName(mimeType)); if (mime.isValid()) { if (mime.isDefault()) { return QStringList(QStringLiteral("*")); } else { return mime.globPatterns(); } } return QStringList(); }
bool convert(const QUrl &uIn, const QString &inputFormat, const QUrl &uOut, const QString &outputFormat, bool batch) { Q_UNUSED(inputFormat); KoFilter::ConversionStatus status = KoFilter::OK; KoFilterManager *manager = new KoFilterManager(uIn.path()); manager->setBatchMode(batch); QByteArray mime(outputFormat.toLatin1()); status = manager->exportDocument(uOut.path(), mime); delete manager; return status == KoFilter::OK; }
static QStringList mime2KdeFilter( const QStringList &mimeTypes, QString *allExtensions = 0 ) { const KUrl emptyUrl; QStringList kdeFilter; QStringList allExt; foreach( const QString& mimeType, mimeTypes ) { KMimeType::Ptr mime( KMimeType::mimeType(mimeType) ); if (mime) { allExt += mime->patterns(); kdeFilter.append(mime->patterns().join(QLatin1String(" ")) + QLatin1Char('|') + mime->comment(emptyUrl)); } }
ResourceItem::ResourceItem(const char *text0, int type) : CLVEasyItem(0, false, false, 20.0) { // Here we're going to get the mini icon from a specific mime type BRect bmpRect(0.0, 0.0, 15.0, 15.0); BBitmap *icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime(type == BT_SHARED_FOLDER ? "application/x-vnd.BeServed-fileshare" : "application/x-vnd.Be.printer"); mime.GetIcon(icon, B_MINI_ICON); SetColumnContent(0, icon, 2.0); SetColumnContent(1, text0); SetColumnContent(2, type == BT_SHARED_FOLDER ? "Shared Files" : "Shared Printer"); }
MountItem(const char *text0, const char *text1, const char *text2) : CLVEasyItem(0, false, false, 20.0) { // Here we're going to get the mini icon from a specific mime type BRect bmpRect(0.0, 0.0, 15.0, 15.0); BBitmap *icon = new BBitmap(bmpRect, B_CMAP8); BMimeType mime("application/x-vnd.BeServed-fileshare"); mime.GetIcon(icon, B_MINI_ICON); SetColumnContent(0, icon, 2.0); SetColumnContent(1, text0); SetColumnContent(2, text1); SetColumnContent(3, text2); }