controlpanelui/src/tonefetcher/src/tonefetcher.cpp
branchRCL_3
changeset 13 90fe62538f66
equal deleted inserted replaced
12:3fec62e6e7fc 13:90fe62538f66
       
     1 /*
       
     2  * Copyright (c) 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:
       
    15  *     The source file for tone fetcher.
       
    16  *     
       
    17  */
       
    18 #include "tonefetcher.h"
       
    19 #include <hbmainwindow.h>
       
    20 #include "tonefetcherview.h"
       
    21 #include "tonefetchermainwindow.h"
       
    22 #include "tonefetcherutils.h"
       
    23 #include <QChar>
       
    24 #include <QDir>
       
    25 #include <tonefetcherlogger.h>
       
    26 
       
    27 ToneFetcher::ToneFetcher(HbMainWindow *mainWindow)
       
    28     : XQServiceProvider(QString("tonefetcher.com.nokia.symbian.IToneFetch"), mainWindow),
       
    29       mMainWindow(mainWindow),
       
    30       mAsyncRequestIndex(-1),
       
    31       mReturnValue(0)
       
    32 {
       
    33     //publish tone service
       
    34     publishAll();
       
    35 }
       
    36 
       
    37 ToneFetcher::~ToneFetcher()
       
    38 {
       
    39 
       
    40 }
       
    41 
       
    42 void ToneFetcher::fetch()
       
    43 {
       
    44     mAsyncRequestIndex = setCurrentRequestAsync();    
       
    45     if (mMainWindow) {
       
    46         mMainWindow->show();
       
    47         ToneFetcherView *toneView = new ToneFetcherView(this);
       
    48         if (toneView) {            
       
    49             connect(toneView, SIGNAL(itemSelected(QString)), this, SLOT(setSelectedPath(QString)));
       
    50             mMainWindow->addView(toneView);
       
    51             mMainWindow->setCurrentView(toneView);            
       
    52         } else {
       
    53             TF_LOG("ToneFetcher::fetch: ToneFetcherView failed to be created");
       
    54         }
       
    55     }
       
    56 }
       
    57 
       
    58 void ToneFetcher::complete()
       
    59 {
       
    60     completeRequest(mAsyncRequestIndex, mReturnValue);    
       
    61 }
       
    62 
       
    63 bool ToneFetcher::isActive()
       
    64 {
       
    65     return mAsyncRequestIndex > 0;
       
    66 }
       
    67 
       
    68 void ToneFetcher::setSelectedPath(const QString & tonePath)
       
    69 {    
       
    70     mReturnValue.setValue(ToneFetcherUtils::normalizeSeperator(tonePath));
       
    71 }
       
    72 //End of File