LMMS
Loading...
Searching...
No Matches
juce::ContentSharer Class Reference

#include <juce_ContentSharer.h>

Inheritance diagram for juce::ContentSharer:
juce::DeletedAtShutdown

Public Member Functions

void shareFiles (const Array< URL > &files, std::function< void(bool, const String &)> callback)
void shareText (const String &text, std::function< void(bool, const String &)> callback)
void shareImages (const Array< Image > &images, std::function< void(bool, const String &)> callback, ImageFileFormat *imageFileFormatToUse=nullptr)
void shareData (const MemoryBlock &mb, std::function< void(bool, const String &)> callback)

Private Member Functions

 ContentSharer ()
 ~ContentSharer ()
void deleteTemporaryFiles ()
void sharingFinished (bool, const String &)

Private Attributes

Array< FiletemporaryFiles
std::function< void(bool, String)> callback

Additional Inherited Members

Static Public Member Functions inherited from juce::DeletedAtShutdown
static void deleteAll ()
Protected Member Functions inherited from juce::DeletedAtShutdown
 DeletedAtShutdown ()
virtual ~DeletedAtShutdown ()

Detailed Description

A singleton class responsible for sharing content between apps and devices.

You can share text, images, files or an arbitrary data block.

@tags{GUI}

Constructor & Destructor Documentation

◆ ContentSharer()

juce::ContentSharer::ContentSharer ( )
private

◆ ~ContentSharer()

juce::ContentSharer::~ContentSharer ( )
private

Member Function Documentation

◆ deleteTemporaryFiles()

void juce::ContentSharer::deleteTemporaryFiles ( )
private

◆ shareData()

void juce::ContentSharer::shareData ( const MemoryBlock & mb,
std::function< void(bool, const String &)> callback )

A convenience function to share arbitrary data. The data will be written to a temporary file and then that file will be shared. If you have your data stored on disk already, call shareFiles() instead.

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.

◆ shareFiles()

void juce::ContentSharer::shareFiles ( const Array< URL > & files,
std::function< void(bool, const String &)> callback )

Shares the given files. Each URL should be either a full file path or it should point to a resource within the application bundle. For resources on iOS it should be something like "content/image.png" if you want to specify a file from application bundle located in "content" directory. On Android you should specify only a filename, without an extension.

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.

◆ shareImages()

void juce::ContentSharer::shareImages ( const Array< Image > & images,
std::function< void(bool, const String &)> callback,
ImageFileFormat * imageFileFormatToUse = nullptr )

A convenience function to share an image. This is useful when you have images loaded in memory. The images will be written to temporary files first, so if you have the images in question stored on disk already call shareFiles() instead. By default, images will be saved to PNG files, but you can supply a custom ImageFileFormat to override this. The custom file format will be owned and deleted by the sharer. e.g.

Graphics g (myImage);
g.setColour (Colours::green);
g.fillEllipse (20, 20, 300, 200);
Array<Image> images;
images.add (myImage);
ContentSharer::getInstance()->shareImages (images, myCallback);
Definition juce_Array.h:56
void add(const ElementType &newElement)
Definition juce_Array.h:418
Definition juce_GraphicsContext.h:45
int g
Definition inflate.c:1573
const Colour green
Definition juce_Colours.h:94

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.

◆ shareText()

void juce::ContentSharer::shareText ( const String & text,
std::function< void(bool, const String &)> callback )

Shares the given text.

Upon completion you will receive a callback with a sharing result. Note: Sadly on Android the returned success flag may be wrong as there is no standard way the sharing targets report if the sharing operation succeeded. Also, the optional error message is always empty on Android.

◆ sharingFinished()

void juce::ContentSharer::sharingFinished ( bool succeeded,
const String & errorDescription )
private

Member Data Documentation

◆ callback

std::function<void (bool, String)> juce::ContentSharer::callback
private

◆ temporaryFiles

Array<File> juce::ContentSharer::temporaryFiles
private

The documentation for this class was generated from the following files: