utilities/downloadmanager/src/downloadcoremanager.cpp
changeset 16 3c88a81ff781
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
       
     1 /**
       
     2    This file is part of CWRT package **
       
     3 
       
     4    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). **
       
     5 
       
     6    This program is free software: you can redistribute it and/or modify
       
     7    it under the terms of the GNU (Lesser) General Public License as 
       
     8    published by the Free Software Foundation, version 2.1 of the License. 
       
     9    This program is distributed in the hope that it will be useful, but
       
    10    WITHOUT ANY WARRANTY; without even the implied warranty of 
       
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
       
    12    (Lesser) General Public License for more details. You should have 
       
    13    received a copy of the GNU (Lesser) General Public License along 
       
    14    with this program. If not, see <http://www.gnu.org/licenses/>.
       
    15 */
       
    16 
       
    17 #include "downloadcore.h"
       
    18 #include "downloadcoremanager.h"
       
    19 #include <QVector>
       
    20 
       
    21 // private implementation class
       
    22 class DownloadCoreManagerPrivate
       
    23 {
       
    24     DM_DECLARE_PUBLIC(DownloadCoreManager);
       
    25 public:
       
    26     DownloadCoreManagerPrivate();
       
    27     ~DownloadCoreManagerPrivate();
       
    28 
       
    29     QVector<DownloadCore*> m_downloadCores;
       
    30     QString m_clientName;
       
    31 };
       
    32 
       
    33 DownloadCoreManagerPrivate::DownloadCoreManagerPrivate()
       
    34 {
       
    35     m_clientName = "";
       
    36 }
       
    37 
       
    38 DownloadCoreManagerPrivate::~DownloadCoreManagerPrivate()
       
    39 {
       
    40     int totalSize = m_downloadCores.size();
       
    41     for( int i=0; i < totalSize; i++)
       
    42     {
       
    43        delete m_downloadCores[i];
       
    44     }
       
    45     m_downloadCores.clear();
       
    46 }
       
    47 
       
    48 DownloadCoreManager::DownloadCoreManager(const QString &clientName)
       
    49 {
       
    50     DM_INITIALIZE(DownloadCoreManager);
       
    51     priv->m_clientName = clientName;
       
    52 }
       
    53 
       
    54 DownloadCoreManager::~DownloadCoreManager()
       
    55 {
       
    56    DM_UNINITIALIZE(DownloadCoreManager);
       
    57 }
       
    58 
       
    59 DownloadCore* DownloadCoreManager::createDownloadCore(const QString &aUrl)
       
    60 {
       
    61     DM_PRIVATE(DownloadCoreManager);
       
    62     // create download core by url
       
    63     DownloadCore* dlCore = new DownloadCore(aUrl);
       
    64     (priv->m_downloadCores).append(dlCore);
       
    65     return dlCore;     
       
    66 }
       
    67 
       
    68 DownloadCore* DownloadCoreManager::createDownloadCore(QNetworkReply *reply)
       
    69 {
       
    70     DM_PRIVATE(DownloadCoreManager);
       
    71     // create download core by network reply
       
    72     DownloadCore* dlCore = new DownloadCore(reply);
       
    73     (priv->m_downloadCores).append(dlCore);
       
    74     return dlCore;     
       
    75 }
       
    76 
       
    77 QString& DownloadCoreManager::clientName(void)
       
    78 {
       
    79     DM_PRIVATE(DownloadCoreManager);
       
    80     return priv->m_clientName;
       
    81 }