messagingapp/msgui/msgapp/src/msgserviceinterface.cpp
changeset 31 ebfee66fde93
child 34 84197e66a4bd
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     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: Message Application Launcher interface used for interfacing between
       
    15  *              QT highway and other applications
       
    16  *
       
    17  */
       
    18 
       
    19 //TODO: to be deprecated
       
    20 #include "convergedmessageaddress.h"
       
    21 
       
    22 #include "msgserviceinterface.h"
       
    23 #include "msgviewmanager.h"
       
    24 #include "msgcontacthandler.h"
       
    25 
       
    26 MsgServiceInterface::MsgServiceInterface(QObject* parent, MsgViewManager* manager)
       
    27 :XQServiceProvider( QLatin1String("com.nokia.services.hbserviceprovider.conversationview"),parent),
       
    28 mViewManager(manager)
       
    29     {
       
    30     publishAll();    
       
    31     }
       
    32 
       
    33 MsgServiceInterface::~MsgServiceInterface()
       
    34     {
       
    35     }
       
    36 
       
    37 void MsgServiceInterface::send(const QString phoneNumber, const qint32 contactId, const QString displayName)
       
    38     {   
       
    39     mViewManager->setServiceRequest(true);
       
    40     mViewManager->send(contactId, phoneNumber, displayName);    
       
    41     }
       
    42 
       
    43 
       
    44 void MsgServiceInterface::send(const QString phoneNumber, const QString alias, const QString bodyText)
       
    45     {   
       
    46     mViewManager->setServiceRequest(true);
       
    47     mViewManager->send(phoneNumber, alias, bodyText);    
       
    48     }
       
    49 
       
    50 
       
    51 void MsgServiceInterface::open(qint64 conversationId)
       
    52     {
       
    53     mViewManager->setServiceRequest(false);
       
    54     mViewManager->open(conversationId); 
       
    55     }
       
    56 
       
    57 void MsgServiceInterface::send(QVariant data)
       
    58     {   
       
    59     mViewManager->setServiceRequest(true);
       
    60     mViewManager->send(data);    
       
    61     }
       
    62 
       
    63 void MsgServiceInterface::view(int msgId)
       
    64     {   
       
    65     mViewManager->view(msgId); 
       
    66     }
       
    67     
       
    68 void MsgServiceInterface::openConversationView(QString number, QString name)
       
    69     {
       
    70     mViewManager->setServiceRequest(true);
       
    71         
       
    72     QString resolvedName;
       
    73     if(name.isEmpty())
       
    74         {
       
    75         ConvergedMessageAddress address;
       
    76         address.setAddress(number);
       
    77         address.setAlias(name);        
       
    78         
       
    79         ContactDetail contactDetail;
       
    80         bool ret = resolveContact(address, contactDetail);
       
    81         if(ret)
       
    82             {
       
    83             resolvedName = contactDetail.displayName;
       
    84             }
       
    85         }
       
    86     mViewManager->openEditor(number,resolvedName);
       
    87     }
       
    88 
       
    89 bool MsgServiceInterface::resolveContact(
       
    90                                          const ConvergedMessageAddress &address,
       
    91                                          ContactDetail &contactDetail)
       
    92 {
       
    93     QString displayLabel = QString("");
       
    94     int localId =
       
    95             MsgContactHandler::resolveContactDisplayName(address.address(),
       
    96                                                          displayLabel,
       
    97                                                          0);
       
    98 
       
    99     if (localId != -1)
       
   100     {
       
   101         contactDetail.contactId = localId;
       
   102         contactDetail.displayName = displayLabel;
       
   103         return true;
       
   104     }
       
   105     
       
   106     return false;
       
   107     }
       
   108