messagingapp/msgui/msguiutils/src/msgcontactsutil.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 /*
       
     2  * Copyright (c) 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:
       
    15  *
       
    16  */
       
    17 #include "msgcontactsutil.h"
       
    18 #include "convergedmessageaddress.h"
       
    19 
       
    20 //System Includes
       
    21 #include <xqservicerequest.h>
       
    22 #include <cntservicescontact.h>
       
    23 #include <qtcontactsglobal.h>
       
    24 #include <qtcontacts.h> 
       
    25 
       
    26 QTM_USE_NAMESPACE
       
    27 
       
    28 //---------------------------------------------------------------
       
    29 // MsgContactsUtil::MsgContactsUtil
       
    30 // @see header file
       
    31 //---------------------------------------------------------------
       
    32 MsgContactsUtil::MsgContactsUtil(QObject* parent):
       
    33 QObject(parent),
       
    34 mRequest(NULL)
       
    35 {    
       
    36 }
       
    37 
       
    38 //---------------------------------------------------------------
       
    39 // MsgContactsUtil::~MsgContactsUtil
       
    40 // @see header file
       
    41 //---------------------------------------------------------------
       
    42 MsgContactsUtil::~MsgContactsUtil()
       
    43 {
       
    44     if(mRequest)
       
    45     {
       
    46         delete mRequest;
       
    47         mRequest = NULL;
       
    48     }
       
    49 }
       
    50 
       
    51 //---------------------------------------------------------------
       
    52 // MsgContactsUtil::~onRequestCompleted
       
    53 // @see header file
       
    54 //---------------------------------------------------------------
       
    55 void MsgContactsUtil::fetchContacts()
       
    56     {
       
    57     if (mRequest)
       
    58         {
       
    59         delete mRequest;
       
    60         }
       
    61     QString interface("com.nokia.services.phonebookservices.Fetch");
       
    62     QString operation("fetch(QString,QString,QString)");
       
    63        
       
    64     mRequest = new XQServiceRequest(interface,operation,false);
       
    65     connect(mRequest, SIGNAL(requestCompleted(const QVariant&)),
       
    66             parent(), SIGNAL(contactsFetched(const QVariant&)));
       
    67 
       
    68 
       
    69     *mRequest << QString(tr("Phonebook")); // TODO: Localization
       
    70     *mRequest << KCntActionAll;
       
    71     *mRequest << KCntFilterDisplayAll;
       
    72 
       
    73     QVariant retValue;
       
    74     bool res=mRequest->send(retValue);
       
    75     }
       
    76 
       
    77 void MsgContactsUtil::openContactDetails(qint32 contactId)
       
    78     {
       
    79     XQServiceRequest* mCntOpen;
       
    80     
       
    81     mCntOpen= new XQServiceRequest("com.nokia.services.phonebookservices.Fetch", "open(int)", false);
       
    82     
       
    83     // Fetch back the persisted contact
       
    84     QContactManager cm("symbian");
       
    85     QContact contact = cm.contact(contactId);
       
    86     
       
    87     QContactLocalId lId;
       
    88     lId = contact.localId();
       
    89     
       
    90     *mCntOpen<<lId;
       
    91     bool res=mCntOpen->send();
       
    92     delete mCntOpen;
       
    93     }
       
    94 // EOF