MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

TransferUI::Client Class Reference

class for applications using transfer-ui More...

Inheritance diagram for TransferUI::Client:
QObject

List of all members.

Public Types

enum   TransferType { TRANSFER_TYPES_UPLOAD, TRANSFER_TYPES_DOWNLOAD, TRANSFER_TYPES_SYNC }
 

This is an enumeration of the kinds of transfers supported by TransferUI.

More...

Signals

void  cancelTransfer (Transfer *transfer)
  Signal emitted when some of transfers related to this client is asked to be cancelled.
void  pauseTransfer (Transfer *transfer)
  Signal emitted when some of transfers related to this client is asked to be paused.
void  repairErrorTransfer (Transfer *transfer)
  Signal emitted when error repair is requested.
void  startTransfer (Transfer *transfer)
  Signal emitted when some of transfers related to this client is asked to be started/continued.
void  summaryReport (int failed, int active, int pending, int completed)
  Summary update of all transfers followed by transfer-ui.

Public Member Functions

bool  askForSummaryUpdate ()
  Ask TransferUI to send summary update.
  Client (QObject *parent=0)
  constructor
bool  init ()
  function to initialize the client library instance.
bool  isTUIVisible () const
  check if the transfer-ui is visible to the user
int  progressTimeDelta () const
  get function for the progress time delta
double  progressValueDelta () const
  get function for the progress value delta
Transfer registerTransfer (const QString &name, TransferType type, const QString &clientId=QString())
  Register a new transient transfer.
void  removeTransfer (const QString &tid)
  Remove the transfer whose id is passed from list of transfers.
void  setProgressTimeDelta (int delta)
  set the progress time delta.
void  setProgressValueDelta (double delta)
  set the progress value delta.
bool  showUI ()
  Ask transfer-ui to show it's UI.

Detailed Description

class for applications using transfer-ui

Author:
Jukka Tiihonen <jukka.t.tiihonen@nokia.com>

Member Enumeration Documentation

This is an enumeration of the kinds of transfers supported by TransferUI.

Enumerator:
TRANSFER_TYPES_UPLOAD 

The transfer is an upload.

TRANSFER_TYPES_DOWNLOAD 

The transfer is a download.

TRANSFER_TYPES_SYNC 

The transfer is sync'ing.


Constructor & Destructor Documentation

TransferUI::Client::Client ( QObject parent = 0  ) 

constructor

Parameters:
parent 

Member Function Documentation

bool TransferUI::Client::askForSummaryUpdate (  ) 

Ask TransferUI to send summary update.

TransferUI emits back the summaryReport for this request.

Returns:
true if request was made successfully
void TransferUI::Client::cancelTransfer ( Transfer transfer  )  [signal]

Signal emitted when some of transfers related to this client is asked to be cancelled.

Transfer will emit signal first then it will be emited by client.

Parameters:
transfer  transfer that is asked to be cancelled
    connect(client,SIGNAL(cancelTransfer(Transfer*)), this,
        SLOT(transferCancelled(Transfer*)));

void TUITestClient::transferCancelled(Transfer * transfer) {
    //User has cancelled the transfer, take neccessary action and mark transfer
    //as cancelled
    //eg uploadTransfer was cancelled by the user
    
    //eg. send the cancel notification to the service
    
    //if cancel was sucessful
    transfer->markCancelled();
    
    //else
    //% "Something went wrong in cancel process"
    QString cancelErrMsg = qtTrid("qtn_tui_cancel_errxxxx");
    transfer->markCancelFailed(cancelErrMsg);
    
    //Remove from the list of client transfers 
    client->removeTransfer(uploadTransfer->transferId());
}
See also:
Transfer::markCancelFailed Transfer::markCancelled
bool TransferUI::Client::init (  ) 

function to initialize the client library instance.

