src/location/qmlbackendmonitorinfo_s60.cpp
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 
       
    43 #include "qmlbackendmonitorinfo_s60_p.h"
       
    44 
       
    45 QTM_BEGIN_NAMESPACE
       
    46 
       
    47 //singleton class object
       
    48 CBackendMonitorInfo* CBackendMonitorInfo::iBackendMonitorInfo = NULL;
       
    49 
       
    50 CBackendMonitorInfo* CBackendMonitorInfo::NewL()
       
    51 {
       
    52     if (!iBackendMonitorInfo)
       
    53         iBackendMonitorInfo = new CBackendMonitorInfo;
       
    54 
       
    55     return iBackendMonitorInfo;
       
    56 }
       
    57 
       
    58 //returns the CMonitorTriggerInfo info based on the aTrigID
       
    59 CMonitorTriggerInfo* CBackendMonitorInfo::getMonitorTriggerInfo(TLbtTriggerId aTrigID)
       
    60 {
       
    61     CMonitorTriggerInfo* currentNode = iMonitorInfo;
       
    62     while (currentNode && (currentNode->iTriggerID != aTrigID)) {
       
    63         currentNode = currentNode->next;
       
    64     }
       
    65     return currentNode;
       
    66 }
       
    67 
       
    68 //returns the CMonitorTriggerInfo info based on the aParent,aType from the linked list
       
    69 CMonitorTriggerInfo* CBackendMonitorInfo::getMonitorTriggerInfo(QGeoAreaMonitorS60* aParent, enTriggerType aType)
       
    70 {
       
    71     CMonitorTriggerInfo* currentNode = iMonitorInfo;
       
    72     while (currentNode) {
       
    73         if ((currentNode->iParent == aParent) && (currentNode->iType == aType))
       
    74             break;
       
    75 
       
    76         currentNode = currentNode->next;
       
    77     }
       
    78     return currentNode;
       
    79 }
       
    80 
       
    81 //creates and adds a new CMonitorTriggerInfo object to the end of linked list
       
    82 bool CBackendMonitorInfo::addMonitorTriggerInfo(QGeoAreaMonitorS60* aParent, TLbtTriggerId aTriggerID, enTriggerType aType)
       
    83 {
       
    84     CMonitorTriggerInfo* currentNode = NULL;
       
    85 
       
    86     CMonitorTriggerInfo* temp = new CMonitorTriggerInfo;
       
    87 
       
    88     if (!temp) {
       
    89         return FALSE;
       
    90     }
       
    91 
       
    92     temp->iTriggerID = aTriggerID;
       
    93     temp->iParent = aParent;
       
    94     temp->iType = aType;
       
    95     temp->next = NULL;
       
    96 
       
    97     currentNode = iMonitorInfo;
       
    98 
       
    99     while (currentNode && (currentNode->next != NULL))
       
   100         currentNode = currentNode->next;
       
   101 
       
   102     if (!currentNode) {
       
   103         iMonitorInfo = temp;
       
   104     } else {
       
   105         currentNode->next = temp;
       
   106     }
       
   107 
       
   108     return TRUE;
       
   109 }
       
   110 
       
   111 //deletes the node corresponding to aTrigID
       
   112 void CBackendMonitorInfo::removeMonitorTriggerInfo(TLbtTriggerId aTrigID)
       
   113 {
       
   114     CMonitorTriggerInfo* currentNode = NULL;
       
   115 
       
   116     CMonitorTriggerInfo* prevNode = NULL;
       
   117 
       
   118     currentNode = prevNode = iMonitorInfo;
       
   119 
       
   120     while (currentNode && (currentNode->iTriggerID != aTrigID)) {
       
   121         prevNode = currentNode;
       
   122         currentNode = currentNode->next;
       
   123     }
       
   124 
       
   125     if (currentNode == NULL)
       
   126         return;
       
   127 
       
   128     else if (currentNode == iMonitorInfo) {
       
   129         iMonitorInfo = currentNode->next;
       
   130     }
       
   131 
       
   132     else {
       
   133         prevNode->next = currentNode->next;
       
   134     }
       
   135 
       
   136     delete currentNode;
       
   137 }
       
   138 
       
   139 //deletes all the nodes in the linked list
       
   140 CBackendMonitorInfo::~CBackendMonitorInfo()
       
   141 {
       
   142     CMonitorTriggerInfo* currentNode = NULL;
       
   143     CMonitorTriggerInfo* prevNode = NULL;
       
   144 
       
   145     prevNode = iMonitorInfo;
       
   146 
       
   147     while (prevNode) {
       
   148         currentNode = prevNode;
       
   149         prevNode = prevNode->next;
       
   150         delete currentNode;
       
   151     }
       
   152 
       
   153     iMonitorInfo = NULL;
       
   154     iBackendMonitorInfo = NULL;
       
   155 }
       
   156 
       
   157 QTM_END_NAMESPACE