dbmanager.html 13.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- dbmanager.cpp -->
  <title>Nemo TransferEngine 1.0: DbManager Class Reference</title>
<li>Modules</li>
<li>DbManager</li>
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">DbManager Class Reference</h1>
<!-- $$$DbManager-brief -->
<p>The DbManager class is a singleton class to read and write transfers database. <a href="#details">More...</a></p>
<!-- @@@DbManager -->
<pre class="cpp"> <span class="preprocessor">#include &lt;DbManager&gt;</span></pre><ul>
<li><a href="dbmanager-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#dtor.DbManager">~DbManager</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#callback">callback</a></b> ( int <i>key</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#callbackMethods">callbackMethods</a></b> ( int <i>key</i>, QString &amp; <i>cancelMethod</i>, QString &amp; <i>restartMethod</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#clearTransfers">clearTransfers</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#createCallbackEntry">createCallbackEntry</a></b> ( int <i>key</i>, const QString &amp; <i>service</i>, const QString &amp; <i>path</i>, const QString &amp; <i>interface</i>, const QString &amp; <i>cancelMethod</i>, const QString &amp; <i>restartMethod</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#createMetadataEntry">createMetadataEntry</a></b> ( int <i>key</i>, const QString &amp; <i>title</i>, const QString &amp; <i>description</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#createTransferEntry">createTransferEntry</a></b> ( MediaItem * <i>mediaItem</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> MediaItem * </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#mediaItem">mediaItem</a></b> ( int <i>key</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#removeTransfer">removeTransfer</a></b> ( int <i>key</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> TransferEngineData::TransferStatus </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#transferStatus">transferStatus</a></b> ( int <i>key</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> TransferEngineData::TransferType </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#transferType">transferType</a></b> ( int <i>key</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;TransferDBRecord&gt; </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#transfers">transfers</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#updateProgress">updateProgress</a></b> ( int <i>key</i>, qreal <i>progress</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#updateTransferStatus">updateTransferStatus</a></b> ( int <i>key</i>, TransferEngineData::TransferStatus <i>status</i> )</td></tr>
</table>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> DbManager * </td><td class="memItemRight bottomAlign"><b><a href="dbmanager.html#instance">instance</a></b> ()</td></tr>
</table>
<a name="details"></a>
<!-- $$$DbManager-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The DbManager class is a singleton class to read and write transfers database.</p>
<p>DbManager class takes care of reading and writing transfer database used by Nemo Transfer Engine. It's a singleton class and it can be instantiated using <a href="dbmanager.html#instance">DbManager::instance</a>() method.</p>
</div>
<!-- @@@DbManager -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$~DbManager[overload1]$$$~DbManager -->
<h3 class="fn"><a name="dtor.DbManager"></a>DbManager::<span class="name">~DbManager</span> ()</h3>
<p>Destructor.</p>
<!-- @@@~DbManager -->
<!-- $$$callback[overload1]$$$callbackint -->
<h3 class="fn"><a name="callback"></a><span class="type">QStringList</span> DbManager::<span class="name">callback</span> ( <span class="type">int</span> <i>key</i> ) const</h3>
<p>Get a DBus callback interface and method for the transfer with <i>key</i>. If there is no callback for the <i>key</i> then an empty QStringList is returned.</p>
<p>In a case there is a DBus callback, then QStringList contains the following items:</p>
<ul>
<li>service</li>
<li>path</li>
<li>interface</li>
<li>cancel method name</li>
<li>restart method name</li>
</ul>
<!-- @@@callback -->
<!-- $$$callbackMethods[overload1]$$$callbackMethodsintQString&QString& -->
<h3 class="fn"><a name="callbackMethods"></a><span class="type">bool</span> DbManager::<span class="name">callbackMethods</span> ( <span class="type">int</span> <i>key</i>, <span class="type">QString</span> &amp; <i>cancelMethod</i>, <span class="type">QString</span> &amp; <i>restartMethod</i> ) const</h3>
<p>Get the callback method names for the transfer with <i>key</i>. The method names are set to the output arguments <i>cancelMethod</i> and <i>restartMethod</i>.</p>
<p>This method returns true on success, false on failure.</p>
<!-- @@@callbackMethods -->
<!-- $$$clearTransfers[overload1]$$$clearTransfers -->
<h3 class="fn"><a name="clearTransfers"></a><span class="type">bool</span> DbManager::<span class="name">clearTransfers</span> ()</h3>
<p>Clear all finished, canceled or failed transfers from the database.</p>
<p>This method returns true on success, false on failure.</p>
<!-- @@@clearTransfers -->
<!-- $$$createCallbackEntry[overload1]$$$createCallbackEntryintconstQString&constQString&constQString&constQString&constQString& -->
<h3 class="fn"><a name="createCallbackEntry"></a><span class="type">int</span> DbManager::<span class="name">createCallbackEntry</span> ( <span class="type">int</span> <i>key</i>, const <span class="type">QString</span> &amp; <i>service</i>, const <span class="type">QString</span> &amp; <i>path</i>, const <span class="type">QString</span> &amp; <i>interface</i>, const <span class="type">QString</span> &amp; <i>cancelMethod</i>, const <span class="type">QString</span> &amp; <i>restartMethod</i> )</h3>
<p>Create a callback entry to the callback table for the existing transfer with a <i>key</i>.</p>
<p>The callback is a dbus interface so it must contain the following attributes:</p>
<ul>
<li><i>service</i> e.g&#x2e; com.jolla.myapp</li>
<li><i>path</i> e.g&#x2e; /com/jolla/myapp</li>
<li><i>interface</i> e.g&#x2e; com.jolla.myapp</li>
<li><i>cancelMethod</i> The name of the cancel method</li>
<li><i>restartMethod</i> The name of the restart method</li>
</ul>
<p>This method returns a key of the created callback record in a callback table or -1 on failure.</p>
<p>NOTE: Deleting the record from the transfer which has a <i>key</i>, also deletes related callback entry.</p>
<!-- @@@createCallbackEntry -->
<!-- $$$createMetadataEntry[overload1]$$$createMetadataEntryintconstQString&constQString& -->
<h3 class="fn"><a name="createMetadataEntry"></a><span class="type">int</span> DbManager::<span class="name">createMetadataEntry</span> ( <span class="type">int</span> <i>key</i>, const <span class="type">QString</span> &amp; <i>title</i>, const <span class="type">QString</span> &amp; <i>description</i> )</h3>
<p>Create a metadata entry for the existing transfer with <i>key</i>. Metadata can contain only <i>title</i> and/or <b class="redFont"><code>\description</code></b>.</p>
<p>Metadata entry will be created to the metadata table. Argument <i>key</i> must point to the existing entry in transfers table.</p>
<p>This method returns a key of the created record in metadata table or -1 on failure.</p>
<p>NOTE: Deleting the record from the transfer which has a <i>key</i>, also deletes related metadata entry.</p>
<!-- @@@createMetadataEntry -->
<!-- $$$createTransferEntry[overload1]$$$createTransferEntryMediaItem* -->
<h3 class="fn"><a name="createTransferEntry"></a><span class="type">int</span> DbManager::<span class="name">createTransferEntry</span> ( <span class="type">MediaItem</span> * <i>mediaItem</i> )</h3>
<p>Create a transfer entry to the transfers table bsaed on <i>mediaItem</i> content.</p>
<p>MediaItem instance contains all the required information for the single Upload, Download or a Sync item. Based on this information, <a href="dbmanager.html">DbManager</a> creates a record to the transfers table, but also to the callback and metadata tables if these are defined.</p>
<p>This method returns a key of the created transfer or -1 on failure.</p>
<p><b>See also </b>MediaItem.</p>
<!-- @@@createTransferEntry -->
<!-- $$$instance[overload1]$$$instance -->
<h3 class="fn"><a name="instance"></a><span class="type">DbManager</span> * DbManager::<span class="name">instance</span> ()<tt> [static]</tt></h3>
<p>Return a singleton instance of this <a href="dbmanager.html">DbManager</a>. Note that caller is NOT responsible of deleting the instance. It will be deleted automatically when application stack is cleaned.</p>
<!-- @@@instance -->
<!-- $$$mediaItem[overload1]$$$mediaItemint -->
<h3 class="fn"><a name="mediaItem"></a><span class="type">MediaItem</span> * DbManager::<span class="name">mediaItem</span> ( <span class="type">int</span> <i>key</i> ) const</h3>
<p>Returns a MediaItem instance from the transfer data with a <i>key</i>.</p>
<!-- @@@mediaItem -->
<!-- $$$removeTransfer[overload1]$$$removeTransferint -->
<h3 class="fn"><a name="removeTransfer"></a><span class="type">bool</span> DbManager::<span class="name">removeTransfer</span> ( <span class="type">int</span> <i>key</i> )</h3>
<p>Remove an existing transfer with a key from the transfers table. If this transfer has metadata or callback defined, they will be removed too.</p>
<p>This method returns true on success, false on failure.</p>
<!-- @@@removeTransfer -->
<!-- $$$transferStatus[overload1]$$$transferStatusint -->
<h3 class="fn"><a name="transferStatus"></a><span class="type"><a href="transferenginedata.html#TransferStatus-enum">TransferEngineData::TransferStatus</a></span> DbManager::<span class="name">transferStatus</span> ( <span class="type">int</span> <i>key</i> ) const</h3>
<p>Returns the transfer status of the transfer with <i>key</i>. In a case of error the <a href="transferenginedata.html#TransferStatus-enum">TransferEngineData::Unknown</a> is returned.</p>
<!-- @@@transferStatus -->
<!-- $$$transferType[overload1]$$$transferTypeint -->
<h3 class="fn"><a name="transferType"></a><span class="type"><a href="transferenginedata.html#TransferType-enum">TransferEngineData::TransferType</a></span> DbManager::<span class="name">transferType</span> ( <span class="type">int</span> <i>key</i> ) const</h3>
<p>Returns the transfer type e.g&#x2e; Sync, Download or Upload of the transfer with a <i>key</i>.</p>
<p>If there is no transfer record with key or error occurs, this method returns <a href="transferenginedata.html#TransferType-enum">TransferEngineData::Undefined</a>.</p>
<!-- @@@transferType -->
<!-- $$$transfers[overload1]$$$transfers -->
<h3 class="fn"><a name="transfers"></a><span class="type">QList</span>&lt;<span class="type"><a href="transferdbrecord.html">TransferDBRecord</a></span>&gt; DbManager::<span class="name">transfers</span> () const</h3>
<p>Returns all the transfers from the database. This method doesn't fetch all the fields from all the tables, instead it returns what is required to fill fields in <a href="transferdbrecord.html">TransferDBRecord</a> class.</p>
<!-- @@@transfers -->
<!-- $$$updateProgress[overload1]$$$updateProgressintqreal -->
<h3 class="fn"><a name="updateProgress"></a><span class="type">bool</span> DbManager::<span class="name">updateProgress</span> ( <span class="type">int</span> <i>key</i>, <span class="type">qreal</span> <i>progress</i> )</h3>
<p>Update a transfer <i>progress</i> of the existing transfer with <i>key</i>.</p>
<p>This method returns true on success, false on failure.</p>
<!-- @@@updateProgress -->
<!-- $$$updateTransferStatus[overload1]$$$updateTransferStatusintTransferEngineData::TransferStatus -->
<h3 class="fn"><a name="updateTransferStatus"></a><span class="type">bool</span> DbManager::<span class="name">updateTransferStatus</span> ( <span class="type">int</span> <i>key</i>, <span class="type"><a href="transferenginedata.html#TransferStatus-enum">TransferEngineData::TransferStatus</a></span> <i>status</i> )</h3>
<p>Update a transfer <i>status</i> of the existing transfer with <i>key</i>. Changing the status updates the timestamp too.</p>
<p>This method returns true on success, false on failure.</p>
<!-- @@@updateTransferStatus -->
</div>
</body>
</html>