camerauis/cameraxui/cxengine/src/cxediskmonitor.cpp
author hgs
Thu, 13 May 2010 21:30:19 +0300
changeset 28 3075d9b614e6
permissions -rw-r--r--
201017_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     1
/*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     3
* All rights reserved.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     8
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
     9
* Initial Contributors:
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    11
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    12
* Contributors:
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    13
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    14
* Description:
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    15
*
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    16
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    17
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    18
#include "cxutils.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    19
#include "cxediskmonitor.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    20
#include "cxediskmonitorprivate.h"
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    21
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    22
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    23
* Constructor.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    24
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    25
CxeDiskMonitor::CxeDiskMonitor(CxeSettings &settings)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    26
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    27
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    28
    p = new CxeDiskMonitorPrivate(settings);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    29
    CX_ASSERT_ALWAYS(p);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    30
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    31
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    32
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    33
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    34
* Destructor.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    35
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    36
CxeDiskMonitor::~CxeDiskMonitor()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    37
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    38
    delete p;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    39
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    40
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    41
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    42
* Set the warning level of free disk space.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    43
* When free disk space falls below this limit, diskSpaceLow() signal is emitted.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    44
* @param bytes Limit in bytes.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    45
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    46
void CxeDiskMonitor::setLowWarningLevel(qint64 bytes)
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    47
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    48
    if (p) {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    49
        p->setLowWarningLevel(bytes);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    50
    }
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    51
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    52
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    53
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    54
* Slot to start monitoring disk space.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    55
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    56
void CxeDiskMonitor::start()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    57
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    58
    if (p) {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    59
        connect(p, SIGNAL(diskSpaceLow()), this, SIGNAL(diskSpaceLow()), Qt::UniqueConnection);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    60
        connect(p, SIGNAL(diskSpaceChanged()), this, SIGNAL(diskSpaceChanged()), Qt::UniqueConnection);
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    61
        p->start();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    62
    }
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    63
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    64
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    65
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    66
* Slot to stop monitoring disk space.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    67
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    68
void CxeDiskMonitor::stop()
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    69
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    70
    if (p) {
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    71
        p->stop();
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    72
        disconnect(p, SIGNAL(diskSpaceChanged()), this, SIGNAL(diskSpaceChanged()));
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    73
        disconnect(p, SIGNAL(diskSpaceLow()), this, SIGNAL(diskSpaceLow()));
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    74
    }
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    75
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    76
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    77
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    78
* Is monitoring ongoing at the moment.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    79
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    80
bool CxeDiskMonitor::isMonitoring() const
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    81
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    82
    return p ? p->isMonitoring() : false;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    83
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    84
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    85
/*!
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    86
* Get free disk space for Camera use in bytes.
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    87
*/
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    88
qint64 CxeDiskMonitor::free(bool cached) const
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    89
{
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    90
    return p ? p->free(cached) : 0;
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    91
}
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    92
3075d9b614e6 201017_1
hgs
parents:
diff changeset
    93
// end of file