examples/QtQuick/callinfo/callinfo_symbian.cpp

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation
00006 **
00007 **
00008 ** $QT_BEGIN_LICENSE:BSD$
00009 ** You may use this file under the terms of the BSD license as follows:
00010 **
00011 ** "Redistribution and use in source and binary forms, with or without
00012 ** modification, are permitted provided that the following conditions are
00013 ** met:
00014 **   * Redistributions of source code must retain the above copyright
00015 **     notice, this list of conditions and the following disclaimer.
00016 **   * Redistributions in binary form must reproduce the above copyright
00017 **     notice, this list of conditions and the following disclaimer in
00018 **     the documentation and/or other materials provided with the
00019 **     distribution.
00020 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00021 **     the names of its contributors may be used to endorse or promote
00022 **     products derived from this software without specific prior written
00023 **     permission.
00024 **
00025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00036 ** $QT_END_LICENSE$
00037 **
00038 ****************************************************************************/
00039 
00040 #include "callinfo_symbian.h"
00041 #include <QDateTime>
00042 #include <e32std.h>
00043 
00047 CallInfoExPrivate* CallInfoExPrivate::NewL(CallInfoEx *aPublicAPI)
00048 {
00049     CallInfoExPrivate* self = new (ELeave) CallInfoExPrivate(aPublicAPI);
00050     CleanupStack::PushL(self);
00051     self->ConstructL();
00052     CleanupStack::Pop(self);
00053     return self;
00054 }
00055 
00059 void CallInfoExPrivate::ConstructL()
00060 {
00061     iTelephony = CTelephony::NewL();
00062 }
00063 
00068 CallInfoExPrivate::CallInfoExPrivate(CallInfoEx *aPublicAPI)
00069     : iLineStatusV1Pckg(iCallStatusV1), iCallInfoV1Pckg(iCallInfoV1),
00070       iRemoteInfoV1Pckg(iRemoteInfoV1),
00071       iPublicAPI(aPublicAPI), CActive(CActive::EPriorityHigh)
00072 {
00073 
00074     // Active objects like this one must register
00075     // themselves with an Active scheduler.
00076     CActiveScheduler::Add(this);
00077 }
00078 
00079 CallInfoExPrivate::~CallInfoExPrivate()
00080 {
00081     // Cancel any outstanding requests before this object is destroyed.
00082     // This destructor cannot leave - so trap any problems here.
00083 
00084     Cancel(); //  Calls DoCancel()
00085     delete iTelephony;
00086 }
00087 
00088 
00092 void CallInfoExPrivate::startNotification()
00093 {
00094     iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange, iLineStatusV1Pckg );
00095     SetActive();
00096 }
00097 
00101 void CallInfoExPrivate::GetCallInfo()
00102 {
00103     CTelephony::TCallSelectionV1 callSelectionV1;
00104     CTelephony::TCallSelectionV1Pckg callSelectionV1Pckg( callSelectionV1 );
00105     callSelectionV1.iLine = CTelephony::EVoiceLine;
00106     callSelectionV1.iSelect = CTelephony::EInProgressCall;
00107 
00108     // Retrieves information about the call selected by the aCallSelect argument.
00109     iTelephony->GetCallInfo(callSelectionV1Pckg, iCallInfoV1Pckg, iRemoteInfoV1Pckg);
00110 
00111     emit iPublicAPI->updateCallInfo("................\n");
00112     emit iPublicAPI->updateCallInfo("Time:");
00113     emit iPublicAPI->updateCallInfo(QTime::currentTime().toString());
00114     emit iPublicAPI->updateCallInfo("Date:");
00115     emit iPublicAPI->updateCallInfo(QDate::currentDate().toString());
00116 
00117     QString displayNumber;
00118 
00119     if(iCallInfoV1.iStatus == CTelephony::EStatusRinging){
00120     displayNumber = QString::fromUtf16(iRemoteInfoV1.iRemoteNumber.iTelNumber.Ptr(),
00121                                                iRemoteInfoV1.iRemoteNumber.iTelNumber.Length());
00122     emit iPublicAPI->updateCallInfo("Call Received from :");
00123     }
00124     else{
00125     displayNumber = QString::fromUtf16(iCallInfoV1.iDialledParty.iTelNumber.Ptr(),
00126                                                iCallInfoV1.iDialledParty.iTelNumber.Length());
00127     emit iPublicAPI->updateCallInfo("Dialling :");
00128     }
00129 
00130     emit iPublicAPI->updateCallInfo(displayNumber);
00131     emit iPublicAPI->updateCallInfo("................\n");
00132 }
00133 
00138 void CallInfoExPrivate::RunL()
00139 {
00140     CTelephony::TCallStatus voiceLineStatus = iCallStatusV1.iStatus;
00141     switch(voiceLineStatus)
00142     {
00143     case CTelephony::EStatusRinging:
00144         emit iPublicAPI->updateCallStatus(".......................");
00145         emit iPublicAPI->updateCallStatus("Phone is ringing");
00146         GetCallInfo();
00147         break;
00148 
00149     case CTelephony::EStatusAnswering:
00150         emit iPublicAPI->updateCallStatus(".......................");
00151         emit iPublicAPI->updateCallStatus("Answering");
00152         break;
00153 
00154     case CTelephony::EStatusDisconnecting:
00155         emit iPublicAPI->updateCallStatus(".......................");
00156         emit iPublicAPI->updateCallStatus("Disconnecting");
00157         break;
00158 
00159     case CTelephony::EStatusDialling:
00160         emit iPublicAPI->updateCallStatus(".......................");
00161         emit iPublicAPI->updateCallStatus("Dialling");
00162         GetCallInfo();
00163         break;
00164 
00165     case CTelephony::EStatusConnecting:  
00166         emit iPublicAPI->updateCallStatus(".......................");
00167         emit iPublicAPI->updateCallStatus("Connecting");
00168         break;
00169 
00170     case CTelephony::EStatusConnected:
00171         emit iPublicAPI->updateCallStatus(".......................");
00172         emit iPublicAPI->updateCallStatus("Connected");
00173         break;
00174 
00175     case CTelephony::EStatusHold:
00176         emit iPublicAPI->updateCallStatus(".......................");
00177         emit iPublicAPI->updateCallStatus("Hold");
00178         break;
00179 
00180     case CTelephony::EStatusIdle:
00181         emit iPublicAPI->updateCallStatus(".......................");
00182         emit iPublicAPI->updateCallStatus("Idle");
00183         break;
00184     }
00185     if(!IsActive()){
00186     iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange, iLineStatusV1Pckg );
00187     SetActive();
00188     }
00189 }
00190 
00195 void CallInfoExPrivate::DoCancel()
00196 {
00197         iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
00198 }
00199 
00200 
00201 
00202 

Generated by  doxygen 1.6.2