locationdataharvester/geocodeupdate/src/geocodeupdate.cpp
changeset 17 0f22fb80ebba
child 20 cd10d5b85554
equal deleted inserted replaced
15:13ae750350c9 17:0f22fb80ebba
       
     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 <qcontactgeolocation.h>
       
    19 #include <qcontactmanager.h>
       
    20 #include <qtcontacts.h>
       
    21 #include <cntdef.h>
       
    22 #include <qstring>
       
    23 
       
    24 #include "geocodeupdate.h"
       
    25 #include "mylocationsdefines.h"
       
    26 #include "mylocationlogger.h"
       
    27 
       
    28 using namespace QTM_NAMESPACE;
       
    29 // ----------------------------------------------------------------------------
       
    30 // CGeocodeUpdate::CreateContactdb()
       
    31 // ----------------------------------------------------------------------------
       
    32 EXPORT_C void GeocodeUpdate::CreateContactdb()
       
    33 {
       
    34     QContactManager* contactManger = NULL;
       
    35     MYLOCLOGSTRING("call to create contactManger object and contactdb as well.");
       
    36     contactManger = new QContactManager("symbian");
       
    37     delete contactManger;
       
    38 }
       
    39 
       
    40 // ----------------------------------------------------------------------------
       
    41 // CGeocodeUpdate::UpDateL()
       
    42 // To update contact db with this latitude and longitude value 
       
    43 // ----------------------------------------------------------------------------
       
    44 EXPORT_C void GeocodeUpdate::UpDate(const TInt32 aCntId,
       
    45         const TInt32 aCntAddressType, const TReal aLatitude,
       
    46         const TReal aLongitude)
       
    47 
       
    48 {
       
    49     __TRACE_CALLSTACK;
       
    50     QContactManager* contactManger = NULL;
       
    51     MYLOCLOGSTRING("call to create contactManger object .");
       
    52     contactManger = new QContactManager("symbian");
       
    53     MYLOCLOGSTRING("contactManger object created .");
       
    54 
       
    55     MYLOCLOGSTRING("contactManger object is not null .");
       
    56     QStringList definitionRestrictions;
       
    57     QContact contact = contactManger->contact(aCntId ,definitionRestrictions);
       
    58     QContactGeoLocation location;
       
    59 
       
    60     switch (aCntAddressType)
       
    61     {
       
    62     case ESourceContactsPref:
       
    63     {
       
    64         break;
       
    65     }
       
    66     case ESourceContactsWork:
       
    67     {
       
    68         location.setContexts(QContactDetail::ContextWork);
       
    69         break;
       
    70     }
       
    71     case ESourceContactsHome:
       
    72     {
       
    73         location.setContexts(QContactDetail::ContextHome);
       
    74         break;
       
    75     }
       
    76     default:
       
    77     {
       
    78         break;
       
    79     }
       
    80     }
       
    81     location.setLongitude(aLongitude);
       
    82     location.setLatitude(aLatitude);
       
    83     contact.saveDetail(&location);
       
    84     contactManger->saveContact(&contact);
       
    85     delete contactManger;
       
    86 
       
    87 }
       
    88 
       
    89 //end of line