Ejemplo n.º 1
0
void URLView::CreatePerson( const BString *fullName, const BString *title ) {
	// Read the file defined by the path and the title.
	BFile *file = new BFile( fullName->String(), B_WRITE_ONLY );
		
	// Set the file's MIME type to be a person.
	BNodeInfo *nodeInfo = new BNodeInfo( file );
	nodeInfo->SetType( "application/x-person" );
	delete nodeInfo;
	delete file;

	// Add all the attributes, both those inherrent to person files and any
	// the developer may have defined using AddAttribute().
	DIR *d;
	int fd;
	d = fs_open_attr_dir( fullName->String() );
	if( d ) {
		fd = open( fullName->String(), O_WRONLY );
		fs_write_attr( fd, "META:name", B_STRING_TYPE, 0, title->String(), title->Length() + 1 );
		BString email = GetImportantURL();
		fs_write_attr( fd, "META:email", B_STRING_TYPE, 0, email.String(), email.Length() + 1 );
		WriteAttributes( fd );
		close( fd );
		fs_close_attr_dir( d ); 
	}
}
Ejemplo n.º 2
0
void
TSigTextView::MessageReceived(BMessage *msg)
{
	char		type[B_FILE_NAME_LENGTH];
	char		*text;
	int32		end;
	int32		start;
	BFile		file;
	BNodeInfo	*node;
	entry_ref	ref;
	off_t		size;

	switch (msg->what) {
		case B_SIMPLE_DATA:
			if (msg->HasRef("refs")) {
				msg->FindRef("refs", &ref);
				file.SetTo(&ref, O_RDONLY);
				if (file.InitCheck() == B_NO_ERROR) {
					node = new BNodeInfo(&file);
					node->GetType(type);
					delete node;
					file.GetSize(&size);
					if ((!strncasecmp(type, "text/", 5)) && (size)) {
						text = (char *)malloc(size);
						file.Read(text, size);
						Delete();
						GetSelection(&start, &end);
						Insert(text, size);
						Select(start, start + size);
						free(text);
					}
				}
			}
			else
				BTextView::MessageReceived(msg);
			break;

		case M_SELECT:
			if (IsSelectable())
				Select(0, TextLength());
			break;

		default:
			BTextView::MessageReceived(msg);
	}
}
Ejemplo n.º 3
0
CMimeItem::CMimeItem(const char *mime)
{
	fMime.SetTo(mime);
	
	memset(fIcon, B_TRANSPARENT_8_BIT, 256);
	memset(fIconSelected, B_TRANSPARENT_8_BIT, 256);

	BBitmap bm(BRect(0, 0, 15, 15), B_COLOR_8_BIT);
	if (fMime.GetIcon(&bm, B_MINI_ICON) != B_OK)
	{
		try
		{
			char p[PATH_MAX];
			if (find_directory(B_SYSTEM_TEMP_DIRECTORY, 0, true, p, PATH_MAX) == B_OK)
			{
				BDirectory tmpdir;
				FailOSErr(tmpdir.SetTo(p));

				time_t t;
				time(&t);
				sprintf(p, "tmp.pe_is_looking_for_a_mime_icon:%ld", t);

				BFile f;
				FailOSErr(tmpdir.CreateFile(p, &f));

				BNodeInfo ni;
				FailOSErr(ni.SetTo(&f));
				FailOSErr(ni.SetType(mime));
				FailOSErr(ni.GetTrackerIcon(&bm, B_MINI_ICON));
			}
		}
		catch (HErr& e) { }
	}

	for (int i = 0; i < 16; i++)
	{
		unsigned char *ba = (unsigned char *)((unsigned char *)bm.Bits() + bm.BytesPerRow() * i);
		memcpy(fIcon + i * 16, ba, 16);
		
		for (int j = 0; j < 16; j++)
			if (ba[j] < 255)
				fIconSelected[j + i * 16] = gSelectedMap[ba[j]];
	}
} /* CMimeItem::CMimeItem */
Ejemplo n.º 4
0
void
IconView::Update()
{
	delete fIcon;
	fIcon = NULL;

	Invalidate();
		// this will actually trigger a redraw *after* we updated the icon below

	BBitmap* icon = NULL;

	if (fHasRef) {
		BFile file(&fRef, B_READ_ONLY);
		if (file.InitCheck() != B_OK)
			return;

		BNodeInfo info;
		if (info.SetTo(&file) != B_OK)
			return;

		icon = Icon::AllocateBitmap(fIconSize);
		if (icon != NULL && info.GetTrackerIcon(icon,
				(icon_size)fIconSize) != B_OK) {
			delete icon;
			return;
		}
	} else if (fHasType) {
		icon = Icon::AllocateBitmap(fIconSize);
		if (icon != NULL && icon_for_type(fType, *icon, (icon_size)fIconSize,
				&fSource) != B_OK) {
			delete icon;
			return;
		}
	} else if (fIconData) {
		icon = Icon::AllocateBitmap(fIconSize);
		if (fIconData->GetIcon(icon) != B_OK) {
			delete icon;
			icon = NULL;
		}
	}

	fIcon = icon;
}
Ejemplo n.º 5
0
void
SpringLoadedFolderAddUniqueTypeToList(entry_ref* ref,
	BObjectList<BString>* typeslist)
{
	if (!ref || !typeslist)
		return;

	//	get the mime type for the current ref
	BNodeInfo nodeinfo;
	BNode node(ref);
	if (node.InitCheck() != B_OK)
		return;

	nodeinfo.SetTo(&node);

	char mimestr[B_MIME_TYPE_LENGTH];
	//	add it to the list
	if (nodeinfo.GetType(mimestr) == B_OK && strlen(mimestr) > 0) {
		//	if this is a symlink, add symlink to the list (below)
		//	resolve the symlink, add the resolved type
		//	to the list
		if (strcmp(B_LINK_MIMETYPE, mimestr) == 0) {
			BEntry entry(ref, true);
			if (entry.InitCheck() == B_OK) {
				entry_ref resolvedRef;
				if (entry.GetRef(&resolvedRef) == B_OK)
					SpringLoadedFolderAddUniqueTypeToList(&resolvedRef, typeslist);
			}
		}
		//	scan the current list, don't add dups
		bool unique = true;
		int32 count = typeslist->CountItems();
		for (int32 index = 0 ; index < count ; index++) {
			if (typeslist->ItemAt(index)->Compare(mimestr) == 0) {
				unique = false;
				break;
			}
		}

		if (unique)
			typeslist->AddItem(new BString(mimestr));
	}
}
Ejemplo n.º 6
0
void PProjectWindow::OpenItem()
{
	PEntryItem *gi;
	gi = dynamic_cast<PEntryItem*>(fList->ItemAt(fList->CurrentSelection()));
	if (gi)
	{
		try
		{
			BNode node;
			FailOSErr(node.SetTo(&gi->Ref()));
			BNodeInfo info;
			FailOSErr(info.SetTo(&node));

			char mime[B_MIME_TYPE_LENGTH];

			CProjectFile* subProject
				= dynamic_cast<CProjectFile*>(gi->ModelItem());
			if (subProject) {
				if (!subProject->HasBeenParsed()) {
					subProject->Read();
					if (subProject->HasBeenParsed()) {
						list<CProjectItem*>::const_iterator iter;
						for( iter = subProject->begin();
							  iter != subProject->end(); ++iter) {
							AddItemsToList( *iter, gi);
						}
					}
				}
			} else if (info.GetType(mime) || strncmp(mime, "text/", 5))
				OpenInTracker(gi->Ref());
			else
				gApp->OpenWindow(gi->Ref());
		}
		catch (HErr& e)
		{
			e.DoError();
			gApp->OpenWindow(gi->Ref());
		}
	}
} /* PProjectWindow::OpenItem */
Ejemplo n.º 7
0
void URLView::CreateBookmark( const BString *fullName, const BString *title ) {
	// Read the file defined by the path and the title.
	BFile *file = new BFile( fullName->String(), B_WRITE_ONLY );

	// Set the file's MIME type to be a bookmark.
	BNodeInfo *nodeInfo = new BNodeInfo( file );
	nodeInfo->SetType( "application/x-vnd.Be-bookmark" );
	delete nodeInfo;
	delete file;

	// Add all the attributes, both those inherrent to bookmarks and any
	// the developer may have defined using AddAttribute().
	DIR *d;
	int fd;
	d = fs_open_attr_dir( fullName->String() );
	if( d ) {
		fd = open( fullName->String(), O_WRONLY );
		fs_write_attr( fd, "META:title", B_STRING_TYPE, 0, title->String(), title->Length() + 1 );
		fs_write_attr( fd, "META:url", B_STRING_TYPE, 0, url->String(), url->Length() + 1 );
		WriteAttributes( fd );
		close( fd );
		fs_close_attr_dir( d ); 
	}
}
Ejemplo n.º 8
0
void
TStatusWindow::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case STATUS:
			break;

		case OK:
		{
			if (!_Exists(fStatus->Text())) {
				int32 index = 0;
				uint32 loop;
				status_t result;
				BDirectory dir;
				BEntry entry;
				BFile file;
				BNodeInfo* node;
				BPath path;

				find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
				dir.SetTo(path.Path());
				if (dir.FindEntry("Mail", &entry) == B_NO_ERROR)
					dir.SetTo(&entry);
				else
					dir.CreateDirectory("Mail", &dir);
				if (dir.InitCheck() != B_NO_ERROR)
					goto err_exit;
				if (dir.FindEntry("status", &entry) == B_NO_ERROR)
					dir.SetTo(&entry);
				else
					dir.CreateDirectory("status", &dir);
				if (dir.InitCheck() == B_NO_ERROR) {
					char name[B_FILE_NAME_LENGTH];
					char newName[B_FILE_NAME_LENGTH];

					sprintf(name, "%s", fStatus->Text());
					if (strlen(name) > B_FILE_NAME_LENGTH - 10)
						name[B_FILE_NAME_LENGTH - 10] = 0;
					for (loop = 0; loop < strlen(name); loop++) {
						if (name[loop] == '/')
							name[loop] = '\\';
					}
					strcpy(newName, name);
					while (1) {
						if ((result = dir.CreateFile(newName, &file, true)) == B_NO_ERROR)
							break;
						if (result != EEXIST)
							goto err_exit;
						sprintf(newName, "%s_%" B_PRId32, name, index++);
					}
					dir.FindEntry(newName, &entry);
					node = new BNodeInfo(&file);
					node->SetType("text/plain");
					delete node;
					file.Write(fStatus->Text(), strlen(fStatus->Text()) + 1);
					file.SetSize(file.Position());
					file.WriteAttr(INDEX_STATUS, B_STRING_TYPE, 0, fStatus->Text(),
						strlen(fStatus->Text()) + 1);
				}
			}
		err_exit:
			{
				BMessage close(M_CLOSE_CUSTOM);
				close.AddString("status", fStatus->Text());
				fTarget.SendMessage(&close);
				// will fall through
			}
		}
		case CANCEL:
			Quit();
			break;
	}
}
Ejemplo n.º 9
0
void
TSignatureWindow::Save()
{
	char			name[B_FILE_NAME_LENGTH];
	int32			index = 0;
	status_t		result;
	BDirectory		dir;
	BEntry			entry;
	BNodeInfo		*node;
	BPath			path;

	if (!fFile) {
		find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
		dir.SetTo(path.Path());
		
		if (dir.FindEntry("bemail", &entry) == B_NO_ERROR)
			dir.SetTo(&entry);
		else
			dir.CreateDirectory("bemail", &dir);
			
		if (dir.InitCheck() != B_NO_ERROR)
			goto err_exit;

		if (dir.FindEntry("signatures", &entry) == B_NO_ERROR)
			dir.SetTo(&entry);
		else
			dir.CreateDirectory("signatures", &dir);
			
		if (dir.InitCheck() != B_NO_ERROR)
			goto err_exit;

		fFile = new BFile();
		while(true) {
			sprintf(name, "signature_%ld", index++);
			if ((result = dir.CreateFile(name, fFile, true)) == B_NO_ERROR)
				break;
			if (result != EEXIST)
				goto err_exit;
		}
		dir.FindEntry(name, &fEntry);
		node = new BNodeInfo(fFile);
		node->SetType("text/plain");
		delete node;
	}

	fSigView->fTextView->fDirty = false;
	fFile->Seek(0, 0);
	fFile->Write(fSigView->fTextView->Text(),
				 fSigView->fTextView->TextLength());
	fFile->SetSize(fFile->Position());
	fFile->WriteAttr(INDEX_SIGNATURE, B_STRING_TYPE, 0, fSigView->fName->Text(),
					 strlen(fSigView->fName->Text()) + 1);
	return;

err_exit:
	beep();
	(new BAlert("", MDR_DIALECT_CHOICE (
		"An error occurred trying to save this signature.",
		"署名を保存しようとした時にエラーが発生しました。"),
		MDR_DIALECT_CHOICE ("Sorry","了解")))->Go();
}
Ejemplo n.º 10
0
// ----------------------------------------------------------------------- RHTML_text_view - MessageReceived -
void RHTMLtextview::MessageReceived(BMessage *msg)
{
 switch (msg->what)
  {
   case 'PPOP':
   {
	Window()->Lock();
	if (pushmenu)
    {
     int32 c,d;
     GetSelection(&c,&d);
     pushmenu=false;
     if (mode==1) fTagMenu->Start(ConvertToScreen(PointAt(c)),c,R_TAG_MENU,tags);
     if (mode==2) fTagMenu->Start(ConvertToScreen(PointAt(c)),c,R_PARAM_MENU,tags,BString(buf1));
     if (mode==3) fTagMenu->Start(ConvertToScreen(PointAt(c)),c,R_VALUE_MENU,tags,BString(buf1),BString(buf2));

    }
	Window()->Unlock();
	fTimer->EndTimer();
   }
   break;
   case 'TIMR':
   {
	Window()->Lock();
	UpdateParamMenu();
    fTarget->fNumView->UpdateNum();
	Window()->Unlock();
	fUpdateTimer->EndTimer();
   }
   break;
   case 'PTFC':
   {
    int32 c,d;
    BString oldstring;
    msg->FindInt32("sel1",&c);
    msg->FindInt32("sel2",&d);
    msg->FindString("oldstring",&oldstring);
    BString *newtext = new BString(Text());
    fFileTypes->SetFontAndColor(&oldstring, newtext,0,c,d);
    delete newtext;
   }
   break;
   case 'CWFC':
   {
    int32 c,d;
    GetSelection(&c,&d);
    BString *newtext = new BString(Text());
    fFileTypes->SetFontAndColor(newtext, newtext, 0, c);
    delete newtext;
   }
   break;
   case 'VALE':
   {
    msg->FindString("tag",&buf1);
    msg->FindString("param",&buf2);
    pushmenu=true;
    mode=3;
    fTimer->StartTimer(fOptions->ReakcioIdoTM);
   }
   break;
   case 'UPPM':
   {
    if (fUpdateTimer->IsActive())
     fUpdateTimer->ResetTimer();
    else
     fUpdateTimer->StartTimer(fOptions->ReakcioIdo);
   }
   break;
   default:
   {
    if (msg->WasDropped())
    {
     int32		num;
     uint32		type;
     char*		name;
     BPoint		aPoint;
     BPoint		point;
     entry_ref ref;
     status_t err;
     
     msg->FindPoint("_drop_point_", &aPoint);

     point = aPoint;
     this->ConvertFromScreen(&point);

     const int32 offset = OffsetAt(point);
    
     if (msg->GetInfo(B_REF_TYPE, 0, &name, &type, &num) == B_NO_ERROR && num >= 1)
     {
		// - File
      for(int32 i = 0; i < num; i++)
      {
       BEntry entry;
       BPath path;
       BFile fFile;
       BNodeInfo fNodeInfo;
       entry_ref ref;
       char fFileType[B_MIME_TYPE_LENGTH];
       if(msg->FindRef("refs", i, &ref) != B_NO_ERROR)
       {
        continue;
       }
       if ((err=entry.SetTo(&ref)) == B_OK)
       {
        entry.GetPath(&path);
       } 
       fFile.SetTo(&ref,B_READ_ONLY);
       fNodeInfo.SetTo(&fFile);
       fNodeInfo.GetType(fFileType);
       DropFile(path.Path(), fFileType, offset);
      }
     }
    } else
    {
     BTextView::MessageReceived(msg);
    }
   }
   break;
  }
}
Ejemplo n.º 11
0
void
PersonWindow::MessageReceived(BMessage* msg)
{
	char			str[256];
	BDirectory		directory;
	BEntry			entry;
	BFile			file;
	BNodeInfo		*node;

	switch (msg->what) {
		case M_SAVE:
			if (!fRef) {
				SaveAs();
				break;
			}
			// supposed to fall through
		case M_REVERT:
		case M_SELECT:
			fView->MessageReceived(msg);
			break;

		case M_SAVE_AS:
			SaveAs();
			break;

		case B_UNDO: // fall through
		case B_CUT:
		case B_COPY:
		case B_PASTE:
		{
			BView* view = CurrentFocus();
			if (view != NULL)
				view->MessageReceived(msg);
			break;
		}

		case B_SAVE_REQUESTED:
		{
			entry_ref dir;
			if (msg->FindRef("directory", &dir) == B_OK) {
				const char* name = NULL;
				msg->FindString("name", &name);
				directory.SetTo(&dir);
				if (directory.InitCheck() == B_NO_ERROR) {
					directory.CreateFile(name, &file);
					if (file.InitCheck() == B_NO_ERROR) {
						node = new BNodeInfo(&file);
						node->SetType("application/x-person");
						delete node;

						directory.FindEntry(name, &entry);
						entry.GetRef(&dir);
						_SetToRef(new entry_ref(dir));
						SetTitle(fRef->name);
						fView->CreateFile(fRef);
					}
					else {
						sprintf(str, B_TRANSLATE("Could not create %s."), name);
						BAlert* alert = new BAlert("", str, B_TRANSLATE("Sorry"));
						alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
						alert->Go();
					}
				}
			}
			break;
		}

		case B_NODE_MONITOR:
		{
			int32 opcode;
			if (msg->FindInt32("opcode", &opcode) == B_OK) {
				switch (opcode) {
					case B_ENTRY_REMOVED:
						// We lost our file. Close the window.
						PostMessage(B_QUIT_REQUESTED);
						break;

					case B_ENTRY_MOVED:
					{
						// We may have renamed our entry. Obtain relevant data
						// from message.
						BString name;
						msg->FindString("name", &name);

						int64 directory;
						msg->FindInt64("to directory", &directory);

						int32 device;
						msg->FindInt32("device", &device);

						// Update our ref.
						delete fRef;
						fRef = new entry_ref(device, directory, name.String());

						// And our window title.
						SetTitle(name);

						// If moved to Trash, close window.
						BVolume volume(device);
						BPath trash;
						find_directory(B_TRASH_DIRECTORY, &trash, false,
							&volume);
						BPath folder(fRef);
						folder.GetParent(&folder);
						if (folder == trash)
							PostMessage(B_QUIT_REQUESTED);

						break;
					}

					case B_ATTR_CHANGED:
					{
						// An attribute was updated.
						BString attr;
						if (msg->FindString("attr", &attr) == B_OK)
							fView->SetAttribute(attr.String(), true);
						break;
					}
					case B_STAT_CHANGED:
						fView->UpdatePicture(fRef);
						break;
				}
			}
			break;
		}

		default:
			BWindow::MessageReceived(msg);
	}
}
Ejemplo n.º 12
0
status_t HModuleRoster::HandleRequest( RequestPB *pb )
{
	BEntry		entry;
	BNode		node;
	BNodeInfo	info;
	char		mimeType[128], vmimeType[128];
	status_t 	status = B_OK;
	int32		parentCount = 0;
	BPath 		absPath, resourcePath( "/" );
	resourcePath.Append( pb->brURI->path );
	pb->resourcePath = &resourcePath;
	pb->mimeType = mimeType;
	
	
	// fix for "hostname//" request crash
	// wade majors <[email protected] - Mar-09-2001
    if (resourcePath.Path() == NULL)
    {
      resourcePath.SetTo("null");
      pb->resourcePath = &resourcePath;
    }
    //
	
	
	VResource	*vres = NULL;
		
	// *****
	// Look for "real" resource
	// *****
	do
	{
		// Small optimization... if not done, the path normalizer will 
		// be tickled when a resource does not exit
		if( (resourcePath.Path())[1] == 0 )
		{
			status = B_ERROR;
			break;
		}
		absPath.SetTo( pb->webDirectory->Path(), resourcePath.Path()+1 );

		if( (entry.SetTo( absPath.Path(), true ) == B_OK)&&(node.SetTo( &entry ) == B_OK)
		&&(info.SetTo( &node ) == B_OK) )
		{
			const char *resMIME;
			
			// Cheap hack for directories without a MIME type
			if(info.GetType( mimeType ) != B_OK)
				strcpy( mimeType, "application/x-vnd.Be-directory" );
				
			if( (resMIME = pb->vresources->MatchVRes( pb->brURI->path, true, &vres )) )
				strcpy( vmimeType, resMIME );
			else
				strcpy( vmimeType, mimeType );
			break;
		}
		parentCount++;
		
	}while( (status = resourcePath.GetParent( &resourcePath )) == B_OK );
	entry.Unset();
	if( node.InitCheck() )
		node.Unset();
	// *****
	// Look for Virtual Resource if no "real" resource was found.
	// *****
	
	if( (status != B_OK)||((parentCount != 0)&&(strcmp(mimeType, "application/x-vnd.Be-directory") == 0)) )
	{
		const char *resMIME;
		if( (resMIME = pb->vresources->MatchVRes( pb->brURI->path, false, &vres )) )
		{
			strcpy( vmimeType, resMIME );
			strcpy( mimeType, resMIME );
		}
		else
		{
			HTTPResponse	response;
			response.SetHTMLMessage( 404 ); // Not Found
			pb->request->SendReply( &response );
			return B_ERROR;
		}
	}
	
	// *****
	// Find handler module for resource
	// *****
	
	HModule		*module, *prefModule = NULL;
	int32		priority, highestPriority = 0;
	for( int32 i=0; (module = (HModule *)moduleList.ItemAt(i)); i++ )
	{
		if( module->CanHandleResource( vmimeType, pb->request->GetMethod(), &priority )&&
			(priority > highestPriority) )
		{
			highestPriority = priority;
			prefModule = module;
		}
	}
	
	// *****
	// Setup PB
	// *****
	pb->HandleRequest = HModuleRoster::HandleRequest;
	pb->Logprintf = log_printf;
	pb->moduleList = &moduleList;
	if( vres )
	{
		pb->authenticate = vres->Authenticate();
		pb->extras = &vres->extras;
	}
	else
		pb->extras = NULL;
	
	// *****
	// Invoke Handler Module to handle the request
	// *****
	if( highestPriority > 0 )
	{
		status = prefModule->HandleRequest( pb );
		return status;
	}
	else // No handler found... send error
	{
		HTTPResponse	response;
		response.SetHTMLMessage( 501 ); // Not Implemented
		pb->request->SendReply( &response );
		return B_ERROR;
	}
	return B_OK;
}
Ejemplo n.º 13
0
void PictureViewer::HandleCopyTarget(BMessage *e) {
  entry_ref targetRef;
   
  BBitmap *toSend;
  if (clipping == true) toSend = GetClipping();
                   else toSend = thePic;
  


  // memory or file transfer ?
  if (e->FindRef("directory",&targetRef) == B_OK)  {

      BDirectory *targetDir = new BDirectory( &targetRef );
      if (targetDir->InitCheck() == B_OK) {
         BFile *targetFile = new BFile(targetDir,e->FindString("name"),B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
         if (targetFile->InitCheck() == B_OK) {

          BBitmap *dragImage = NULL;
          BBitmapStream *strm;
          strm = new BBitmapStream(toSend);

          translator_id trans_id;
          uint32 type;

          GetTranslatorInfo(e->FindString("be:filetypes"),&trans_id,&type);
          BTranslatorRoster::Default()->Translate(trans_id,strm,NULL,targetFile,type);
          BNodeInfo *ni = new BNodeInfo(targetFile);
          ni->SetType(e->FindString("be:filetypes"));
          if (dragImage == NULL) strm->DetachBitmap(&toSend);
           else {
            strm->DetachBitmap(&dragImage);
            delete dragImage;
           }
          delete ni;
          delete strm;
         } 
        delete targetFile;
       }   
     delete targetDir;
     return;
   } 
   
  else {
     BMallocIO *data = new BMallocIO;
     BBitmapStream *imageSrc;
     imageSrc = new BBitmapStream(toSend);

     BMessage *package = new BMessage(B_MIME_DATA);
     translator_id trans_id;
     uint32 type;

     GetTranslatorInfo(e->FindString("be:types"),&trans_id,&type);
     if (BTranslatorRoster::Default()->Translate( trans_id, imageSrc, NULL, data, type ) != B_OK) return;
     package->AddData( e->FindString("be:types"),  B_MIME_DATA, data->Buffer(), data->BufferLength());
     e->SendReply(package);        

     imageSrc->DetachBitmap(&toSend);

     delete data;
     delete imageSrc;
     delete package;
  } 

 if (clipping) delete toSend;

}
Ejemplo n.º 14
0
void TQueueDialog::AddItemToDataList(BEntry *theEntry, BNodeInfo &nodeInfo)
{
	//
	//	Get name
	//

	char fileName[B_FILE_NAME_LENGTH];	
	theEntry->GetName(fileName);
	
	
	//
	//	Get Date
	//
	
	time_t	fileTime;
	struct	tm *localTime;
    char	timeStr[255];

	theEntry->GetModificationTime(&fileTime);
    localTime = localtime(&fileTime);
    strftime(timeStr, sizeof(timeStr), "%A, %B %d, %Y, %H:%M:%S %p", localTime);

	//
	//	Get Path
	//

	BPath filePath;
	theEntry->GetPath(&filePath);	

	//
	//	Get Type
	//
	
	char typeStr[B_MIME_TYPE_LENGTH];
	if ( nodeInfo.GetType(typeStr) != B_OK)
		strcpy(typeStr, "unknown");
		
	//
	//	Get Size
	//
	
	off_t fileSize;
	theEntry->GetSize(&fileSize);
	
	int32 kBytes = fileSize / 1024;
	char sizeStr[65];
	sprintf(sizeStr, "%dK", kBytes);

	
	//	Get entry_ref
	entry_ref ref;
	theEntry->GetRef(&ref);
	
	//	Set up ID3 Tag info
	ID3_tag tag;	
	tag.tag[0] 		= '\0';
	tag.songname[0] = '\0';
	tag.artist[0] 	= '\0';
	tag.album[0] 	= '\0';
	tag.year[0] 	= '\0';
	tag.comment[0] 	= '\0';
	tag.genre 		= 0;
	
	//	Add the item to the list
	TQueueListItem *item = new TQueueListItem(m_TracksListView, m_Parent, &tag, fileName);
	m_TracksListView->AddItem(item);
	
	//	Add item to master encode list
	m_Parent->ProcessList()->AddItem(theEntry);
	
	//	Update controls based on list contents
	UpdateControls();
}