Returns:
true if initialization was success, other wise false
void TUITestClient::initTUIClient() {

    // Create libtuiclient
    client = new TransferUI::Client(this);
    
    // Establish the connection between TUIClient and transfer-ui
    if(!client->init()) {
        qDebug()<<"Cannot initialize TUIClient";//error 
        delete client;
    }
void TransferUI::Client::pauseTransfer ( Transfer transfer  )  [signal]

Signal emitted when some of transfers related to this client is asked to be paused.

Transfer will emit signal first then it will be emited by client.

Parameters:
transfer  Transfer that is asked to be paused
    connect(client,SIGNAL(pauseTransfer(Transfer*)), this,
        SLOT(transferPaused(Transfer*)));

void TUITestClient::transferPaused(Transfer * transfer) {
    //User requested transfer to pause, pause transfer and update TransferUI
    
    transfer->markPaused();
}
See also:
startTransfer
int TransferUI::Client::progressTimeDelta (  )  const

get function for the progress time delta

Returns:
the progress time delata
double TransferUI::Client::progressValueDelta (  )  const

get function for the progress value delta

Returns:
the progress value delata
Transfer* TransferUI::Client::registerTransfer ( const QString name,
TransferType  type,
const QString clientId = QString()  
)

Register a new transient transfer.

This function registers a transfer which doesn't uses tracker. A unique identifier is generated by TransferUI and returned as Id. Id is used to control presentation of the transfer registered in TransferUI. The transfer details other than title and type will be set to default values. libtuiclient has a failsafe mechanism which re-populates the transfers in transfer-ui if transfer-ui crashes, hence when the transfer is completed or canceled, transfer should be removed from the client list using removeTransfer. For the first registered transfer of this client , transfer-ui emits its visibility state signals tuiOpened() / tuiClosed()
Size will be set to zero
Total file count will be set to 1
State will be set to pending without any message
Thumbnail is set to default thumbnail
TargetName will be set to Null.

Parameters:
name  transfer name which will be presented to the user
type  transfer type , TransferType enum
clientId  client id of the client. This parameter is used get special attributes for the client. clients should install config file into /usr/share/transfer-ui/clients/<clientid> path. transfer-ui reads the attributes from the given path. At present "DetailsDBusInterface" is supported by transfer-ui which displays custom details dialog when user clicks on the transfer.
Returns:
Transfer class you can use to update it's state and get signals. Owned by client.
void TUITestClient::registerTransfer() {
    //Add a new upload transfer in TransferUI
    uploadTransfer = client->registerTransfer("New Upload Transfer",TransferUI::Client::TRANSFER_TYPES_UPLOAD);
    
    //Add a new download transfer in TransferUI
    downloadTransfer = client->registerTransfer("New Download Transfer", TransferUI::Client::TRANSFER_TYPES_DOWNLOAD);
    
    //Add a new Sync transfer in TransferUI
    syncTransfer = client->registerTransfer("Synchronizing", TransferUI::Client::TRANSFER_TYPES_SYNC);
    
    //Commit usage
    uploadTransfer->waitForCommit(); //start commit
    uploadTransfer->setName("filename.jpg");
    uploadTransfer->setTargetName("picasa");
    uploadTransfer->setFilesCount(10);
    uploadTransfer->setSize(1000);
    uploadTransfer->commit(); //end commit 
    //Reduces three dbus calls to transfer-ui
    
}
See also:
removeTransfer
void TransferUI::Client::removeTransfer ( const QString tid  ) 

Remove the transfer whose id is passed from list of transfers.

This does not remove transfers from transfer-ui. After removing from the list, transfer will not recieve any signals from the transfer-ui.

Parameters:
tid  Id of the transfer to be removed.
void TUITestClient::removeTransfer() {
    //Get the transfer identifier 
    QString tdId = uploadTransfer->transferId();
    
    //remove upload transfer from TransferUI
    client->removeTransfer(tdId);
    
    delete uploadTransfer;
    uploadTransfer= 0;
}
void TransferUI::Client::repairErrorTransfer ( Transfer transfer  )  [signal]

Signal emitted when error repair is requested.

Parameters:
transfer  Transfer that is asked to be paused
    connect(client,SIGNAL(repairErrorTransfer(Transfer*)), this,
        SLOT(transferErrorRepairRequested(Transfer*)));

void TUITestClient::transferErrorRepairRequested(Transfer * transfer) {
    //User has requested for repair the error take some action
}
See also:
Transfer::markRepairableFailure
void TransferUI::Client::setProgressTimeDelta ( int  delta  ) 

set the progress time delta.

This delta is applicable for all the transfers in the client. Changing default delta value will impact the performance.Delta value should be non-negative value and greater than 50 ms.

Parameters:
delta  modified delta value in milliseconds
void TransferUI::Client::setProgressValueDelta ( double  delta  ) 

set the progress value delta.

This delta is applicable for all the transfers in the client. Changing default delta value will impact the performance. Delta values should be in the range of 0.01 to 1. Other than those, delta values will be ignored

Parameters:
delta  modified delta value.
bool TransferUI::Client::showUI (  ) 

Ask transfer-ui to show it's UI.

Returns:
true if request was send successfully
void TransferUI::Client::startTransfer ( Transfer transfer  )  [signal]

Signal emitted when some of transfers related to this client is asked to be started/continued.

Transfer will emit signal first then it will be emited by client.

Parameters:
transfer  transfer that is asked to be started/continued
    connect(client,SIGNAL(startTransfer(Transfer*)), this,
        SLOT(transferResumed(Transfer*)));

void TUITestClient::transferResumed(Transfer * transfer) {
    //User requested transfer to resume, resume transfer and update TransferUI
    
    transfer->markResumed();
}
See also:
pauseTransfer
void TransferUI::Client::summaryReport ( int  failed,
int  active,
int  pending,
int  completed  
) [signal]

Summary update of all transfers followed by transfer-ui.

Parameters:
failed  number of failed transfers
active  number of active transfers
pending  number of pending transfers
completed  number of completed transfers currently presented by Transfer UI

(c) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
GNU Lesser General Public License, version 2.1 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MeeGo 1.2 Harmattan API