camerauis/cameraxui/cxengine/src/cxegeotaggingtrail_desktop_p.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 53 61bc0f252b2b
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
     1 /*
       
     2 * Copyright (c) 2010 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 *
       
    16 */
       
    17 
       
    18 #include "cxutils.h"
       
    19 #include "cxestate.h"
       
    20 #include "cxesettings.h"
       
    21 #include "cxenamespace.h"
       
    22 #include "cxestillcapturecontrol.h"
       
    23 #include "cxevideocapturecontrol.h"
       
    24 #include "cxegeotaggingtrail_desktop_p.h"
       
    25 
       
    26 
       
    27 namespace
       
    28 {
       
    29     // in milliseconds
       
    30     const int STOP_TRAIL_INTERVAL = 10*1000;
       
    31 }
       
    32 
       
    33 
       
    34 /*!
       
    35 * Constructor
       
    36 */
       
    37 CxeGeoTaggingTrailPrivate::CxeGeoTaggingTrailPrivate(CxeStillCaptureControl &stillControl,
       
    38                                                      CxeVideoCaptureControl &videoControl,
       
    39 													 CxeSettings &settings)
       
    40     : CxeStateMachine("CxeGeoTaggingTrailPrivate"),
       
    41       mSettings(settings)
       
    42 {
       
    43     CX_DEBUG_ENTER_FUNCTION();	
       
    44     Q_UNUSED(stillControl);
       
    45     Q_UNUSED(videoControl);
       
    46 
       
    47     qRegisterMetaType<CxeGeoTaggingTrail::State>();
       
    48     initializeStates();
       
    49 
       
    50     connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)),
       
    51             this, SLOT(handleSettingValueChanged(const QString&,QVariant)));
       
    52     
       
    53     CX_DEBUG_EXIT_FUNCTION();
       
    54 }
       
    55 
       
    56 /*!
       
    57 * Destructor
       
    58 */
       
    59 CxeGeoTaggingTrailPrivate::~CxeGeoTaggingTrailPrivate()
       
    60 {
       
    61     CX_DEBUG_ENTER_FUNCTION();
       
    62 
       
    63     // stop trail and close location utility session
       
    64     stop(true);
       
    65 
       
    66     CX_DEBUG_EXIT_FUNCTION();
       
    67 }
       
    68 
       
    69 /*!
       
    70 * Start location trail.
       
    71 */
       
    72 void CxeGeoTaggingTrailPrivate::start()
       
    73 {
       
    74     CX_DEBUG_ENTER_FUNCTION();
       
    75 
       
    76     setState(CxeGeoTaggingTrail::Connected);
       
    77     setState(CxeGeoTaggingTrail::TrailStarted);
       
    78 
       
    79     CX_DEBUG_EXIT_FUNCTION();
       
    80 }
       
    81 
       
    82 /*!
       
    83 * Stop location trail.
       
    84 * @ param closeSession, indicates if we are willing to close the location utility session.
       
    85 */
       
    86 void CxeGeoTaggingTrailPrivate::stop(bool closeSession)
       
    87 {
       
    88     CX_DEBUG_ENTER_FUNCTION();
       
    89 
       
    90     setState(CxeGeoTaggingTrail::NotConnected);
       
    91 
       
    92     CX_DEBUG_EXIT_FUNCTION();
       
    93 }
       
    94 
       
    95 /*!
       
    96 * Handle new setting value.
       
    97 * Check if the geotagging setting has changed.
       
    98 */
       
    99 void CxeGeoTaggingTrailPrivate::handleSettingValueChanged(const QString& settingId, QVariant newValue)
       
   100 {
       
   101     CX_DEBUG_ENTER_FUNCTION();
       
   102     
       
   103     if (settingId == CxeSettingIds::GEOTAGGING) {
       
   104         if (newValue.toInt() == Cxe::GeoTaggingOn) {
       
   105             // setting is turned ON, start location trail
       
   106             start();
       
   107         } else {
       
   108             // setting is turned OFF, stopping location trail
       
   109             stop();
       
   110         }
       
   111     } else if (settingId == CxeSettingIds::GEOTAGGING_DISCLAIMER) {
       
   112         if (newValue.toInt() == Cxe::GeoTaggingDisclaimerDisabled) {
       
   113             // geotagging disclaimer is diabled, we can start location trail.
       
   114             start();
       
   115         }
       
   116     }
       
   117     
       
   118     CX_DEBUG_EXIT_FUNCTION();
       
   119 }
       
   120 
       
   121 /*!
       
   122 Returns current state of Location trail
       
   123 */
       
   124 CxeGeoTaggingTrail::State CxeGeoTaggingTrailPrivate::state() const
       
   125 {
       
   126     return static_cast<CxeGeoTaggingTrail::State> (stateId());
       
   127 }
       
   128 
       
   129 /*!
       
   130 * slot called when state is changed.
       
   131 */
       
   132 void CxeGeoTaggingTrailPrivate::handleStateChanged(int newStateId, CxeError::Id error)
       
   133 {
       
   134     emit stateChanged(static_cast<CxeGeoTaggingTrail::State> (newStateId), error);
       
   135     
       
   136 }
       
   137 
       
   138 /*!
       
   139 * Initialize states for geotaggingtrail
       
   140 */
       
   141 void CxeGeoTaggingTrailPrivate::initializeStates()
       
   142 {
       
   143     // addState( id, name, allowed next states )
       
   144     addState(new CxeState(CxeGeoTaggingTrail::NotConnected, "NotConnected", CxeGeoTaggingTrail::Connected));
       
   145     
       
   146     addState(new CxeState(CxeGeoTaggingTrail::Connected, "Connected", CxeGeoTaggingTrail::TrailStarted | 
       
   147                                                                       CxeGeoTaggingTrail::NotConnected));
       
   148     
       
   149     addState(new CxeState(CxeGeoTaggingTrail::TrailStarted, "TrailStarted", CxeGeoTaggingTrail::DataAvailable |
       
   150                                                                             CxeGeoTaggingTrail::Connected |
       
   151                                                                             CxeGeoTaggingTrail::NotConnected));
       
   152     
       
   153     addState(new CxeState(CxeGeoTaggingTrail::DataAvailable, "DataAvailable", CxeGeoTaggingTrail::Connected | 
       
   154                                                                               CxeGeoTaggingTrail::NotConnected));
       
   155     
       
   156 
       
   157     setInitialState(CxeGeoTaggingTrail::NotConnected);
       
   158 }
       
   159 
       
   160 // end of file