YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.ShareService Class Reference

The part of a confirmed file share that talks to the provider and the registry, on a worker thread: it opens the file (or copies it), registers it for the CHOSEN receivers, waits for the local HTTP server and builds the item to play. More...

Collaboration diagram for de.yaacc.share.ShareService:
Collaboration graph

Classes

interface  Addresses
 What a share allows is decided before: the addresses of the receivers are fixed at confirm. More...
 
class  Prepared
 A registered share and the item that plays it.
 

Public Member Functions

 ShareService (Context appContext, UpnpClient upnpClient)
 
Prepared prepare (PendingShare.Data data, Set< String > receiverIds)
 Worker thread only.
 
Prepared prepareFor (PendingShare.Data data, Set< String > allowedAddresses)
 Same, with the allowed receiver addresses given (resolved once at the confirm, not at every later bind: a receiver that changed its address or left the registry must not change what its share allows).
 

Static Public Member Functions

static boolean hasAddress (String ip)
 Whether there is an address a receiver could fetch from.
 
static String proxyUrl (String ip, String key)
 The URL a receiver fetches a share from: http://<ip>:<port>/proxy/<key>.
 
static int failureTextRes (boolean providerCallRefusedBusy, boolean copySlotBusy)
 The message the user gets when a shared file or link could not be taken or opened.
 

Detailed Description

The part of a confirmed file share that talks to the provider and the registry, on a worker thread: it opens the file (or copies it), registers it for the CHOSEN receivers, waits for the local HTTP server and builds the item to play.

Every failure closes the source, deletes the copy and removes the registry key before it returns null, so the caller has nothing to clean up.

Nothing here logs the URI, the name, the key or the proxy URL.

Member Function Documentation

◆ failureTextRes()

static int de.yaacc.share.ShareService.failureTextRes ( boolean providerCallRefusedBusy,
boolean copySlotBusy )
static

The message the user gets when a shared file or link could not be taken or opened.

The messages are fixed texts: nothing the provider or the file said ever reaches them. "Busy" means the app turned the share away for lack of room (the provider already has a call outstanding, too many providers are busy, or another copy is running), which the user can understand and retry later; everything else stays the generic "could not play" message.

Parameters
providerCallRefusedBusythe provider call was refused for lack of room (BoundedCall.Result#isRefusedBusy())
copySlotBusythe copy fallback was refused because another copy runs or too many stuck copies are left
Returns
the string resource of the toast

◆ hasAddress()

static boolean de.yaacc.share.ShareService.hasAddress ( String ip)
static

Whether there is an address a receiver could fetch from.

Offline the phone has none; the check comes before anything is registered so that no URL with the text "null" in it exists.

Parameters
ipthis phone's address as text, null or blank when it is not known

Referenced by de.yaacc.share.ShareService.proxyUrl().

Here is the caller graph for this function:

◆ prepare()

Prepared de.yaacc.share.ShareService.prepare ( PendingShare.Data data,
Set< String > receiverIds )

Worker thread only.

Parameters
datathe confirmed pending share
receiverIdsthe receivers the user picked; the allowed addresses come from these, not from the stored selection
Returns
the registered share and its item (counted as unclaimed until a player takes it), or null after the failure was reported to the user and everything was cleaned up

Referenced by de.yaacc.share.ShareService.prepare(), and de.yaacc.share.ShareService.prepareFor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proxyUrl()

static String de.yaacc.share.ShareService.proxyUrl ( String ip,
String key )
static

The URL a receiver fetches a share from: http://<ip>:<port>/proxy/<key>.

An IPv6 literal is put in brackets by URI; a zone id is kept.

Parameters
ipthis phone's address as text, surrounding blanks are ignored
keythe registry key
Returns
the URL, or null if there is no address, no key or the address is no valid host (never a URL with the text "null" in it); nothing is logged, the key is a secret
Here is the call graph for this function:

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