qtinternetradio/irqstatisticsreport/src/irqreportsender.cpp
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2009-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  interface for updating network info
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "irqreportsender.h"
       
    20 #include "irqisdsclient.h"
       
    21 #include "irqsettings.h"
       
    22 #include "irqnetworkcontroller.h"
       
    23 #include "irreportsettings.h"
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // IRQReportSender::IRQReportSender()
       
    27 // Constructor
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 IRQReportSender::IRQReportSender(IRQIsdsClient *aIsdsClient):iIsdsClient(aIsdsClient),
       
    31                                                              iSettingManager(NULL),
       
    32                                                              iNetworkController(NULL)
       
    33 {
       
    34     iNetworkController = IRQNetworkController::openInstance();
       
    35     
       
    36     iSettingManager = IRQSettings::openInstance();
       
    37 }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // IRQReportSender::~IRQReportSender()
       
    41 // Destructor
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 IRQReportSender::~IRQReportSender()
       
    45 {
       
    46     if(iSettingManager)
       
    47     {
       
    48         iSettingManager->closeInstance();
       
    49     }
       
    50     
       
    51     if(iNetworkController)
       
    52     {
       
    53         iNetworkController->closeInstance();
       
    54     }    
       
    55 }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // IRQReportSender::LogDbNeedFlush()
       
    59 // From MIRLogDbStatusObserver
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void IRQReportSender::LogDbNeedFlush()
       
    63 {
       
    64     sendReport();
       
    65 }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // IRQReportSender::sendReport()
       
    69 // Send the statistics report to isds server
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void IRQReportSender::sendReport()
       
    73 {
       
    74     if(iNetworkController)
       
    75     {
       
    76     	  if(iNetworkController->getNetworkStatus() 
       
    77     	     && iIsdsClient && iSettingManager)
       
    78     	  {
       
    79             QString logFilePath = iSettingManager->privatePath();
       
    80             QString logFileName = QString::fromUtf16(KGZipLogFileName().Ptr(), KGZipLogFileName().Length());
       
    81             iIsdsClient->isdsPostLog(logFilePath + logFileName);
       
    82             emit reportSent();
       
    83         }
       
    84     }
       
    85 }