camerauis/cameraxui/cxengine/inc/cxefilesavethreadsymbian.h
branchRCL_3
changeset 54 bac7acad7cb3
parent 53 61bc0f252b2b
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
     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:  Still image saving thread
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CXEFILESAVETHREADSYMBIAN_H
       
    21 #define CXEFILESAVETHREADSYMBIAN_H
       
    22 
       
    23 #include <QMutex>
       
    24 #include <QWaitCondition>
       
    25 #include <QHash>
       
    26 #include <QQueue>
       
    27 #include "cxeerror.h"
       
    28 #include "cxefilesavethread.h"
       
    29 
       
    30 class CxeImageDataItem;
       
    31 class CxeThumbnailManagerSymbian;
       
    32 class CxeHarvesterControlSymbian;
       
    33 
       
    34 
       
    35 class CxeFileSaveThreadSymbian : public CxeFileSaveThread
       
    36     {
       
    37     Q_OBJECT
       
    38 public:
       
    39 
       
    40     CxeFileSaveThreadSymbian(QObject *parent = 0);
       
    41     ~CxeFileSaveThreadSymbian();
       
    42 
       
    43     /**
       
    44      * Save is called by Camera UI thread.
       
    45      * Method takes ownership of data.
       
    46      */
       
    47     void save(CxeImageDataItem* data);
       
    48 
       
    49 public slots:
       
    50     void handleVideoSaved(CxeError::Id status, const QString& filename);
       
    51     void handleSnapshotReady(CxeError::Id status, const QImage& snapshot, const QString& filename);
       
    52     void handleSnapshotReady(CxeError::Id status, const QImage& snapshot, int id);
       
    53 
       
    54 protected slots:
       
    55     void handleFileHarvested(CxeError::Id status, const QString& filename);
       
    56 
       
    57 protected:
       
    58     virtual void init();
       
    59     virtual void deinit();
       
    60 
       
    61 private:
       
    62     /**
       
    63      * This method includes saving in own thread.
       
    64      * Functions called from this method are running in "saving thread"
       
    65      */
       
    66     void run();
       
    67     void read();
       
    68     void saveNow();
       
    69     void harvestFile(const QString& filename, bool addLocation);
       
    70 
       
    71 private: // data shared between the threads
       
    72 
       
    73     bool mExitThread;
       
    74     QQueue<CxeImageDataItem*> mQueue;
       
    75 
       
    76     mutable QMutex mMutex;
       
    77     QWaitCondition mDataToSave;
       
    78 
       
    79     mutable QMutex mSnapshotsMutex;
       
    80     QHash<QString, QImage> mSnapshots;
       
    81 
       
    82 protected: // thread only used data
       
    83     int mCount;
       
    84     int mActiveHarvests;
       
    85     bool mExit;
       
    86     CxeThumbnailManagerSymbian *mThumbnailManager; // own
       
    87     CxeHarvesterControlSymbian *mHarvesterControl; // own
       
    88     };
       
    89 
       
    90 #endif // CXEFILESAVETHREADSYMBIAN_H